Lab 12: Path Planning and Execution

Objective

In lab 12, the goal was to combine everything from all of the previous labs to have the robot drive to a set of waypoints.

I worked with Eshita Sangani on this lab.

Design Approach

The planned trajectory around the waypoints is shown below.

Ideally, I would do localization as the robot drove around the map, relocalizing each time it hit a waypoint. However, due to time constraints, I first pursued open loop control with PID control and decided to do localization if time allowed,

To achieve this, I designed 3 Ardduino functions - FORWARD, TURN_POS_90, and TURN_NEG_90.

The FORWARD function was essentially the PID controller from lab 6. However, this time the target disance was set as a user input to allow us to reuse the function. As before, the kP value was also set by the user. This allowed us to drive both forwards and backwards, depending on how far the car was from the target.

The TURN_POS_90 function turned the robot clockwise a specified angle. Note that the function name is misleading; it was originally meant for the robot to only turn 90 degrees but I was able to change the amount turned to a user specified value.

This code was adapted from lab 9. The car has the same target angular velocity from the gyroscope, and I used the time to determine when the robot had turned 90 degrees. With more tuning, I probably should have used the angular position (by integrating it over time) to get more accuracy.

The TURN_NEG_90 function was exactly the same as the previous function but it turned in the other direction. The timing was adjusted since the wheels did not rotate the same in each direction. The code is shown below.

Plan in Action

In practice, this required a lot of tuning to get both all of the kP values correct, as well as get the exact target distances. However, the above scheme did allow for this to be smoother, as everything could be edited within the jupyter side rather than having to modify and reupload the Arduino code each time. The final values as well as the jupyter code is shown below.

As mentioned above, tuning the jupyter code required the most work. This was because both the kP and target values needed to be tuned to drive forward, so it required much more work than the typical PID tuning process. The Arduino code only required some manipulation of the setup to ensure there was no slowdown or noise from the sensors, of which there ended up being none. To tune both the kP and targets, manually calculated the values for each waypoint, referencing the first image at the very top of this page. However, after I had tuned those values perfectly, I struggled with the integration. Since I only used PID control, the ending position of one waypoint was not necessarily exactly on that specific waypoint or exactly in the desired angle, which made tuning these values, specifically the distances, extremely difficult. Then I decided to do the pathway in chunks, hoping that would allow for some easier integration. That ended up being the best strategy.

However, on the last day in lab, both the Artemis and the motor batteries sarted behaving in unexpected ways, the ToF sensor stopped working, and the number of people in the lab was so high that testing any changes took a long time due to having to wait.

All of the videos can be found in the following playlist here.

While there were not any full runs, the robot was able to drive around and hit waypoints, especially as seen in the middle section of the route, and there was a long run that showed that the robot was able to reach most of the waypoints.

Unfortunately, I was not able to add in localization due to time constraints as I had planned to before. If I had, and also integrated orientation control, then perhaps the robot would have been more accurate at reaching all of the waypoints.

Reflections on the Class

This class was so challenging and difficult, and I really wish I had taken it in a semester where I had a lighter workload. However, I am so thankful to all of the TAs (specifically Lemon and Cameron, my lab TAs!!) for helping out with all of my stupid questions and weird hardware issues. Also, I would like to thank Professor Petersen for teaching this class this semester. You guys have been incredibly patient and helpful this semester!