- PID Controllers
- Driving the car autonomously via Wall Following
A PID controller is a way to maintain certain parameters of a system around a specified set point. PID controllers are used in a variety of applications requiring closed-loop control, such as in the VESC speed controller on your car.
The general equation for a PID controller in the time domain, as discussed in lecture, is as follows:
Here,
In the context of our car, the desired distance to the wall should be our set point for our controller, which means our error is the difference between the desired and actual distance to the wall. This raises an important question: how do we measure the distance to the wall, and at what point in time? One option would simply be to consider the distance to the right wall at the current time
Figure 1: Distance and orientation of the car relative to the wall
Using the two distances
We can then express
to get the current distance between the car and the right wall. What's our error term
However, we have a problem on our hands. Remember that this is a race: your car will be traveling at a high speed and therefore will have a non-instantaneous response to whatever speed and servo control you give to it. If we simply use the current distance to the wall, we might end up turning too late, and the car may crash. Therefore, we must look to the future and project the car ahead by a certain lookahead distance (let's call it
Figure 2: Finding the future distance from the car to the wall
We're almost there. Our control algorithm gives us a steering angle for the VESC, but we would also like to slow the car down around corners for safety. We can compute the speed in a step-like fashion based on the steering angle, or equivalently the calculated error, so that as the angle exceeds progressively larger amounts, the speed is cut in discrete increments. For this lab, a good starting point for the speed control algorithm is:
- If the steering angle is between 0 degrees and 10 degrees, the car should drive at 1.5 meters per second.
- If the steering angle is between 10 degrees and 20 degrees, the speed should be 1.0 meters per second.
- Otherwise, the speed should be 0.5 meters per second.
So, in summary, here's what we need to do:
- Obtain two laser scans (distances) a and b.
- Use the distances a and b to calculate the angle
$\alpha$ between the car's$x$ -axis and the right wall. - Use
$\alpha$ to find the current distance$D_t$ to the car, and then$\alpha$ and$D_t$ to find the estimated future distance$D_{t+1}$ to the wall. - Run
$D_{t+1}$ through the PID algorithm described above to get a steering angle. - Use the steering angle you computed in the previous step to compute a safe driving speed.
- Publish the steering angle and driving speed to the
/drive
topic in simulation.
Implement wall following to make the car drive autonomously around the Levine Hall map. Follow the inner walls of Levine. Which means follow left if the car is going counter-clockwise in the loop. (The first race we run will be counter-clockwise). You can implement this node in either C++ or Python.
Deliverables 1 and 2 are to be done individually and Deliverable 3 in group as per your respective team allocation. Check your team allocation here : https://docs.google.com/spreadsheets/d/1Kx_6AzT0c4vWXpCim19qRhrQNDTCvQCWJ8yHXSqw4Uo/edit?usp=sharing .
Deliverable 1: After you're finished, update the entire skeleton package directory with your wall_follow
package and directly download the package, compress it in zip format and rename the zip file as lab3_<your last name>_<your team number>. Submit the renamed zip file directly to Canvas.
Deliverable 2: Make a screen cast of running your wall following node in the simulation. Include a link to the video on YouTube in SUBMISSION.md
.
Deliverable 3 (tentative, as a team): Make a recording of the run on the actual car following the wall anc completing a lap on a closed loop trajectory formed by flexible ducts.
- Compilation: 10 Points
- Implemented PID: 15 Points
- Tuned PID: 5 Points
- Video (Simulator + hardware): 15 Points