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.
inlanecruising_plugin::InLaneCruisingPlugin Class Reference

Class containing primary business logic for the In-Lane Cruising Plugin. More...

#include <inlanecruising_plugin.hpp>

Collaboration diagram for inlanecruising_plugin::InLaneCruisingPlugin:
Collaboration graph

Public Member Functions

 InLaneCruisingPlugin (std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > nh, carma_wm::WorldModelConstPtr wm, const InLaneCruisingPluginConfig &config, const DebugPublisher &debug_publisher=[](const auto &msg){}, const std::string &plugin_name="inlanecruising_plugin", const std::string &version_id="v1.0")
 Constructor. More...
 
void plan_trajectory_callback (carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr req, carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr resp)
 Service callback for trajectory planning. More...
 
void set_yield_client (carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > client)
 set the yield service More...
 

Public Attributes

carma_planning_msgs::msg::VehicleState ending_state_before_buffer_
 

Private Member Functions

 FRIEND_TEST (InLaneCruisingPluginTest, rostest1)
 

Private Attributes

std::string plugin_name_
 
std::string version_id_
 
carma_wm::WorldModelConstPtr wm_
 
InLaneCruisingPluginConfig config_
 
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > yield_client_
 
DebugPublisher debug_publisher_
 
carma_debug_ros2_msgs::msg::TrajectoryCurvatureSpeeds debug_msg_
 
std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > nh_
 

Detailed Description

Class containing primary business logic for the In-Lane Cruising Plugin.

Definition at line 50 of file inlanecruising_plugin.hpp.

Constructor & Destructor Documentation

◆ InLaneCruisingPlugin()

inlanecruising_plugin::InLaneCruisingPlugin::InLaneCruisingPlugin ( std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode >  nh,
carma_wm::WorldModelConstPtr  wm,
const InLaneCruisingPluginConfig config,
const DebugPublisher debug_publisher = [](const auto& msg){},
const std::string &  plugin_name = "inlanecruising_plugin",
const std::string &  version_id = "v1.0" 
)

Constructor.

Parameters
nhPointer to the lifecyle node
wmPointer to intialized instance of the carma world model for accessing semantic map data
configThe configuration to be used for this object
debug_publisherCallback which will publish a debug message. The callback defaults to no-op.
plugin_nameRetrieved from the plugin node
version_idRetrieved from the plugin node

Definition at line 40 of file inlanecruising_plugin.cpp.

Member Function Documentation

◆ FRIEND_TEST()

inlanecruising_plugin::InLaneCruisingPlugin::FRIEND_TEST ( InLaneCruisingPluginTest  ,
rostest1   
)
private

◆ plan_trajectory_callback()

void inlanecruising_plugin::InLaneCruisingPlugin::plan_trajectory_callback ( carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr  req,
carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr  resp 
)

Service callback for trajectory planning.

Parameters
srv_headerheader
reqThe service request
respThe service response

Definition at line 49 of file inlanecruising_plugin.cpp.

52{
53 std::chrono::system_clock::time_point start_time = std::chrono::system_clock::now(); // Start timing the execution time for planning so it can be logged
54
55 lanelet::BasicPoint2d veh_pos(req->vehicle_state.x_pos_global, req->vehicle_state.y_pos_global);
56 double current_downtrack = wm_->routeTrackPos(veh_pos).downtrack;
57
58 // Only plan the trajectory for the initial LANE_FOLLOWING maneuver and any immediately sequential maneuvers of the same type
59 std::vector<carma_planning_msgs::msg::Maneuver> maneuver_plan;
60 for(size_t i = req->maneuver_index_to_plan; i < req->maneuver_plan.maneuvers.size(); i++)
61 {
62 if(req->maneuver_plan.maneuvers[i].type == carma_planning_msgs::msg::Maneuver::LANE_FOLLOWING)
63 {
64 maneuver_plan.push_back(req->maneuver_plan.maneuvers[i]);
65 resp->related_maneuvers.push_back((uint8_t)i);
66 }
67 else
68 {
69 break;
70 }
71 }
72
75
79
87
88 auto points_and_target_speeds = basic_autonomy::waypoint_generation::create_geometry_profile(maneuver_plan, std::max((double)0, current_downtrack - config_.back_distance),
89 wm_, ending_state_before_buffer_, req->vehicle_state, wpg_general_config, wpg_detail_config);
90
91 RCLCPP_DEBUG_STREAM(nh_->get_logger(), "points_and_target_speeds: " << points_and_target_speeds.size());
92
93 RCLCPP_DEBUG_STREAM(nh_->get_logger(), "PlanTrajectory");
94
95 carma_planning_msgs::msg::TrajectoryPlan original_trajectory;
96 original_trajectory.header.frame_id = "map";
97 original_trajectory.header.stamp = nh_->now();
98 original_trajectory.trajectory_id = boost::uuids::to_string(boost::uuids::random_generator()());
99
100 original_trajectory.trajectory_points = basic_autonomy:: waypoint_generation::compose_lanefollow_trajectory_from_path(points_and_target_speeds,
101 req->vehicle_state, req->header.stamp, wm_, ending_state_before_buffer_, debug_msg_,
102 wpg_detail_config); // Compute the trajectory
103 original_trajectory.initial_longitudinal_velocity = std::max(req->vehicle_state.longitudinal_vel, config_.minimum_speed);
104
105 // Set the planning plugin field name
106 for (auto& p : original_trajectory.trajectory_points) {
107 p.planner_plugin_name = plugin_name_;
108 }
109
110 resp->trajectory_plan = original_trajectory;
111
112 // Aside from the flag, ILC should not call yield_plugin on invalid trajectories
113 if (config_.enable_object_avoidance && original_trajectory.trajectory_points.size() >= 2)
114 {
116 }
117 else
118 {
119 RCLCPP_DEBUG(nh_->get_logger(), "Ignored Object Avoidance");
120 }
121
122 if (config_.publish_debug) { // Publish the debug message if in debug logging mode
123 debug_msg_.trajectory_plan = resp->trajectory_plan;
125 }
126
127 resp->maneuver_status.push_back(carma_planning_msgs::srv::PlanTrajectory::Response::MANEUVER_IN_PROGRESS);
128
129 std::chrono::system_clock::time_point end_time = std::chrono::system_clock::now(); // Planning complete
130
131 auto duration = end_time - start_time;
132 RCLCPP_DEBUG_STREAM(nh_->get_logger(), "ExecutionTime: " << std::chrono::duration<double>(duration).count());
133}
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > yield_client_
carma_debug_ros2_msgs::msg::TrajectoryCurvatureSpeeds debug_msg_
carma_planning_msgs::msg::VehicleState ending_state_before_buffer_
GeneralTrajConfig compose_general_trajectory_config(const std::string &trajectory_type, int default_downsample_ratio, int turn_downsample_ratio)
carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr modify_trajectory_to_yield_to_obstacles(const std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > &node_handler, const carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr &req, const carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr &resp, const carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > &yield_client, int yield_plugin_service_call_timeout)
Applies a yield trajectory to the original trajectory set in response.
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 InLaneCruisingPluginConfig::back_distance, InLaneCruisingPluginConfig::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(), InLaneCruisingPluginConfig::curvature_moving_average_window_size, InLaneCruisingPluginConfig::curve_resample_step_size, debug_msg_, debug_publisher_, InLaneCruisingPluginConfig::default_downsample_ratio, InLaneCruisingPluginConfig::enable_object_avoidance, ending_state_before_buffer_, process_bag::i, InLaneCruisingPluginConfig::lat_accel_multiplier, InLaneCruisingPluginConfig::lateral_accel_limit, InLaneCruisingPluginConfig::max_accel, InLaneCruisingPluginConfig::max_accel_multiplier, InLaneCruisingPluginConfig::minimum_speed, basic_autonomy::waypoint_generation::modify_trajectory_to_yield_to_obstacles(), nh_, plugin_name_, InLaneCruisingPluginConfig::publish_debug, InLaneCruisingPluginConfig::speed_moving_average_window_size, InLaneCruisingPluginConfig::tactical_plugin_service_call_timeout, carma_cooperative_perception::to_string(), InLaneCruisingPluginConfig::trajectory_time_length, InLaneCruisingPluginConfig::turn_downsample_ratio, wm_, and yield_client_.

Here is the call graph for this function:

◆ set_yield_client()

void inlanecruising_plugin::InLaneCruisingPlugin::set_yield_client ( carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory >  client)

set the yield service

Parameters
yield_srvinput yield service

Definition at line 135 of file inlanecruising_plugin.cpp.

136{
137 yield_client_ = client;
138}

References yield_client_.

Member Data Documentation

◆ config_

InLaneCruisingPluginConfig inlanecruising_plugin::InLaneCruisingPlugin::config_
private

Definition at line 94 of file inlanecruising_plugin.hpp.

Referenced by plan_trajectory_callback().

◆ debug_msg_

carma_debug_ros2_msgs::msg::TrajectoryCurvatureSpeeds inlanecruising_plugin::InLaneCruisingPlugin::debug_msg_
private

Definition at line 97 of file inlanecruising_plugin.hpp.

Referenced by plan_trajectory_callback().

◆ debug_publisher_

DebugPublisher inlanecruising_plugin::InLaneCruisingPlugin::debug_publisher_
private

Definition at line 96 of file inlanecruising_plugin.hpp.

Referenced by plan_trajectory_callback().

◆ ending_state_before_buffer_

carma_planning_msgs::msg::VehicleState inlanecruising_plugin::InLaneCruisingPlugin::ending_state_before_buffer_

Definition at line 87 of file inlanecruising_plugin.hpp.

Referenced by plan_trajectory_callback().

◆ nh_

std::shared_ptr<carma_ros2_utils::CarmaLifecycleNode> inlanecruising_plugin::InLaneCruisingPlugin::nh_
private

Definition at line 98 of file inlanecruising_plugin.hpp.

Referenced by plan_trajectory_callback().

◆ plugin_name_

std::string inlanecruising_plugin::InLaneCruisingPlugin::plugin_name_
private

Definition at line 91 of file inlanecruising_plugin.hpp.

Referenced by plan_trajectory_callback().

◆ version_id_

std::string inlanecruising_plugin::InLaneCruisingPlugin::version_id_
private

Definition at line 92 of file inlanecruising_plugin.hpp.

◆ wm_

carma_wm::WorldModelConstPtr inlanecruising_plugin::InLaneCruisingPlugin::wm_
private

Definition at line 93 of file inlanecruising_plugin.hpp.

Referenced by plan_trajectory_callback().

◆ yield_client_

carma_ros2_utils::ClientPtr<carma_planning_msgs::srv::PlanTrajectory> inlanecruising_plugin::InLaneCruisingPlugin::yield_client_
private

Definition at line 95 of file inlanecruising_plugin.hpp.

Referenced by plan_trajectory_callback(), and set_yield_client().


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