Lab 8: Stunts!

Aidan Chan (amc564@cornell.edu)

Prelab

With extra time over break, I reorganized my code, taking inspiration from Stephan Wagner as seen in the dependency diagram below:

missing

Lab

Drift Methodology

My initial strategy was to drive as fast as possible towards the wall, then drive one motor fully forwards and the other backwards to drift. But, it looks more like a glorified turn:

The robot doesn’t lose traction. I tried a lot of different speeds to get the robot to lose traction but I could not. So, I reduced the traction of the wheels by adding tape to the two back wheels. This performed slightly better but the robot could still not properly drift. Thus, I moved on to adding tape to all the wheels and moving from a wood to a tiled surface, which had a lower coefficient of friction, as demonstrated below:

Robot with tape:

missing

By implementing my strategy I discussed earlier, I was able to achieve the result below:

However, the tile had too low of a coefficient of friction. It can drift well when making the turn, but maybe too well, as when it makes its way back to its initial position, it lacks enough traction and can't go back straight. So, as a middle ground, I returned to the wooden floor and I had much better results.

Software

I start around 3m away from the wall. First, I will go forwards at 90% of my maximum speed (0.9*200=180). If I go too fast, it will be harder to control the drift, as the robot will build up more linear momentum. I don’t use a KF since I don’t need to react that fast. I start the turn at 2250 mm from the wall. I know we should turn within 914 mm, but the handout allows manually changing the distance to the wall where we initiate the turn. If I went too close to the wall, the car would build up more linear momentum, and I would not have enough space to decelerate in time, and thus I would collide with the wall.

Once the TOF receives a distance less than 2250 mm, the robot first does a quick, gentle turn where the left motor is at full speed while the right motor is still spinning forwards but at half its max speed for 50ms. This will generate a small angular and lateral velocity while the static friction with the ground is great enough to prevent the car from slipping. Then I initiate a much more aggressive turn where the right motor now goes backwards at 70 PWM to exceed the maximum static friction force, which causes the robot to slide (kinetic friction). The robot will begin to slide/drift until the IMU reads 30° or more (using the DMP, the initial angle is 0° going forwards). Then I stop both motors immediately, allowing the angular momentum built up to continue to spin the robot (without motor torque) until the IMU reads 170° or more. However, there is still enough momentum built up that it will continue to rotate in the CW direction. So after 170°, I turn in the CCW direction by setting the right motor to 180 PWM forwards and the left motor to 86 PWM backwards to counteract the momentum in the CW direction for 165ms. Then I stop both motors for 80ms (I found if I go straight right away, the robot loses control, so this is a compromise to still make it seem like one fluid motion) and then go full speed forwards for 1500 ms. I was thinking of putting up a wall at the starting point so I could do PID until I was a foot from the starting point wall, but my PID controller wasn’t as effective anymore with the new surface and taped wheels. Thus, open loop was satisfactory.

missing
missing

Demo

Here is the best demo I recorded:

missing
missing

I didn’t think to record yaw data for the last 80ms of the turn where the motors brake and the robot is brought to 180°. But, the video shows a full 180-degree drift-turn.

missing

Video of a later attempt where I edited the code to collect more yaw data.

missing
missing

Around 1600ms, the robot is 180° from its original position. Because of atan2, as the robot rotates CW, the measurement goes from 180° to -179°, etc. So in reality, the robot does stay around 180° from the original angle after around 1600ms. So, it drives pretty straight as well on the return. Also around 1200ms, the angular speed decreases from rotating the robot CCW to decrease the built-up angular momentum.

missing

Evidence of other runs to prove consistency:

Bloopers

Collaborations

Thank you Prof. Helbling. I referenced Jack Defay's webpage. Hunter inspired this website template.