PID
The PID controller is the simplest controller available on CRS for cars. It is taking the centerline of the track as a reference trajectory. Since the centerline clearly is not an optimal racing line, its performance is heavily limited.
The PID computes its steering command by linearly combining the lateral distance to the centerline (proportional term), the change in lateral distance (derivative term) and the lateral distance summed over time (integral term). The control gains are the weights of this linear combination and can be tuned in the config file. In the end, the steering command can be low pass filtered to prevent wobbly steering commands.
At the same time, it is just applying a constant torque command which will make it converge to a desired steady state velocity.
To prevent it from reacting too late if the car is entering a turn, a look ahead time can be specified. This means that instead of the current lateral distance between the car and the centerline, a predicted look ahead distance will be computed to calculate the steering command.
The PID controller is completely independent of any model parameters.
Warning: The PID controller is using a steady state velocity as a torque command internally. However, CRS is now using a torque command between 0 and 1, which means that the PID controller needs to convert its torque internally before publishing the control input.
Tuning Parameters¶
| name | description |
|---|---|
| Kp | proportional gain |
| Kd | derivative gain |
| Ki | integral gain |
| target_velocity | target velocity |
| look_ahead_time | look ahead to detect curves early |
state_type: pacejka_car
input_type: pacejka_car
controller_type: PID
max_rate: 50
visualization_rate: 10
controller_params:
target_velocity: 2.6
look_ahead_time: 0.2
use_filter: false
b_filter: [0.0985,0.2956,0.2956,0.0985]
a_filter: [1.0000,-0.5772,0.4218,-0.0563]
Kd: 2.0
Kp: 5
Ki: 0
# crs uses a torque between 0 and 1. The kinematic model uses a different torque range internally.
# the conversion is done with the linear function torque_km = a * torque_crs + b
a_torque: 6.44026018
b_torque: 0.13732343
steer_limit: 0.4
visualizer:
rate: 10
type: last_reference
# Visualizer specific parameters
frame_id: crs_frame # default
namespace: pid # default
use_arrows: false # If true, use arrows to visualize planned and reference yaw angle. This option is a lot slower and may introduce visual lags
r: 1
g: 0
b: 0
a: 1
size_x: 0.05 # 0.07 for arrows
size_y: 0.05 # 0.02 for arrows
size_z: 0.05 # 0.02 for arrows