Low-level Controllers
This article details the low-level controllers that run on the Chronos RC car.
Documentation index — full table of contents.
Steer Controller¶
The cars run a low-level controller to track the reference steer angle \(\delta_r\), which is received from CRS.
The car uses a steer map to convert the feedback voltage from a potentiometer to an estimate of the current steer angle \(\delta\). A PID controller then tries to drive the error \(e = \delta_r - \delta\) to zero.
The low-level controller runs with \(T_s = 4\,\mathrm{ms}\). Let \(k_p, k_i, k_d\) be the PID gains and \(T_f\) be the filter time for the derivative term. The PID controller is given by (where \(\alpha = \exp(-T_s/T_f)\))
Tuning: The gains \(k_p, k_i, k_d\) can be adjusted in the configuration interface.
Note: Since the sample time is small, the derivative gain can be quite sensitive to noise. Keep the gain "small".
Throttle Controller¶
The reference throttle does not require a controller, as it is applied directly to the motor. An input in the range \([0, 1]\) is mapped to a PWM duty cycle in the range \([0\%, 100\%]\), which corresponds to a steady-state voltage of \([0\,\mathrm{V}, 5\,\mathrm{V}]\) on the throttle actuator.
Auto-coasting¶
Two motor driver chips manage the current on the actuators. They offer two different styles of PWM actuation: fast and slow decay. For a more linear response, slow decay is beneficial---during the off time of the PWM signal, the current decays more slowly. Fast decay has a less linear response but will improve coasting behavior of the motor.
The auto-coasting function of the car will automatically switch from the default (slow) decay to fast decay when the input is falling fast enough. In particular, it will coast whenever
The threshold \(\Delta_\text{thresh}\) is in units of [1] and adjustable in the configuration interface
Speed Controller¶
If the car is equipped with wheel encoders, another low-level controller can be used to track a reference longitudinal velocity \(v_{x,r}\). Here, the feedback is the measured longitudinal velocity from the rear wheel encoders, \(v_x = (\Omega_{rl} + \Omega_{rr}) / 2 \cdot r_w\). The controller is a simple PID, analogous to the steer controller.
Tuning: The gains \(k_p, k_i, k_d\) can be adjusted in the configuration interface.
When is the Speed Controller used?¶
The speed controller is used when CRS sends a reference velocity instead of a throttle value. This is controlled by setting either the throttle or velocity field in the /control_input message. The car will then use the throttle controller if throttle is set, and the speed controller if velocity is set.