Lab 8: Stunts

Flip Stunt Description

To complete this stunt, my robot had to start from a designated line less than 4 meters from the wall, accelerate forward at a high speed without using PID position control, hit a sticky mat positioned 1 foot from the wall to trigger a front flip, and then drive back in the original direction. Success was determined by whether the robot completed the flip and made it back across the starting line without veering off course.

Completing the Stunt

I added weight to the front of the car to help it flip by taping on two 9V batteries. This shifted the center of mass forward so that, when the robot hit the sticky mat at high speed, it would rotate and flip instead of just stopping or bouncing.

I set up a Python command to initiate the flip and another to send position and PWM data once the stunt was completed, just like in past labs.

The flip sequence began by driving the car toward the wall at full speed (255 PWM). Using trial and error, I found that triggering the flip at 1200 mm worked best. When the distance sensor read 1200 mm, the robot switched to -255 PWM, causing it to slow down sharply and flip on the mat, then start driving in the opposite direction. After one second of reverse motion at -255 pwm, the car was switched to -150 PWM to return to the starting line. I found this PWM level allowed it to reliably cross back instead of veering off, although looking back, I could have kept it at -255 pwm. The car drove away from the wall for three seconds, at which point I had to physically catch it. This value of three seconds could have been reduced to keep me from chasing the car down.

Flip Code Snippet:

Flip stunt code snippet

Troubleshooting

My main troubleshooting focused on tuning the sensor distance to trigger the flip and calibrating the return speed so the car wouldn’t go off course. I initially attempted to use a Kalman filter to clean up the distance sensor readings, but found it unnecessary—my car flipped reliably without it.

Video 1 & Graphs

Graph 3

Video 2 & Graphs

Graph 3

Video 3 & Graphs

Graph 3

The graphs show the distance sensor readings up until the flip, after that point they're not needed. My PWM graph shows the PWM value at -150 at the end, which is where it stayed until it crossed the line and I caught the car.

Average Time to complete full stunt: 2.7 seconds

Discussion

I really enjoyed getting to make the car do stunts—it made me think more about how the physical behavior of the robot interacts with the code and sensor input. I had to adjust the robot’s hardware (adding front weight) and software (tuning sensor thresholds and timing) to achieve the flip. The sensor didn’t trigger at exactly the mat’s position, which highlighted the importance of adjusting your system for the actual conditions and not just theoretical measurements.


Back to Main Page