laserscan not showing up correctly in rviz
I an running ros on 2 raspberry pi's. one pi runs master, mapserver, gmapping or amcl and my motor control and sensor node. on the other I an running Rviz. I am in my motor control and sensor node I and turning sonar readings into lasersans by adapting a sonartolaserscan package. I added the laserscan layer in rviz and I see the scan dots but they are not oriented correctly. I can see the values change as I put an obstacle in different positions. I have the obstacles in such a way that I tell where the laserscan dots should be but they are not. Hopefully the image will attach. What should be direction in front of the robot is out the back and not directly opposite from where it should be (1) The one that should be on the robot's left (2) should be 90 degrees left but it is more like 120 degrees left and the one on the right should be 90 degrees right but it is move like 160 degrees right.
Sorry I am not able to add and image
I do not know if the problem is my urdf or my code or I am missing a transform.
Here is the code where I set up the message for the laserscan with all values as no value
scan.header.frame_id = "/base_link";
scan.angle_min = 1.81514242;//DEG_TO_RAD(MIN_ANGLE);
scan.angle_max = -1.81514242;//DEG_TO_RAD(MAX_ANGLE);
scan.angle_increment = 0.034906585;//DEG_TO_RAD(DEG_INCREMENT);
scan.time_increment = (1.0 / 100) / (NUM_READINGS);
scan.range_min = 0.0;
scan.range_max = MAX_SONAR_CM;
scan.ranges.resize(NUM_READINGS);
scan.intensities.resize(NUM_READINGS);
for(unsigned int i = 0; i < NUM_READINGS; ++i) {
scan.ranges[i] = (double)(MAX_SONAR_CM + .15)/100.0;
scan.intensities[i] = 0;
}
Then here is code where I set the appropriate laserdots that correspond to the sonar readings during each sensor update.
ROS_INFO("begin scan conversion");
scan.header.stamp = ros::Time::now();
// overwrite the no signal with our sonar for the 14 readings within our beam
for(unsigned int i = 0; i < 8; ++i){
scan.ranges[i] = (float)(LeftF/100.0) + SIDE_OFFSET;
scan.intensities[i] = 0.5;
}
for(unsigned int i = 26-3; i < 26+3; ++i){
scan.ranges[i] = (float)Front/100.0 + FRONT_OFFSET;
scan.intensities[i] = 0.5;
}
for(unsigned int i = 53-9; i < 53; ++i){
scan.ranges[i] = (float)Right/100.0 + SIDE_OFFSET;
scan.intensities[i] = 0.5;
}
ptr_scan_pub->publish(scan);
ROS_INFO("end scan conversion");
I tried to add a transform for base_link to laser but got an error message saying the transform is already published in my motor control and sensor node Here is the urdf <robot name="robpi"> <link name="base_link"> <visual> <geometry> <box size="0.17 0.267 0.267"/> <origin rpy="0 0 0" xyz="0 0 0"/> <material name="blue"> <color rgba="0.0 0.0 0.8 1.0"/> </material> </geometry> </visual> <collision> <geometry> <box size="0.21 0.3 0.267"/> <origin rpy="0 0 0" xyz=".01 .01 0"/> </geometry> </collision> </link>
<link name="left_wheel ...
Please format your question text properly. Use the Preformatted Text button (the one with
101010
on it) to format console copy-pastes, code, and urdfs.I've also given you enough karma to so please attach an image that shows what is going on.
Thanks.