Home Skip to the content.

Lab 8: Stunts

Lab Objective

The purpose of this lab is to combine the work done in previous labs to control the robot in a high-speed stunt. For the controlled stunt, I chose to do an orientation task which involves turning the car quickly and driving back to where it came from.

Task B: Orientation Control

For this lab, I was tasked with turning the robot at a specified distance from the wall. More specifically, the goal was to drive the robot forward as fast as possible starting at a distance of less than 4 m from the wall. Then, at a distance of 3 feet, the robot will turn 180 degrees and head back to the starting line.

There are two key components in successfully completing this lab:

  1. Quickly and correctly estimating the distance from the wall such that the robot initiates the turn on time.
  2. Making the 180-degree turn correctly and quickly.

I am not using the Kalman Filter to estimate the distance, but I am using linear interpolation which helps the robot estimate the distance to the wall quicker than if I only used the ToF sensor readings.


Implementation

The task is divided into four different sections:

  1. Drive forward quickly until the robot is 3 feet from the wall.
  2. Quickly turn the car 180 degrees.
  3. Drive back to the starting line.
  4. Send data over Bluetooth.

To accomplish this, a new case "STUNT" was created:

Stunt case

Below is the logic of my main loop as well as the doStunt function. These were the two main components of the implementation. Additional functions worked as helper functions. Notice that doStunt is called right away from the loop. When the desired position is reached, it calls the reverse function, which activates my orientation PID. Finally, the car accelerates back from where it came from.

Main loop
doStunt function

Two main challenges arose when completing this lab.


Results

The videos below show that my stunt is working well. The robot travels fast, initiates the turn at the right distance, and then quickly drives back to the starting line.

And here is the collected data of the change in angle over the run:

Angle graph 1
Angle graph 2
Angle graph 3