This lab was dedicated to combining our past labs to fully implement our chosen stunt on our robot as fast as possible (I chose Task A). Additionally, I also implemented a custom open-loop stunt that will be detailed more below.
The full implementation of Task A was to drive the robot until it was exactly 500 mm away
from the wall, flip, and drive back to its starting line as fast as possible.
I first implemented this by tuning my PID with Kalman Filter from Lab 6 and 7 to a point where it could stop at exactly
500 mm away from the wall without oscillations, which took a considerable amount
of time. I then added code that would cause the robot to go full speed backward back to
the starting line. The results can be seen in the video and plot below (note: the plot becomes a bit strange in the
later portion due to the robot going out of the ToF's sensors range and also hitting things beyond the starting line):
Unfortunately, this only completed two of the three tasks and the robot was not able to flip.
After talking with the professor, I discovered that the problem was because
my PID controller caused the robot to smoothly slow down as it approached the wall (as it is
designed to do). This causes problems with flipping because in order the flip, the robot actually instead
needs to go full speed forward and then full speed backwards in order to flip without slowing down.
This meant that the PID controller designed in Labs 6 and 7 and finely tuned in this lab wasn't actually needed,
and I had to find a new solution to accomplish this task.
My new solution was considerably simpler and started with moving the robot forward at full speed. I then
used the front ToF sensor and a Kalman Filter to figure out the robot's distance from the wall. When
when it is at about 500 mm from the wall (I had to increase the trigger distance a fair bit), it performs a flip by hard braking very briefly
and going full reverse. Then it reverses at a slightly slower speed (to avoid doing multiple flips). Unfortunately, after much
trial and error, I discovered that my robot was actually physically unable to flip due to it being front
heavy from me placing all my components in the robot's front compartment. After
redistributing the weight by re-soldering and moving the components around, I next discovered that the ToF sensor started
having trouble measuring the distance to the foam padding on the wall, although it seemed to still work well measuring the distance
to a normal wall. After several hours of testing and unsuccessful debugging, I finally decided that I've spent too much time on this
lab and decided to modify the strategy described above to replace the distance trigger using the ToF and Kalman Filter with
a simple timer. This worked surprisingly well and consistently, and below is a video of the stunt:
For my open loop stunt, I chose to do a linear drift, where the robot tries to drift on its side for
as great a distance as possible. This was actually a surprisingly difficult task since it was
very easy for the robot to either not drift and just make a wide turn, or drift but then lose control and spin out.
From Lab 4 I found that a good sequence to do this is:
Motors forward at full speed to gain momentum > Turn off motors >
Short right turn to initialize drift > Turn off motors to let it rotate about 90 degrees >
Short left turn to prevent the robot from losing control and spinning out.
After much trial and error adjusting the timings
for this sequence, I produced this code that could reliably perform open-loop linear drifts:
Here are three runs of this, with the greatest drift distance being about 3 feet:
The robot randomly decides to ram into the computer controlling it. Is this the beginning of the robot revolution?