49 double controllerOutput = 0.0;
53 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"The current leader position is " << leaderCurrentPosition);
55 double desiredHostPosition = leaderCurrentPosition -
desired_gap_;
56 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"desiredHostPosition = " << desiredHostPosition);
58 double hostVehiclePosition = leaderCurrentPosition -
actual_gap_;
59 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"hostVehiclePosition = " << hostVehiclePosition);
63 double adjSpeedCmd = controllerOutput + leader.
commandSpeed;
64 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"Adjusted Speed Cmd = " << adjSpeedCmd <<
"; Controller Output = " << controllerOutput
69 speed_cmd = adjSpeedCmd;
70 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"A speed command is generated from command generator: " << speed_cmd <<
" m/s");
76 }
else if(speed_cmd < leader.commandSpeed - ctrl_config_->adjustment_cap_mps) {
79 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"The adjusted cmd speed after max adjustment cap is " << speed_cmd <<
" m/s");
86 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"Host vehicle is the leader");
96 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"The adjusted leader cmd speed after max adjustment cap is " << speed_cmd <<
" m/s");
105 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"There is no leader available");
117 if(speed_cmd > max) {
119 }
else if (speed_cmd < min) {
123 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"platooning_control"),
"The speed command after max accel cap is: " << speed_cmd <<
" m/s");
This class includes logic for PID controller. PID controller is used in this plugin to maintain the i...
double calculate(double setpoint, double pv)
function to calculate control command based on setpoint and process vale
void set_leader(const PlatoonLeaderInfo &leader)
Sets the platoon leader object using info from msg.
void set_current_speed(double speed)
set current speed
double get_last_speed_command() const
Returns latest speed command.
PlatoonLeaderInfo platoon_leader
std::shared_ptr< PlatooningControlPluginConfig > ctrl_config_
PlatooningControlWorker()
Default constructor for platooning control worker.
void generate_speed(const carma_planning_msgs::msg::TrajectoryPlanPoint &point)
Generates speed commands (in m/s) based on the trajectory point.