Continuing the Laser Mapping exercise 2
Overview
This week I kept working on the laser mapping exercise again.
Updating map
First I updated the map of the universe with thicker exterior walls so when the user draws their map, they have room to draw it if there is some noise or it ends up rotated.
With the new map dimensions I also updated the setUserMap function and the ones that draw the robot on the map so it’s placed correctly, to modify them I did the same process I did last week.
Adding getOdom2 and getOdom3 functions
I also added two new functions to HAL, getOdom2() and getOdom3(). They essentially work the same as getOdom() but the odometry it gives you has more noise, with getOdom3() being the one with the most amount of noise. To change the level of noise of each one, I had to look up and change the class they are using from hal_interfaces, noisy_odometry_node. This class has a variable called noise_level that you can set and it’s an argument for the function that adds the noise to the odometry, however, it wasn’t being used at all and instead it was using a number, so I changed it so it correctly uses the noise_level argument and the number is now the default value it takes if no noise_level is set. Now in the HAL.py from laser_mapping, I could change that noise_level on each getOdom function so they have more or less noise.
After testing for a while, I noticed the noisy_odometry_node class wasn’t adding the noise correctly. It was adding the noise to the difference between the last coordinates and the new ones (adding noise to the x coordinate and another noise to the y coordinate) and the yaw difference. However, the noise in the coordinates wasn’t taking into account the new noisy orientation so it ended up not changing how much the robot rotates. If the robot rotated 45 degrees, the noisy odometry would also rotate exactly that, without adding noise there. To fix this, I first calculate the distance between the last pose coordinates and the new ones and add the noise there instead of x and y, and then calculate the new cartesian coordinates with the noisy distance and the noisy yaw (that was already being calculated).
Creating the solution of the exercise
In the process of creating and testing this exercise I also did the solution for laser mapping. This one was very simple, for the construction of the map I get the laser readings and substract 1 to the pixel where the laser collides with a wall or object, the map is a grayscale image where the white color is 255 and black is 1, so the pixels become darker and darker the more it reads there’s an obstacle there, I don’t set the pixel to 1 directly just in case it’s a false positive due to noise.
For the movement of the robot, I just did a simple random navigation algorithm.
You can also change which odometry to use for the construction of the map and see the difference between them by changing a variable the function uses (getPose3d, getOdom, getOdom2 or getOdom3).