The objective of this lab is to combine everything I've done up till now to do fast stunts.
Back to mainpageFor this lab, I made my robot drive towards the wall as fast as it can and when was within 3 feet of the wall, perform a 180 degree drift and come back to the start line.
First off, since I chose to do position control for lab 6, I had to write new code for orientation control for this lab. I used code from lab 4 to compute the yaw angle of the robot. Then I implemented a proportional controller to control the robot's orientation (i.e. yaw). Here is the code I wrote to achieve this:
Here is a video of the orientation control working:
Below is the plot of the time vs. orientation (yaw) from the video above:
My plan for the stunt was to simply use the code I wrote for the orientation control but add in an offset to the PWM values by a value of 100 so that the robot moves forward with 100 PWM while maintaining control of its orientation. Then when it got to 300 mm from the wall, it would perform a 180 degree turn and return to its initial starting position while maintaining its original orientation using orientation control. Unfortunately, getting the robot to do a stunt using the orientation control developed in the previous section proved to be a real challenge. One of the biggest problems I had was that if the angular velocity of the robot changes too fast, the zero point of the robot's orientation changes. This is likely due to the fact that the angular velocity was changing quicker than the control loop could run (i.e. the code could not integrate the angular velocity quick enough to accurately capture the robot's orientation). Therefore, I had to use open-loop control to perform the stunt. The code for the open-loop control is below:
Here are videos of 3 successful runs of the stunt:
If time allows at the end of the semester, I plan to implement the extrapolation method from lab 7 such that the robot can react faster to sensor measurements.