Real Robot Lab - Sensor giving weird values


I am working on Rosject (follow wall) of ROS2 Basics in 5 Days: Course Project. I managed to get the first simple code for the robot to just follow the wall in simulation. It works quite well in there. But when working with the real robot, something with the LaserScan sensor doesnt seem right.

In the first image I attached, you can see the readings of the real robot. They correspond to the robot moving mostly forwards and getting closer to a wall, while it maintains a tiny distance with another wall to its right.

The second image shows the part of the code where I read those values from the /scan topic and show them in the terminal. Even though the front part of the robot is getting closer to a wall, the scan tells that the distance increases. On the other hand, the scan of the back of the robot always tells that it is close to something (while actually it is getting away from another wall!)

These values are too different from the ones I get in the simulation. Even worse, the apparently dont make sense. This makes my code not work at all and make the robot behave in unpredictable ways.

Can someone tell me if they have had the same problem? Is there any advice that you could give me?


Because im a new user, I can only add one image per message. Here is the second one:

The real robot laser may not have the exact same parameters as the simulated one. Check the /scan topic while it is active to see what the min/max angle is, and the increment. From this you can determine how many values are in the ranges array and from that which locations in the array correspond with front, left, right, behind*. Keep in mind the array is formatted where 0 would be the clockwise most position and what ever the max is would be the CCW most position. For example, if the min angle is -pi and the max angle is pi, and the increment results in 360 positions, 0 and 360 would be directly behind the robot. This implies that the front direction will be the half value of the actual size of the ranges array.

*Also keep in mind it is possible that the min/max angle may not result in full 360 coverage, this does not change the front position, but there may be no behind and left/right are not quite as simple as dividing it into quarters.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.