In this lab, I programmed my car to do a drift that followed the following requirements:
I implemented the drift stunt by combining code I developed from the previous labs. Steps 1 and 2 were accomplished using the Kalman Filter code developed in Lab 7. I disabled PID control so the robot would drive forward quickly, instead supplying a constant PWM value.
I used code from lab 6 to turn the car 180 degrees. I modified the orientation PID controller so it would turn 180 degrees from its starting orientation. I modified the PID gains to minimize the time it takes during the drift. This led to significant overshoot, but it made the stunt execute faster and look cooler (in my opinion). After turning the car 180 degrees, I programmed it to drive back across the starting line. One major modification I made was that I slowed down the DMP’s data rate, so it would overload and crash the Artemis. I implemented this after reading Stephan Wagner’s website, where he first implements this to prevent the DMP from crashing his Artemis.
The screenshots below show the code and the associated functions. The main code runs in a loop, calling external functions as necessary. The external functions are essentially unchanged from previous labs, but are listed here for completeness.
Main Loop code:
External Functions:
I transmitted the data back to the computer using the same callback functions developed in labs 5 and 6.
I recorded 3 videos of the robot successfully executing the stunt.
Trial 1: starting distance = 2184mm , run time = 4.25s
Trial 2: starting distance = 2205mm, run time = 4.5s
Trial 3: starting distance = 2401mm, run time = 4s
I have added videos of several additional successful stunts to showcase system reliability.
This lab was very fun as I got to combine code and functionality that I had developed over the previous 3 labs into a cool stunt.