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.
intersection_transit_maneuvering::IntersectionTransitManeuveringNode Class Reference

ROS node for the inlanecruising_plugin. More...

#include <intersection_transit_maneuvering_node.hpp>

Inheritance diagram for intersection_transit_maneuvering::IntersectionTransitManeuveringNode:
Inheritance graph
Collaboration diagram for intersection_transit_maneuvering::IntersectionTransitManeuveringNode:
Collaboration graph

Public Member Functions

 IntersectionTransitManeuveringNode (const rclcpp::NodeOptions &)
 IntersectionTransitManeuveringNode constructor. More...
 
std::vector< carma_planning_msgs::msg::Maneuver > convert_maneuver_plan (const std::vector< carma_planning_msgs::msg::Maneuver > &maneuvers)
 Converts a sequence of INTERSECTION_TRANSIT maneuvers to LANE_FOLLOWING maneuvers. More...
 
void plan_trajectory_callback (std::shared_ptr< rmw_request_id_t >, carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr req, carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr resp) override
 Extending class provided callback which should return a planned trajectory based on the provided trajectory planning request. More...
 
bool get_availability () override
 Get the availability status of this plugin based on the current operating environment. Method must be overriden by extending classes. More...
 
std::string get_version_id () override
 Returns the version id of this plugin. More...
 
carma_ros2_utils::CallbackReturn on_configure_plugin () override
 This method should be used to load parameters and will be called on the configure state transition. More...
 
- Public Member Functions inherited from carma_guidance_plugins::TacticalPlugin
 TacticalPlugin (const rclcpp::NodeOptions &)
 TacticalPlugin constructor. More...
 
virtual ~TacticalPlugin ()=default
 Virtual destructor for safe deletion. More...
 
virtual void plan_trajectory_callback (std::shared_ptr< rmw_request_id_t > srv_header, carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr req, carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr resp)=0
 Extending class provided callback which should return a planned trajectory based on the provided trajectory planning request. More...
 
std::string get_capability () override
 Get the capability string representing this plugins capabilities Method must be overriden by extending classes. Expectation is that abstract plugin type parent classes will provide a default implementation. More...
 
uint8_t get_type () override final
 Returns the type of this plugin according to the carma_planning_msgs::Plugin type enum. Extending classes for the specific type should override this method. More...
 
carma_ros2_utils::CallbackReturn handle_on_configure (const rclcpp_lifecycle::State &) override final
 
carma_ros2_utils::CallbackReturn handle_on_activate (const rclcpp_lifecycle::State &) override final
 
carma_ros2_utils::CallbackReturn handle_on_deactivate (const rclcpp_lifecycle::State &) override final
 
carma_ros2_utils::CallbackReturn handle_on_cleanup (const rclcpp_lifecycle::State &) override final
 
carma_ros2_utils::CallbackReturn handle_on_shutdown (const rclcpp_lifecycle::State &) override final
 
carma_ros2_utils::CallbackReturn handle_on_error (const rclcpp_lifecycle::State &, const std::string &exception_string) override final
 
- Public Member Functions inherited from carma_guidance_plugins::PluginBaseNode
 PluginBaseNode (const rclcpp::NodeOptions &)
 PluginBaseNode constructor. More...
 
virtual ~PluginBaseNode ()=default
 Virtual destructor for safe deletion. More...
 
virtual std::shared_ptr< carma_wm::WMListenerget_world_model_listener () final
 Method to return the default world model listener provided as a convience by this base class If this method or get_world_model() are not called then the world model remains uninitialized and will not create unnecessary subscriptions. More...
 
virtual carma_wm::WorldModelConstPtr get_world_model () final
 Method to return the default world model provided as a convience by this base class If this method or get_world_model_listener() are not called then the world model remains uninitialized and will not create unnecessary subscriptions. More...
 
virtual bool get_activation_status () final
 Returns the activation status of this plugin. The plugins API callbacks will only be triggered when this method returns true. More...
 
virtual uint8_t get_type ()
 Returns the type of this plugin according to the carma_planning_msgs::Plugin type enum. Extending classes for the specific type should override this method. More...
 
std::string get_plugin_name_and_ns () const
 Return the name of this plugin with namespace. NOTE: If only the name of the plugin is required, use get_plugin_name() More...
 
std::string get_plugin_name () const
 Return the name of this plugin. More...
 
virtual bool get_availability ()=0
 Get the availability status of this plugin based on the current operating environment. Method must be overriden by extending classes. More...
 
virtual std::string get_capability ()=0
 Get the capability string representing this plugins capabilities Method must be overriden by extending classes. Expectation is that abstract plugin type parent classes will provide a default implementation. More...
 
virtual std::string get_version_id ()=0
 Returns the version id of this plugin. More...
 
virtual carma_ros2_utils::CallbackReturn on_configure_plugin ()=0
 Method which is triggered when this plugin is moved from the UNCONFIGURED to INACTIVE states. This method should be used to load parameters and is required to be implemented. More...
 
virtual carma_ros2_utils::CallbackReturn on_activate_plugin ()
 Method which is triggered when this plugin is moved from the INACTIVE to ACTIVE states. This method should be used to prepare for future callbacks for plugin's capabilites. More...
 
virtual carma_ros2_utils::CallbackReturn on_deactivate_plugin ()
 Method which is triggered when this plugin is moved from the ACTIVE to INACTIVE states. This method should be used to disable any functionality which should cease execution when plugin is inactive. More...
 
virtual carma_ros2_utils::CallbackReturn on_cleanup_plugin ()
 Method which is triggered when this plugin is moved from the INACTIVE to UNCONFIGURED states. This method should be used to fully reset the plugin such that a future call to on_configure_plugin would leave the plugin in a fresh state as though just launched. More...
 
virtual carma_ros2_utils::CallbackReturn on_shutdown_plugin ()
 Method which is triggered when this plugin is moved from any state to FINALIZED This method should be used to generate any shutdown logs or final cleanup. More...
 
virtual carma_ros2_utils::CallbackReturn on_error_plugin (const std::string &exception_string)
 Method which is triggered when an unhandled exception occurs in this plugin This method should be used to cleanup such that the plugin could be moved to UNCONFIGURED state if possible. More...
 
carma_ros2_utils::CallbackReturn handle_on_configure (const rclcpp_lifecycle::State &) override
 
carma_ros2_utils::CallbackReturn handle_on_activate (const rclcpp_lifecycle::State &) override
 
carma_ros2_utils::CallbackReturn handle_on_deactivate (const rclcpp_lifecycle::State &) override
 
carma_ros2_utils::CallbackReturn handle_on_cleanup (const rclcpp_lifecycle::State &) override
 
carma_ros2_utils::CallbackReturn handle_on_shutdown (const rclcpp_lifecycle::State &) override
 
carma_ros2_utils::CallbackReturn handle_on_error (const rclcpp_lifecycle::State &, const std::string &exception_string) override
 
 FRIEND_TEST (carma_guidance_plugins_test, connections_test)
 

Public Attributes

std::shared_ptr< CallInterfaceobject_
 
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > client_
 

Private Attributes

std::vector< carma_planning_msgs::msg::Maneuver > converted_maneuvers_
 
carma_planning_msgs::msg::VehicleState vehicle_state_
 

Detailed Description

ROS node for the inlanecruising_plugin.

Definition at line 33 of file intersection_transit_maneuvering_node.hpp.

Constructor & Destructor Documentation

◆ IntersectionTransitManeuveringNode()

intersection_transit_maneuvering::IntersectionTransitManeuveringNode::IntersectionTransitManeuveringNode ( const rclcpp::NodeOptions &  options)
explicit

IntersectionTransitManeuveringNode constructor.

Definition at line 133 of file intersection_transit_maneuvering.cpp.

TacticalPlugin base class which can be extended by user provided plugins which wish to implement the ...

Member Function Documentation

◆ convert_maneuver_plan()

std::vector< carma_planning_msgs::msg::Maneuver > intersection_transit_maneuvering::IntersectionTransitManeuveringNode::convert_maneuver_plan ( const std::vector< carma_planning_msgs::msg::Maneuver > &  maneuvers)

Converts a sequence of INTERSECTION_TRANSIT maneuvers to LANE_FOLLOWING maneuvers.

Parameters
maneuversThe list of maneuvers to convert
Returns
The new list of converted maneuvers

Definition at line 228 of file intersection_transit_maneuvering.cpp.

229 {
230 if (maneuvers.size() == 0)
231 {
232 throw std::invalid_argument("No maneuvers to convert");
233 }
234
235 std::vector<carma_planning_msgs::msg::Maneuver> new_maneuver_plan;
236 carma_planning_msgs::msg::Maneuver new_maneuver;
237 new_maneuver.type = carma_planning_msgs::msg::Maneuver::LANE_FOLLOWING; //All of the converted maneuvers will be of type LANE_FOLLOWING
238 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"Input Maneuver Type = "<< static_cast<int>(maneuvers.front().type));
239 for(const auto& maneuver : maneuvers)
240 {
241 //Throw exception if the manuever type does not match INTERSECTION_TRANSIT
242 if ( maneuver.type != carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_STRAIGHT &&
243 maneuver.type != carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_LEFT_TURN &&
244 maneuver.type != carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_RIGHT_TURN)
245 {
246 throw std::invalid_argument("Intersection transit maneuvering does not support this maneuver type");
247 }
248
249 //Convert IT Straight
250 if (maneuver.type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_STRAIGHT)
251 {
252 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"Converting INTERSECTION_TRANSIT_STRAIGHT");
253
254 new_maneuver.lane_following_maneuver.parameters.maneuver_id = maneuver.intersection_transit_straight_maneuver.parameters.maneuver_id;
255 new_maneuver.lane_following_maneuver.parameters.planning_strategic_plugin = maneuver.intersection_transit_straight_maneuver.parameters.planning_strategic_plugin;
256 new_maneuver.lane_following_maneuver.parameters.planning_tactical_plugin = maneuver.intersection_transit_straight_maneuver.parameters.planning_tactical_plugin;
257 new_maneuver.lane_following_maneuver.parameters.negotiation_type = maneuver.intersection_transit_straight_maneuver.parameters.negotiation_type;
258 new_maneuver.lane_following_maneuver.parameters.presence_vector = carma_planning_msgs::msg::ManeuverParameters::HAS_TACTICAL_PLUGIN;
259
260 new_maneuver.lane_following_maneuver.start_dist = maneuver.intersection_transit_straight_maneuver.start_dist;
261 new_maneuver.lane_following_maneuver.start_speed = maneuver.intersection_transit_straight_maneuver.start_speed;
262 new_maneuver.lane_following_maneuver.start_time = maneuver.intersection_transit_straight_maneuver.start_time;
263
264 new_maneuver.lane_following_maneuver.end_dist = maneuver.intersection_transit_straight_maneuver.end_dist;
265 new_maneuver.lane_following_maneuver.end_speed = maneuver.intersection_transit_straight_maneuver.end_speed;
266 new_maneuver.lane_following_maneuver.end_time = maneuver.intersection_transit_straight_maneuver.end_time;
267
268
269 new_maneuver.lane_following_maneuver.lane_ids = { maneuver.intersection_transit_straight_maneuver.starting_lane_id };
270
271 new_maneuver_plan.push_back(new_maneuver);
272 }
273
274 //Convert IT LEFT TURN
275 if (maneuver.type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_LEFT_TURN)
276 {
277 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"Converting INTERSECTION_TRANSIT_LEFT_TURN");
278
279 new_maneuver.lane_following_maneuver.parameters.maneuver_id = maneuver.intersection_transit_left_turn_maneuver.parameters.maneuver_id;
280 new_maneuver.lane_following_maneuver.parameters.planning_strategic_plugin = maneuver.intersection_transit_left_turn_maneuver.parameters.planning_strategic_plugin;
281 new_maneuver.lane_following_maneuver.parameters.planning_tactical_plugin = maneuver.intersection_transit_left_turn_maneuver.parameters.planning_tactical_plugin;
282 new_maneuver.lane_following_maneuver.parameters.negotiation_type = maneuver.intersection_transit_left_turn_maneuver.parameters.negotiation_type;
283 new_maneuver.lane_following_maneuver.parameters.presence_vector = carma_planning_msgs::msg::ManeuverParameters::HAS_TACTICAL_PLUGIN;
284
285 new_maneuver.lane_following_maneuver.start_dist = maneuver.intersection_transit_left_turn_maneuver.start_dist;
286 new_maneuver.lane_following_maneuver.start_speed = maneuver.intersection_transit_left_turn_maneuver.start_speed;
287 new_maneuver.lane_following_maneuver.start_time = maneuver.intersection_transit_left_turn_maneuver.start_time;
288
289 new_maneuver.lane_following_maneuver.end_dist = maneuver.intersection_transit_left_turn_maneuver.end_dist;
290 new_maneuver.lane_following_maneuver.end_speed = maneuver.intersection_transit_left_turn_maneuver.end_speed;
291 new_maneuver.lane_following_maneuver.end_time = maneuver.intersection_transit_left_turn_maneuver.end_time;
292
293 new_maneuver.lane_following_maneuver.lane_ids = { maneuver.intersection_transit_left_turn_maneuver.starting_lane_id };
294
295 new_maneuver_plan.push_back(new_maneuver);
296 }
297
298 //Convert IT RIGHT TURN
299 if (maneuver.type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_RIGHT_TURN)
300 {
301
302 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"Converting INTERSECTION_TRANSIT_RIGHT_TURN");
303
304 new_maneuver.lane_following_maneuver.parameters.maneuver_id = maneuver.intersection_transit_right_turn_maneuver.parameters.maneuver_id;
305 new_maneuver.lane_following_maneuver.parameters.planning_strategic_plugin = maneuver.intersection_transit_right_turn_maneuver.parameters.planning_strategic_plugin;
306 new_maneuver.lane_following_maneuver.parameters.planning_tactical_plugin = maneuver.intersection_transit_right_turn_maneuver.parameters.planning_tactical_plugin;
307 new_maneuver.lane_following_maneuver.parameters.negotiation_type = maneuver.intersection_transit_right_turn_maneuver.parameters.negotiation_type;
308 new_maneuver.lane_following_maneuver.parameters.presence_vector = carma_planning_msgs::msg::ManeuverParameters::HAS_TACTICAL_PLUGIN;
309
310 new_maneuver.lane_following_maneuver.start_dist = maneuver.intersection_transit_right_turn_maneuver.start_dist;
311 new_maneuver.lane_following_maneuver.start_speed = maneuver.intersection_transit_right_turn_maneuver.start_speed;
312 new_maneuver.lane_following_maneuver.start_time = maneuver.intersection_transit_right_turn_maneuver.start_time;
313
314 new_maneuver.lane_following_maneuver.end_dist = maneuver.intersection_transit_right_turn_maneuver.end_dist;
315 new_maneuver.lane_following_maneuver.end_speed = maneuver.intersection_transit_right_turn_maneuver.end_speed;
316 new_maneuver.lane_following_maneuver.end_time = maneuver.intersection_transit_right_turn_maneuver.end_time;
317
318 new_maneuver.lane_following_maneuver.lane_ids = { maneuver.intersection_transit_right_turn_maneuver.starting_lane_id };
319
320 new_maneuver_plan.push_back(new_maneuver);
321 }
322
323 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"Original Maneuver : " << maneuver << std::endl << "Converted Maneuver: " << new_maneuver);
324
325 }//end for-loop
326
327 return new_maneuver_plan;
328
329 }

Referenced by plan_trajectory_callback().

Here is the caller graph for this function:

◆ get_availability()

bool intersection_transit_maneuvering::IntersectionTransitManeuveringNode::get_availability ( )
overridevirtual

Get the availability status of this plugin based on the current operating environment. Method must be overriden by extending classes.

Returns
This method should return true if the plugin's current understanding of the world means it would be capable of planning or executing its capability.

Implements carma_guidance_plugins::PluginBaseNode.

Definition at line 151 of file intersection_transit_maneuvering.cpp.

151 {
152 return true;
153 }

◆ get_version_id()

std::string intersection_transit_maneuvering::IntersectionTransitManeuveringNode::get_version_id ( )
overridevirtual

Returns the version id of this plugin.

Returns
The version id represented as a string

Implements carma_guidance_plugins::PluginBaseNode.

Definition at line 155 of file intersection_transit_maneuvering.cpp.

155 {
156 return "v4.0"; // Version ID matches the value set in this package's package.xml
157 }

◆ on_configure_plugin()

carma_ros2_utils::CallbackReturn intersection_transit_maneuvering::IntersectionTransitManeuveringNode::on_configure_plugin ( )
overridevirtual

This method should be used to load parameters and will be called on the configure state transition.

Implements carma_guidance_plugins::PluginBaseNode.

Definition at line 136 of file intersection_transit_maneuvering.cpp.

137{
138 RCLCPP_INFO_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"), "IntersectionTransitManeuveringNode trying to configure");
139
140 object_ = std::make_shared<intersection_transit_maneuvering::Servicer>();
141
142 client_ = create_client<carma_planning_msgs::srv::PlanTrajectory>("inlanecruising_plugin/plan_trajectory");
143
144 object_->set_client(client_);
145
146 //Return success if everthing initialized successfully
147return CallbackReturn::SUCCESS;
148
149}
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > client_

References client_, and object_.

◆ plan_trajectory_callback()

void intersection_transit_maneuvering::IntersectionTransitManeuveringNode::plan_trajectory_callback ( std::shared_ptr< rmw_request_id_t >  srv_header,
carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr  req,
carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr  resp 
)
overridevirtual

Extending class provided callback which should return a planned trajectory based on the provided trajectory planning request.

Parameters
srv_headerRCL header for services calls. Can usually be ignored by implementers.
reqThe service request containing the maneuvers to plan trajectories for and current vehicle state
respThe response containing the planned trajectory

Implements carma_guidance_plugins::TacticalPlugin.

Definition at line 160 of file intersection_transit_maneuvering.cpp.

164 {
165
166 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
167
168 std::vector<carma_planning_msgs::msg::Maneuver> maneuver_plan;
169
170 auto related_maneuvers = resp->related_maneuvers;
171
172 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"Starting planning for maneuver index: " << req->maneuver_index_to_plan);
173 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"req->maneuver_plan.maneuvers.size(): " << req->maneuver_plan.maneuvers.size());
174
175 for(size_t i = req->maneuver_index_to_plan; i < req->maneuver_plan.maneuvers.size(); i++)
176 {
177 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"Looping");
178 if(req->maneuver_plan.maneuvers[i].type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_STRAIGHT ||
179 req->maneuver_plan.maneuvers[i].type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_LEFT_TURN ||
180 req->maneuver_plan.maneuvers[i].type == carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_RIGHT_TURN )
181 {
182 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"Found valid maneuver for planning at index: " << i);
183 maneuver_plan.push_back(req->maneuver_plan.maneuvers[i]);
184 related_maneuvers.push_back(i);
185 }
186 else
187 {
188 break;
189 }
190 }
191
193 auto new_req = std::make_shared<carma_planning_msgs::srv::PlanTrajectory::Request> ();
194
195 for(auto i : converted_maneuvers_)
196 {
197 new_req->maneuver_plan.maneuvers.push_back(i);
198 }
199
200 new_req->header = req->header;
201 new_req->vehicle_state = req->vehicle_state;
202 new_req->initial_trajectory_plan = req->initial_trajectory_plan;
203 carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr ilc_resp = std::make_shared<carma_planning_msgs::srv::PlanTrajectory::Response>();
204 object_->call(new_req,ilc_resp);
205
206 if(ilc_resp->trajectory_plan.trajectory_points.empty())//Since we're using an interface for this process, the call() functionality will come from somewhere else
207 {
208 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"Failed to call service");
209 return ;
210 } else {
211 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"Call Successful");
212 resp->trajectory_plan = ilc_resp->trajectory_plan;
213 }
214
215
216 resp->related_maneuvers = related_maneuvers; // Set the related maneuvers using the origional maneuver indexs not those sent to inlane-cruising
217 for (auto maneuver : related_maneuvers) {
218 resp->maneuver_status.push_back(carma_planning_msgs::srv::PlanTrajectory::Response::MANEUVER_IN_PROGRESS);
219 }
220
221 std::chrono::system_clock::time_point end_time = std::chrono::system_clock::now(); // Start timing the execution time for planning so it can be logged
222
223 auto duration = end_time - start_time;
224 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"),"ExecutionTime: " << std::chrono::duration<double>(duration).count());
225 return ;
226 }
std::vector< carma_planning_msgs::msg::Maneuver > convert_maneuver_plan(const std::vector< carma_planning_msgs::msg::Maneuver > &maneuvers)
Converts a sequence of INTERSECTION_TRANSIT maneuvers to LANE_FOLLOWING maneuvers.

References convert_maneuver_plan(), converted_maneuvers_, process_bag::i, and object_.

Here is the call graph for this function:

Member Data Documentation

◆ client_

carma_ros2_utils::ClientPtr<carma_planning_msgs::srv::PlanTrajectory> intersection_transit_maneuvering::IntersectionTransitManeuveringNode::client_

Definition at line 44 of file intersection_transit_maneuvering_node.hpp.

Referenced by on_configure_plugin().

◆ converted_maneuvers_

std::vector<carma_planning_msgs::msg::Maneuver> intersection_transit_maneuvering::IntersectionTransitManeuveringNode::converted_maneuvers_
private

Definition at line 39 of file intersection_transit_maneuvering_node.hpp.

Referenced by plan_trajectory_callback().

◆ object_

std::shared_ptr<CallInterface> intersection_transit_maneuvering::IntersectionTransitManeuveringNode::object_

◆ vehicle_state_

carma_planning_msgs::msg::VehicleState intersection_transit_maneuvering::IntersectionTransitManeuveringNode::vehicle_state_
private

Definition at line 40 of file intersection_transit_maneuvering_node.hpp.


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