In this lab, I implemented localization on a real robot. Iniially, I used a simulator to test out the given localization code and confirm that it was working. In this lab, we were provided with optimized localization code, so I used this instead of using my implementation from lab 10.
I tested the simulated code and obtained the following result for the bayes filter. This screen shows the simulated code running successfully.
After confirming with the simulator, I moved onto implementing localization on the real robot. I implemented the given functions in python to connect the simulator to my physical robot.
This is the main python function that communicates with the robot. This function sends BLE commands to the robot to enable PID and start localizing. There is delays built in to ensure the commands are sent and processed by the artemis. The robo does one full spin, gathers data, and then sends back the angle and distance data to the computer. This function uses callbacks to proccess the incoming data from the robot. After the data is collected, the function returns this data to the main localization script.
The callback functions are provided below. They are essentially the same callback functions used throughout the remaining labs, but are listed here as well.
The arduino code is essentially the same as lab 9, but I modified it so it only does increments every 20 degrees instead of 15. Additionally, I didn’t collect 4 measurements per angle, only one.
Using this code and the python functions, I evaluated the localization in 4 places.
(-3, -2);
In this case, the localization was pretty accurate, but not exact.
(5,-3):
The localization was almost perfect in this case, indicating that the sensor measurements were very good at this point.
(5,3):
The localization was relatively accurate here, but not as good as the previous locations.
(0,3):
The localization was almost perfect in this case, indicating that the sensor measurements were very good at this point.
Overall, the sensor measurements were very accurate at (0,3) and (5,-3), potentially becuase of numerous obstacles surrounding them, so the sensor is able to localize off of multiple objects. Also, it is interesting the note that the initial angle measured was often around 10 degrees, even though my robot started at 0 degrees. This is probably because my robot’s DMP was not zoroed perfectly, so it was at a slight offset. Additionally, the robot did not turn to the exact angles (18 degrees instead of 20), which casued some error in the localization filter. Overall, it did a good job localizing the robot.
It was cool to see the robot able to succesfully localize using a bayes filter. I don’t know if I will actually use this during lab 12, but it was still cool to implement localization on a physical hardware.