Feedforward Feedback
The FF-FB controller (feed forward feed back) is also tracking the track center line as a reference. This time we make use of the fact that we have perfect knowledge of the track. The controller can be separated into a lateral and a longitudinal part.
Lateral Controller¶
The lateral controller consists of a feedforward and a feedback part. The feedback part is a PID controller that tracks the centerline as a reference. To react to curves early, it computes the distance to the centerline not at the current position of the car, but at a look ahead distance in front of the car.
The feedforward part computes the steering angle that makes the vehicle turn at the same curvature as the track centerline. To compute the respective steering angle it makes use of a model of the vehicle.
In the end, those two parts are added together to determine the steer command. This command can again be low pass filtered if desired.
Longitudinal Controller¶
Instead of just choosing a constant torque command like the PID controller, the FF-FB controller slows down the vehicle if it is approaching a turn. First, it computes the average track curvature in a fixed window ahead of the car. It then substracts a term that is proportional to this average curvature from the constant torque command that would make it converge to the desired steady state velocity.
Warning: The FF-FB 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 FF-FB 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 |
| look_ahead_distance | look ahead to compute lateral distance error for feedback PID controller |
| lag_compensation_time | compensate for time delay in feedforward controller |
| target_velocity | velocity that longitudinal controller pursues if there's no curve ahead |
| mean_curve_dist | distance to take curvature ahead of car into account for longitudinal controller |
| K_torque_curve | gain that is multiplied with the average track curvature ahead of the vehicle and then subtracted from the torque command |
state_type: pacejka_car
input_type: pacejka_car
controller_type: FF_FB
max_rate: 50
visualization_rate: 10
controller_params:
target_velocity: 2.0
use_filter: false
b_filter: [0.0985,0.2956,0.2956,0.0985]
a_filter: [1.0000,-0.5772,0.4218,-0.0563]
Kd: 0.01
Kp: 3.0
Ki: 0.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
K_torque_curv: 0.32
mean_curv_dist: 70 # in number of track indices
look_ahead_dist: 0.15
lag_compensation_time: 0.2
visualizer:
type: last_reference
rate: 10
# Visualizer specific parameters
frame_id: crs_frame # default
namespace: ff_fb # default
color_r: 1
color_g: 0
color_b: 0
color_a: 1
size_x: 0.05
size_y: 0.05
size_z: 0.05