Lab 9: Localization on the real robot
Objective
The purpose of this lab is to localize from the map in lab 7 using the actual robot. The main objective is to note the differences between simulation and real life.
Procedure
First, I ran Lab9_sim in Jupyter Lab and got the simulated version of localization below. Similar to Lab 8, it shows that odometry (blue) is not a good method of localization,but Bayes filter (yellow) is. (Green is truth pose).
Second, I added my map. I also added an obstacle as it was recommended for localization.
When I ran the jupyter lab, it threw an error that it was not able to produce the map. It seemed that other people had similar problems on campuswire and solved it by adding a border around the map. I also added a border, but it still threw the same error even after changing the map limits using Mapper so I just converted my map units to meters and then used the Mapper border limits that was originally given. Then I no longer had an error.
Initially, I wasn't able to connect to bluetooth via VM. Even taking a few days trying to figure out the code, I wasn't able to figure it out on my own and decided to just test the Bayes filter by taking the measurements manually instead of through bluetooth. Using arduino code from lab 7, I collected data separately by having the robot turn approximately 20 degrees per second and take 18 distance measurements. However, since there is friction, battery life and other factors that affect how well the robot rotates, I was able to get 18~22 data points. Since I wasn't sure how many I would get each time, I filtered the data in perform_observation_loop.
I ran the bayes filter and got the output below. It wasn't very accurate in terms of its y position. I believe there are couple reasons why this could be. First, the robot does not rotate perfectly at its axis, especially at the speed of 20 degrees/second. There is a radius of rotation that can cause inaccurate distance measurements. Secondly, my obstacle may be too small to be detected during the rotation. It is completely possible that the distance between the obstacle and the robot was not measured at all since there are only 18 measurements. Third, since my map have all rectangular sides, it is possible it confused the robot of its true location since all the corners are similar. Out of the four tries, two of the measurements were pretty accurate.
I attempted the bluetooth connection in Jupyter notebook again after watching the tutorial videos from Alex. I made the edits that he suggested and also added a doScan function. After some finicking around with the code, my robot was able to connect!
This was very exciting and I tried to attempt the doScan function that Alex mentioned, but got error for callRemote. Since this was a built-in function from the code and bleak module, I was unable to debug it even after editing other functions. I'm glad I was able to connect to the robot on Jupyter notebook, but I decided to end the lab here since I have been spending too long debugging with the bluetooth.