Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
platooning_tactical_plugin::PlatooningTacticalPlugin Class Reference

Class containing primary business logic for the Platooning Tactical Plugin for trajectory generation. More...

#include <platooning_tactical_plugin.h>

Collaboration diagram for platooning_tactical_plugin::PlatooningTacticalPlugin:
Collaboration graph

Public Member Functions

 PlatooningTacticalPlugin (carma_wm::WorldModelConstPtr wm, PlatooningTacticalPluginConfig config, std::shared_ptr< carma_ros2_utils::timers::TimerFactory > timer_factory)
 Constructor. More...
 
bool plan_trajectory_cb (carma_planning_msgs::srv::PlanTrajectory::Request &req, carma_planning_msgs::srv::PlanTrajectory::Response &resp)
 Service callback for trajectory planning. More...
 
void set_config (PlatooningTacticalPluginConfig config)
 Set the current config. More...
 

Public Attributes

carma_planning_msgs::msg::VehicleState ending_state_before_buffer_
 

Private Attributes

carma_wm::WorldModelConstPtr wm_
 
PlatooningTacticalPluginConfig config_
 
carma_debug_ros2_msgs::msg::TrajectoryCurvatureSpeeds debug_msg_
 
DebugPublisher debug_publisher_
 
carma_planning_msgs::msg::VehicleState ending_state_before_buffer
 
std::shared_ptr< carma_ros2_utils::timers::TimerFactory > timer_factory_
 

Detailed Description

Class containing primary business logic for the Platooning Tactical Plugin for trajectory generation.

Definition at line 50 of file platooning_tactical_plugin.h.

Constructor & Destructor Documentation

◆ PlatooningTacticalPlugin()

platooning_tactical_plugin::PlatooningTacticalPlugin::PlatooningTacticalPlugin ( carma_wm::WorldModelConstPtr  wm,
PlatooningTacticalPluginConfig  config,
std::shared_ptr< carma_ros2_utils::timers::TimerFactory >  timer_factory 
)

Constructor.

Parameters
wmPointer to initalized instance of the carma world model for accessing semantic map data
configThe configuration to be used for this object

Definition at line 39 of file platooning_tactical_plugin.cpp.

41 : wm_(wm), config_(config), timer_factory_(timer_factory)
42{}
std::shared_ptr< carma_ros2_utils::timers::TimerFactory > timer_factory_

Member Function Documentation

◆ plan_trajectory_cb()

bool platooning_tactical_plugin::PlatooningTacticalPlugin::plan_trajectory_cb ( carma_planning_msgs::srv::PlanTrajectory::Request &  req,
carma_planning_msgs::srv::PlanTrajectory::Response &  resp 
)

Service callback for trajectory planning.

Parameters
reqThe service request
respThe service response
Returns
True if success. False otherwise

Definition at line 44 of file platooning_tactical_plugin.cpp.

46{
47 auto start_time = std::chrono::high_resolution_clock::now(); // Start timing the execution time for planning so it can be logged
48
49 lanelet::BasicPoint2d veh_pos(req.vehicle_state.x_pos_global, req.vehicle_state.y_pos_global);
50 double current_downtrack = wm_->routeTrackPos(veh_pos).downtrack;
51
52 // Only plan the trajectory for the initial LANE_FOLLOWING maneuver and any immediately sequential maneuvers of the same type
53 std::vector<carma_planning_msgs::msg::Maneuver> maneuver_plan;
54 for(size_t i = req.maneuver_index_to_plan; i < req.maneuver_plan.maneuvers.size(); i++)
55 {
56 if(req.maneuver_plan.maneuvers[i].type == carma_planning_msgs::msg::Maneuver::LANE_FOLLOWING)
57 {
58 if (req.maneuver_plan.maneuvers[i].lane_following_maneuver.parameters.negotiation_type != carma_planning_msgs::msg::ManeuverParameters::NO_NEGOTIATION)
59 {
60 maneuver_plan.push_back(req.maneuver_plan.maneuvers[i]);
61 resp.related_maneuvers.push_back(i);
62 }
63 }
64 else
65 {
66 break;
67 }
68 }
69
72
76
85
86 auto points_and_target_speeds = basic_autonomy::waypoint_generation::create_geometry_profile(maneuver_plan, std::max((double)0, current_downtrack - config_.back_distance),
87 wm_, ending_state_before_buffer_, req.vehicle_state, wpg_general_config, wpg_detail_config);
88
89 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("platooning_tactical_plugin"), "points_and_target_speeds: " << points_and_target_speeds.size());
90
91 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("platooning_tactical_plugin"), "PlanTrajectory");
92
93 carma_planning_msgs::msg::TrajectoryPlan original_trajectory;
94 original_trajectory.header.frame_id = "map";
95 original_trajectory.header.stamp = timer_factory_->now();
96 original_trajectory.trajectory_id = boost::uuids::to_string(boost::uuids::random_generator()());
97 original_trajectory.trajectory_points = basic_autonomy:: waypoint_generation::compose_lanefollow_trajectory_from_path(points_and_target_speeds,
98 req.vehicle_state, req.header.stamp, wm_, ending_state_before_buffer_, debug_msg_,
99 wpg_detail_config); // Compute the trajectory
100 original_trajectory.initial_longitudinal_velocity = std::max(req.vehicle_state.longitudinal_vel, config_.minimum_speed);
101
102 resp.trajectory_plan = original_trajectory;
103
104 if (config_.publish_debug) { // Publish the debug message if in debug logging mode
105 debug_msg_.trajectory_plan = resp.trajectory_plan;
107 }
108
109 resp.maneuver_status.push_back(carma_planning_msgs::srv::PlanTrajectory::Response::MANEUVER_IN_PROGRESS);
110
111 auto end_time = std::chrono::high_resolution_clock::now(); // Planning complete
112
113 auto nano_s = std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time);
114 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("platooning_tactical_plugin"), "ExecutionTime: " << ((double)nano_s.count() * 1e9));
115
116 return true;
117
118}
carma_planning_msgs::msg::VehicleState ending_state_before_buffer_
carma_debug_ros2_msgs::msg::TrajectoryCurvatureSpeeds debug_msg_
GeneralTrajConfig compose_general_trajectory_config(const std::string &trajectory_type, int default_downsample_ratio, int turn_downsample_ratio)
DetailedTrajConfig compose_detailed_trajectory_config(double trajectory_time_length, double curve_resample_step_size, double minimum_speed, double max_accel, double lateral_accel_limit, int speed_moving_average_window_size, int curvature_moving_average_window_size, double back_distance, double buffer_ending_downtrack, std::string desired_controller_plugin="default")
std::vector< PointSpeedPair > create_geometry_profile(const std::vector< carma_planning_msgs::msg::Maneuver > &maneuvers, double max_starting_downtrack, const carma_wm::WorldModelConstPtr &wm, carma_planning_msgs::msg::VehicleState &ending_state_before_buffer, const carma_planning_msgs::msg::VehicleState &state, const GeneralTrajConfig &general_config, const DetailedTrajConfig &detailed_config)
Creates geometry profile to return a point speed pair struct for LANE FOLLOW and LANE CHANGE maneuver...
std::vector< carma_planning_msgs::msg::TrajectoryPlanPoint > compose_lanefollow_trajectory_from_path(const std::vector< PointSpeedPair > &points, const carma_planning_msgs::msg::VehicleState &state, const rclcpp::Time &state_time, const carma_wm::WorldModelConstPtr &wm, const carma_planning_msgs::msg::VehicleState &ending_state_before_buffer, carma_debug_ros2_msgs::msg::TrajectoryCurvatureSpeeds &debug_msg, const DetailedTrajConfig &detailed_config)
Method converts a list of lanelet centerline points and current vehicle state into a usable list of t...
auto to_string(const UtmZone &zone) -> std::string
Definition: utm_zone.cpp:21

References PlatooningTacticalPluginConfig::back_distance, PlatooningTacticalPluginConfig::buffer_ending_downtrack, basic_autonomy::waypoint_generation::compose_detailed_trajectory_config(), basic_autonomy::waypoint_generation::compose_general_trajectory_config(), basic_autonomy::waypoint_generation::compose_lanefollow_trajectory_from_path(), config_, basic_autonomy::waypoint_generation::create_geometry_profile(), PlatooningTacticalPluginConfig::curvature_moving_average_window_size, PlatooningTacticalPluginConfig::curve_resample_step_size, debug_msg_, debug_publisher_, PlatooningTacticalPluginConfig::default_downsample_ratio, PlatooningTacticalPluginConfig::desired_controller_plugin, ending_state_before_buffer_, process_bag::i, PlatooningTacticalPluginConfig::lat_accel_multiplier, PlatooningTacticalPluginConfig::lateral_accel_limit, PlatooningTacticalPluginConfig::max_accel, PlatooningTacticalPluginConfig::max_accel_multiplier, PlatooningTacticalPluginConfig::minimum_speed, PlatooningTacticalPluginConfig::publish_debug, PlatooningTacticalPluginConfig::speed_moving_average_window_size, timer_factory_, carma_cooperative_perception::to_string(), PlatooningTacticalPluginConfig::trajectory_time_length, PlatooningTacticalPluginConfig::turn_downsample_ratio, and wm_.

Here is the call graph for this function:

◆ set_config()

void platooning_tactical_plugin::PlatooningTacticalPlugin::set_config ( PlatooningTacticalPluginConfig  config)

Set the current config.

Definition at line 120 of file platooning_tactical_plugin.cpp.

121{
122 config_ = config;
123}

References config_.

Member Data Documentation

◆ config_

PlatooningTacticalPluginConfig platooning_tactical_plugin::PlatooningTacticalPlugin::config_
private

Definition at line 82 of file platooning_tactical_plugin.h.

Referenced by plan_trajectory_cb(), and set_config().

◆ debug_msg_

carma_debug_ros2_msgs::msg::TrajectoryCurvatureSpeeds platooning_tactical_plugin::PlatooningTacticalPlugin::debug_msg_
private

Definition at line 84 of file platooning_tactical_plugin.h.

Referenced by plan_trajectory_cb().

◆ debug_publisher_

DebugPublisher platooning_tactical_plugin::PlatooningTacticalPlugin::debug_publisher_
private

Definition at line 85 of file platooning_tactical_plugin.h.

Referenced by plan_trajectory_cb().

◆ ending_state_before_buffer

carma_planning_msgs::msg::VehicleState platooning_tactical_plugin::PlatooningTacticalPlugin::ending_state_before_buffer
private

Definition at line 87 of file platooning_tactical_plugin.h.

◆ ending_state_before_buffer_

carma_planning_msgs::msg::VehicleState platooning_tactical_plugin::PlatooningTacticalPlugin::ending_state_before_buffer_

Definition at line 78 of file platooning_tactical_plugin.h.

Referenced by plan_trajectory_cb().

◆ timer_factory_

std::shared_ptr<carma_ros2_utils::timers::TimerFactory> platooning_tactical_plugin::PlatooningTacticalPlugin::timer_factory_
private

Definition at line 89 of file platooning_tactical_plugin.h.

Referenced by plan_trajectory_cb().

◆ wm_

carma_wm::WorldModelConstPtr platooning_tactical_plugin::PlatooningTacticalPlugin::wm_
private

Definition at line 81 of file platooning_tactical_plugin.h.

Referenced by plan_trajectory_cb().


The documentation for this class was generated from the following files: