Lab8 - Drift Stunts
Published:
Objective
The purpose of this lab is to combine everything from the past labs to do fast stunts. Specifically, I chose to do the drift stunt.
Keyword
Drift
Lab Task B - Orientation Control
Task Description
The robot car must start at the designated line (<4m from the wall), drive fast forward, and when the robot is within 3ft (914mm = 3 floor tiles in the lab) from the wall, initiate a 180 degree turn.
Task Implementation
ToF Distance Bound & ToF Manually Tuning
From the previous labs, I found that there was some bias with my TOF sensor. Generally, there will be 20-30mm error. Also, considering the inertia which will cause the car hard to make the rotation with the position still, I set the distance bound for whether the car needs to drift as 1300mm:
Robot Car 180 Degree Turn
Once the car went cross the bound, the car would start to drift by setting the target_yaw to be 180 degrees more. And pass the error to the orientation PID control code block.
where I also set the yaw error tolerance bound as 1.5 degrees.
Kalman Filter after Drift
During the whole process, the robot car’s motion should be regarded as two phases - before and after drift. As for the kalman filter’s prediction, after the drift, we should reset it because during the drift, the orientation will have continuous sudden changes and the changes can be “discontinuous” changes for the sensor readings. I reset the kalman filter simply by resetting the tof_read_num as 0 to delay the kalman filter’s prediction. Also, reset the the previous readings and the sum parts for Derivative and Integral terms of the PID control.
Three Successful Stunts Demos
Here are three different successful demos for the drift stunts:
The yaw/yaw error & time is:
The PWM duty cycle:
The ToF distance reading with Kalman Filter:
Note The starting distance was quite far. The car speed would be fast, which will let the TOF get vague readings. So, our KF cannot work very well.
The PID values for position control:
The yaw/yaw error & time is:
The PWM duty cycle:
The ToF distance reading with Kalman Filter:
The PID values for position control:
The yaw/yaw error & time is:
The PWM duty cycle:
The ToF distance reading with Kalman Filter:
The PID values for position control:
Drift Stunt Finished