CARLA
Loading...
Searching...
No Matches
Functions
carla::traffic_manager::PID Namespace Reference

Functions

float RelativeVelocityDeviation (const float reference_velocity, const float vehicle_speed, const float target_velocity)
 The target is exactly zero behind a stopped vehicle; the floor avoids a 0/0 NaN that the derivative term would turn into a NaN steering command.
 
ActuationSignal RunStep (StateEntry present_state, StateEntry previous_state, const std::vector< float > &longitudinal_parameters, const std::vector< float > &lateral_parameters, const float vehicle_speed, const float control_dt=DT, const float lateral_pursuit_steer=0.0f, const float lateral_damping_scale=1.0f, const float steer_authority_correction=1.0f)
 This function calculates the actuation signals based on the resent state change of the vehicle to minimize PID error.
 
float ShapeReferenceVelocity (const float previous_reference, const float vehicle_speed, const float target_velocity, const float control_dt, const bool emergency_stop)
 Reference speed that closes on target_velocity at COMFORT_ACCELERATION instead of stepping to it.
 
void SmoothActuation (const StateEntry &previous_state, const float control_dt, const float vehicle_speed, ActuationSignal &actuation_signal)
 A zero pedal demand bypasses the deadband, so pedals rest exactly at zero and nothing here delays a deceleration.
 

Function Documentation

◆ RelativeVelocityDeviation()

float carla::traffic_manager::PID::RelativeVelocityDeviation ( const float  reference_velocity,
const float  vehicle_speed,
const float  target_velocity 
)
inline

The target is exactly zero behind a stopped vehicle; the floor avoids a 0/0 NaN that the derivative term would turn into a NaN steering command.

Definition at line 50 of file trafficmanager/PIDController.h.

References carla::traffic_manager::constants::MotionPlan::EPSILON_RELATIVE_SPEED.

Referenced by carla::traffic_manager::MotionPlanStage::Update().

◆ RunStep()

ActuationSignal carla::traffic_manager::PID::RunStep ( StateEntry  present_state,
StateEntry  previous_state,
const std::vector< float > &  longitudinal_parameters,
const std::vector< float > &  lateral_parameters,
const float  vehicle_speed,
const float  control_dt = DT,
const float  lateral_pursuit_steer = 0.0f,
const float  lateral_damping_scale = 1.0f,
const float  steer_authority_correction = 1.0f 
)
inline

This function calculates the actuation signals based on the resent state change of the vehicle to minimize PID error.

control_dt is the measured simulation-time period between the two states. The gains are tuned at the nominal DT (sync-mode 0.05 s); in asynchronous mode the real period is one server frame, which under render load (e.g. a path-traced rt_lens sensor) stretches to 2-4x nominal. Left uncompensated that halves the loop's phase margin and the lateral PID goes from damped to divergent weaving (measured on Town12: steer_std 0.11 at 19 fps -> 0.71 with full-lock swings at 11 fps), which then trips the stuck/K-turn recovery into alternating full-lock "jerking". lateral_pursuit_steer replaces the linearized proportional term of the lateral loop: the caller computes the geometric pure-pursuit command atan(wheelbase * margin * 2 sin(alpha) / d) / wheel_lock from the vehicle's own steering geometry, which is exact for every wheelbase and lock where a fixed linear gain is only correct for the car-class fleet it was tuned on. The integral term keeps its original form and units. lateral_damping_scale rescales the derivative term with the loop bandwidth (pursuit-distance schedule x steering-authority correction). steer_authority_correction (>= 1) scales the STEER_LIMIT_GAIN envelope: the envelope is a physical curvature/lateral-acceleration guard, so it must cap curvature, not raw normalized command.

Definition at line 113 of file trafficmanager/PIDController.h.

References carla::traffic_manager::StateEntry::angular_deviation, carla::traffic_manager::constants::PID::MAX_BRAKE, carla::traffic_manager::constants::PID::MAX_CONTROL_DT, carla::traffic_manager::constants::PID::MAX_DEVIATION_RATE, carla::traffic_manager::constants::PID::MAX_STEERING, carla::traffic_manager::constants::PID::MAX_STEERING_RATE, carla::traffic_manager::constants::PID::MAX_THROTTLE, carla::traffic_manager::constants::PID::MIN_CONTROL_DT, carla::traffic_manager::StateEntry::steer, carla::traffic_manager::constants::PID::STEER_LIMIT_GAIN, and carla::traffic_manager::StateEntry::velocity_deviation.

Referenced by carla::traffic_manager::MotionPlanStage::Update().

◆ ShapeReferenceVelocity()

float carla::traffic_manager::PID::ShapeReferenceVelocity ( const float  previous_reference,
const float  vehicle_speed,
const float  target_velocity,
const float  control_dt,
const bool  emergency_stop 
)
inline

Reference speed that closes on target_velocity at COMFORT_ACCELERATION instead of stepping to it.

After an emergency stop the previous reference is meaningless, so it restarts from the vehicle speed.

Definition at line 29 of file trafficmanager/PIDController.h.

References carla::traffic_manager::constants::PID::COMFORT_ACCELERATION, carla::traffic_manager::constants::PID::MAX_CONTROL_DT, carla::traffic_manager::constants::PID::MIN_CONTROL_DT, and carla::traffic_manager::constants::PID::REFERENCE_LEAD_FRACTION.

Referenced by carla::traffic_manager::MotionPlanStage::Update().

◆ SmoothActuation()

void carla::traffic_manager::PID::SmoothActuation ( const StateEntry &  previous_state,
const float  control_dt,
const float  vehicle_speed,
ActuationSignal &  actuation_signal 
)
inline