Control
Control algorithms allow us to take desired actions and responses based on sensory input. One of the key challenges in robotics is accurately navigating and reacting to the environment. On this page, we'll explore three fundamental control algorithms used in robotics: PID Controller, Pure Pursuit Controller, and Stanley Controller.
PID Controller
The PID (Proportional-Integral-Derivative) controller is one of the most widely used feedback mechanisms in control systems and robotics. It operates based on the error, which is the difference between a desired setpoint and the actual output.
Equation
\(u(t) = K_p e(t) + K_i \int_{0}^{t} e(\tau) d\tau + K_d \frac{de(t)}{dt}\)
Where:
-
\(u(t)\) is the control input
-
\(e(t)\) is the error
-
\(K_p\) is the proportional gain, \(K_i\) is the integral gain, and \(K_d\) is the derivative gain
Components:
-
Proportional Control (P): This component produces an output value that's proportional to the current error. If the error has been large for an extended period of time, it will adjust the control output in proportion to that error.
-
Integral Control (I): This component concerns itself with the accumulation of past errors. If the error has been present for an extended period, it will accumulate (integral of the error).
-
Derivative Control (D): This predicts the future trend of the error, by determining its rate of change. It provides a control output to counteract the rate of error change.
Demo
The following Google Colab notebook demonstrates a simple PID controller implementation in Python. The controller is used to control the position and orientation of a point robot along a desired trajectory.
The following Google Colab notebook implements a PID controller for a F1TENTH car:
The following Google Colab notebook implements a PID controller for a differential drive Husky robot:
Pure Pursuit Controller
The Pure Pursuit controller is a path tracking algorithm. It is used for navigating a robot along a predetermined path.
Working Principle:
- It defines a lookahead distance from the robot.
- Finds the point on the path that's this distance ahead.
- Steers the robot to this point.
Key Features:
- The lookahead distance plays a crucial role. A smaller distance makes the robot more reactive, while a larger distance makes it more stable but less responsive to path changes.
Stanley Controller
Developed by Gabriel Hoffmann at Stanford for the DARPA Grand Challenge, the Stanley Controller is mainly used for autonomous vehicles to track paths. It combines cross-track error with heading error to compute the steering command.
Equation
\(\delta = \theta_e + \tan^{-1} \left( \frac{K_e e(t)}{v(t)} \right)\)
Where:
-
\(\delta\) is the steering angle
-
\(\theta_e\) is the heading error
-
\(K_e\) is the cross-track error gain
-
\(e(t)\) is the cross-track error
-
\(v(t)\) is the velocity