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:

drift_distance_bound

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.

drift_code

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.

kf_after_drift

Three Successful Stunts Demos

Here are three different successful demos for the drift stunts:

First: Drift Stunt Demo1

The yaw/yaw error & time is:

demo1_yaw

demo1_yaw_err

The PWM duty cycle:

demo1_pwm

The ToF distance reading with Kalman Filter:

demo1_tof_kf

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:

demo1_pid

Second: Drift Stunt Demo2

The yaw/yaw error & time is:

demo2_yaw

demo2_yaw_err

The PWM duty cycle:

demo2_pwm

The ToF distance reading with Kalman Filter:

demo2_tof_kf

The PID values for position control:

demo2_pid

Third: Drift Stunt Demo3

The yaw/yaw error & time is:

demo3_yaw

demo3_yaw_err

The PWM duty cycle:

demo3_pwm

The ToF distance reading with Kalman Filter:

demo3_tof_kf

The PID values for position control:

demo3_pid

Drift Stunt Finished