26 double error = setpoint - pv;
27 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"PID error: " << error);
30 double Pout =
config_->kp * error;
31 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"Proportional term: " << Pout);
35 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"Integral term: " <<
_integral);
40 else if (_integral < config_->integrator_min){
44 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"Iout: " << Iout);
48 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"derivative term: " << derivative);
49 double Dout =
config_->kd * derivative;
50 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"Dout: " << Dout);
53 double output = Pout + Iout + Dout;
54 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"total controller output: " << output);
57 if( output >
config_->max_delta_speed_per_timestep )
58 output =
config_->max_delta_speed_per_timestep;
59 else if( output < config_->min_delta_speed_per_timestep )
60 output =
config_->min_delta_speed_per_timestep;
std::shared_ptr< PlatooningControlPluginConfig > config_
plugin config object
PIDController()
Constructor for the PID controller class.
double calculate(double setpoint, double pv)
function to calculate control command based on setpoint and process vale