Safety Filter
The MPC Safety Filter allows to use a possible unsafe controller within the CRS framework. It works by applying an input that is as close as possible to the provided reference input from the unsafe controller while still ensuring that the car will not leave the track.
In order to run the safety filter, make sure to create a file use_safety_filter:=true to the .launch file.
Configuration¶
Full Yaml Config Structure
safety_filter.yaml
state_type: pacejka_car
input_type: pacejka_car
safety_filter_type: mpc_filter
config:
solver_type: acados # solver that is used
reference_method: uniform # method that is used to generate reference trajectory (uniform or const_input)
dist_targ_multiplier: 3 # Multiplier that maps an applied torque to the expected driven distance
min_terminal_dist: 1 # Min distance the car must drive
max_terminal_dist: 5 # Max distance the car can drive
use_torque_filter: true # If true, make sure driving distance does only decrease by max dist_decrement_max in each iteration
dist_decrement_max: 0.01 # Max distence decrementin each iteration
loookahead_time: 0.1 # By how much the state should be advanced
threshold: 0.01 # Threshold. If the input norm was modified more than this threhsold, a visual hint is shown with the planned trajectory
# Cost
cost_torque: 0.08
cost_steer: 0.08
cost_delta_torque: 0
cost_delta_steer: 0
visualizer:
type: mpc
rate: 15
# Visualizer specific parameters
frame_id: crs_frame # default
namespace: mpc # 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
double_min_velocity: 1.5 # Min velocity for visualization (this or below gets mapped to blue)
double_max_velocity: 3 # Max velocity for visualization (this or above gets mapped to red)
planned:
size_x: 0.04 # 0.07 for arrows
size_y: 0.04 # 0.02 for arrows
size_z: 0.04 # 0.02 for arrows
reference:
r: 1
g: 0
b: 0
a: 1
size_x: 0.04 # 0.07 for arrows
size_y: 0.04 # 0.02 for arrows
size_z: 0.04 # 0.02 for arrows