Lab 11
The purpose of this lab is perform localization with the Bayes filter on the physical robot. The Bayes filter will make a belief about where the robot is based on a full 360 degree spin at each of the locations.
Localization in Simulation
The first task of the lab was to run the simulation and ensure the provided code all worked properly. This is the corrected code from Lab 10, and the procedure is roughly the exact same. A picture of the plot is shown below to prove that the code and simulation is working correctly.
Implementation on Robot
While most of the code was provided for us, we were responsible for implementing the PID orientation control. This was taken from Lab 9, and the only thing I needed to adjust was to have it spin every 20 degrees instead of 10. However, my code from Lab 9 collects more than 18 data points, and the provided code can only handle 18 points, one from each angle. In order to fix this issue, I added a secondary post-processing step that extracts the ToF value at each of the desired angles from 0 to 340 degrees. The full code is shown below.
Tested Points on Map
The first tested location was (5,-3). This location localized exactly on the correct location. The plot is shown below, with the blue dot representing the belief of the robot's location.
The second tested location was (5,3). This location localized well, but not perfectly. It was an extra foot in the positive x direction and down a foot in the y direction. The plot is shown below, with the blue dot representing the belief of the robot's location, and th green dot representing the actual location of the robot.
The third tested location was (-3,-2). This location localized exactly on the correct location. The plot is shown below, with the blue dot representing the belief of the robot's location.
The final tested location was (0,3). This location localized exactly on the correct location. The plot is shown below, with the blue dot representing the belief of the robot's location.
Lab 11 Takeaways
This lab was relatively straight forward, as it mostly built on the code from Labs 9 and 10. However, it was very interesting to see how the Bayes filter predicted where the robot was located within the lab map. A few times, the belief would be drastically off, and it was interesting to try and debug based on the polar coordinate plot. Overall, it shows the usefulness of using a Bayes filter, and it will definitely help for the final lab.