Prelab
Before this lab, I read over the lab tasks and devised a plan for rotation control. Like my Linear PID lab, I decided to start with P control, and if my car was not quickly converging to a set point, I would try to include the derivative and/or integral terms.
Lab Tasks
P Control
Below is the code I used to implement P control:
Note that I have functionality to stop the control loop when the car has been at the target angle for enough time. This was included to ensure that the car’s stopping location was consistent, and this functionality was disabled when I was testing if the robot could hold at an angle (and not have any unexpected jumps).
First, I tried this control with Kp = 0.5:
Since this led to constant overshooting of the target angle, I reduced Kp to 0.1:
While this was better, I figured that instead of incorporating another term into the control loop, I would try Kp = 0.05 to see if I could achieve satisfactory results:
Kp = 0.05 seemed to work very well, and I confirmed this with the ‘kick test’:
Therefore, with Kp = 0.05, I was able to complete orientation control.
Acknowledgements
I referenced past students Mikayla Lahr’s and Nila Narayan’s websites for implementing the methods.