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.
stop_and_wait_plugin::StopandWaitNode Class Reference

#include <stop_and_wait_node.hpp>

Inheritance diagram for stop_and_wait_plugin::StopandWaitNode:
Inheritance graph
Collaboration diagram for stop_and_wait_plugin::StopandWaitNode:
Collaboration graph

Public Member Functions

 StopandWaitNode (const rclcpp::NodeOptions &)
 Node constructor. More...
 
carma_ros2_utils::CallbackReturn on_configure_plugin ()
 This method should be used to load parameters and will be called on the configure state transition. More...
 
rcl_interfaces::msg::SetParametersResult parameter_update_callback (const std::vector< rclcpp::Parameter > &parameters)
 Callback for dynamic parameter updates. More...
 
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) 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 final
 Returns the version id of this plugin. 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)
 

Private Attributes

StopandWaitConfig config_
 
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > yield_client_
 
std::shared_ptr< StopandWaitplugin_
 
std::string version_id_
 
std::string plugin_name_
 

Detailed Description

Definition at line 51 of file stop_and_wait_node.hpp.

Constructor & Destructor Documentation

◆ StopandWaitNode()

stop_and_wait_plugin::StopandWaitNode::StopandWaitNode ( const rclcpp::NodeOptions &  options)
explicit

Node constructor.

Definition at line 23 of file stop_and_wait_plugin_node.cpp.

25 {
26 // Create initial config
28
29 // Declare parameters
30 config_.minimal_trajectory_duration = declare_parameter<double>("minimal_trajectory_duration", config_.minimal_trajectory_duration);
31 config_.stop_timestep = declare_parameter<double>("stop_timestep", config_.stop_timestep);
32 config_.trajectory_step_size = declare_parameter<double>("trajectory_step_size", config_.trajectory_step_size);
33 config_.accel_limit_multiplier = declare_parameter<double>("accel_limit_multiplier", config_.accel_limit_multiplier);
34 config_.accel_limit = declare_parameter<double>("vehicle_acceleration_limit", config_.accel_limit);
35 config_.crawl_speed = declare_parameter<double>("crawl_speed", config_.crawl_speed);
36 config_.centerline_sampling_spacing = declare_parameter<double>("centerline_sampling_spacing", config_.centerline_sampling_spacing);
37 config_.default_stopping_buffer = declare_parameter<double>("default_stopping_buffer", config_.default_stopping_buffer);
38 config_.tactical_plugin_service_call_timeout = declare_parameter<int>("tactical_plugin_service_call_timeout", config_.tactical_plugin_service_call_timeout);
39 config_.enable_object_avoidance = declare_parameter<bool>("enable_object_avoidance", config_.enable_object_avoidance);
40
41 }
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,...
TacticalPlugin base class which can be extended by user provided plugins which wish to implement the ...
Stuct containing the algorithm configuration values for the stop_and_wait_plugin.

References StopandWaitConfig::accel_limit, StopandWaitConfig::accel_limit_multiplier, StopandWaitConfig::centerline_sampling_spacing, config_, StopandWaitConfig::crawl_speed, StopandWaitConfig::default_stopping_buffer, StopandWaitConfig::enable_object_avoidance, StopandWaitConfig::minimal_trajectory_duration, StopandWaitConfig::stop_timestep, StopandWaitConfig::tactical_plugin_service_call_timeout, and StopandWaitConfig::trajectory_step_size.

Member Function Documentation

◆ get_availability()

bool stop_and_wait_plugin::StopandWaitNode::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 100 of file stop_and_wait_plugin_node.cpp.

101 {
102 return true;
103 }

◆ get_version_id()

std::string stop_and_wait_plugin::StopandWaitNode::get_version_id ( )
finaloverridevirtual

Returns the version id of this plugin.

Returns
The version id represented as a string

Implements carma_guidance_plugins::PluginBaseNode.

Definition at line 105 of file stop_and_wait_plugin_node.cpp.

106 {
107 return version_id_;
108 }

References version_id_.

◆ on_configure_plugin()

carma_ros2_utils::CallbackReturn stop_and_wait_plugin::StopandWaitNode::on_configure_plugin ( )
virtual

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 63 of file stop_and_wait_plugin_node.cpp.

64 {
65
66 get_parameter<double>("minimal_trajectory_duration", config_.minimal_trajectory_duration);
67 get_parameter<double>("stop_timestep", config_.stop_timestep);
68 get_parameter<double>("trajectory_step_size", config_.trajectory_step_size);
69 get_parameter<double>("accel_limit_multiplier", config_.accel_limit_multiplier);
70 get_parameter<double>("vehicle_acceleration_limit", config_.accel_limit);
71 get_parameter<double>("crawl_speed", config_.crawl_speed);
72 get_parameter<double>("centerline_sampling_spacing", config_.centerline_sampling_spacing);
73 get_parameter<double>("default_stopping_buffer", config_.default_stopping_buffer);
74 get_parameter<int>("tactical_plugin_service_call_timeout", config_.tactical_plugin_service_call_timeout);
75 get_parameter<bool>("enable_object_avoidance", config_.enable_object_avoidance);
76
77 RCLCPP_INFO_STREAM(rclcpp::get_logger("stop_and_wait_plugin"),"Done loading parameters: " << config_);
78
79 // Register runtime parameter update callback
80 add_on_set_parameters_callback(std::bind(&StopandWaitNode::parameter_update_callback, this, std_ph::_1));
81
82 plugin_ = std::make_shared<StopandWait>(shared_from_this(), get_world_model(), config_,plugin_name_,version_id_);
83
84 yield_client_ = create_client<carma_planning_msgs::srv::PlanTrajectory>("yield_plugin/plan_trajectory");
85 plugin_->set_yield_client(yield_client_);
86 RCLCPP_INFO(rclcpp::get_logger("stop_and_wait_plugin"), "Yield Client Set");
87
88 // Return success if everything initialized successfully
89 return CallbackReturn::SUCCESS;
90 }
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...
std::shared_ptr< StopandWait > plugin_
rcl_interfaces::msg::SetParametersResult parameter_update_callback(const std::vector< rclcpp::Parameter > &parameters)
Callback for dynamic parameter updates.
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > yield_client_

References StopandWaitConfig::accel_limit, StopandWaitConfig::accel_limit_multiplier, StopandWaitConfig::centerline_sampling_spacing, config_, StopandWaitConfig::crawl_speed, StopandWaitConfig::default_stopping_buffer, StopandWaitConfig::enable_object_avoidance, carma_guidance_plugins::PluginBaseNode::get_world_model(), StopandWaitConfig::minimal_trajectory_duration, parameter_update_callback(), plugin_, plugin_name_, StopandWaitConfig::stop_timestep, StopandWaitConfig::tactical_plugin_service_call_timeout, StopandWaitConfig::trajectory_step_size, version_id_, and yield_client_.

Here is the call graph for this function:

◆ parameter_update_callback()

rcl_interfaces::msg::SetParametersResult stop_and_wait_plugin::StopandWaitNode::parameter_update_callback ( const std::vector< rclcpp::Parameter > &  parameters)

Callback for dynamic parameter updates.

Definition at line 43 of file stop_and_wait_plugin_node.cpp.

44 {
45
46 auto error = update_params<double>({
47 {"minimal_trajectory_duration", config_.minimal_trajectory_duration},
48 {"stop_timestep", config_.stop_timestep},
49 {"trajectory_step_size", config_.trajectory_step_size},
50 {"accel_limit_multiplier", config_.accel_limit_multiplier},
51 {"crawl_speed", config_.crawl_speed},
52 {"centerline_sampling_spacing", config_.centerline_sampling_spacing},
53 {"default_stopping_buffer", config_.default_stopping_buffer}
54 }, parameters); // vehicle_acceleration_limit not updated as it's global param
55
56 rcl_interfaces::msg::SetParametersResult result;
57
58 result.successful = !error;
59
60 return result;
61 }

References StopandWaitConfig::accel_limit_multiplier, StopandWaitConfig::centerline_sampling_spacing, config_, StopandWaitConfig::crawl_speed, StopandWaitConfig::default_stopping_buffer, StopandWaitConfig::minimal_trajectory_duration, StopandWaitConfig::stop_timestep, and StopandWaitConfig::trajectory_step_size.

Referenced by on_configure_plugin().

Here is the caller graph for this function:

◆ plan_trajectory_callback()

void stop_and_wait_plugin::StopandWaitNode::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 92 of file stop_and_wait_plugin_node.cpp.

96 {
97 plugin_->plan_trajectory_cb(req, resp);
98 }

References plugin_.

Member Data Documentation

◆ config_

StopandWaitConfig stop_and_wait_plugin::StopandWaitNode::config_
private

◆ plugin_

std::shared_ptr<StopandWait> stop_and_wait_plugin::StopandWaitNode::plugin_
private

Definition at line 62 of file stop_and_wait_node.hpp.

Referenced by on_configure_plugin(), and plan_trajectory_callback().

◆ plugin_name_

std::string stop_and_wait_plugin::StopandWaitNode::plugin_name_
private

Definition at line 65 of file stop_and_wait_node.hpp.

Referenced by on_configure_plugin().

◆ version_id_

std::string stop_and_wait_plugin::StopandWaitNode::version_id_
private

Definition at line 64 of file stop_and_wait_node.hpp.

Referenced by get_version_id(), and on_configure_plugin().

◆ yield_client_

carma_ros2_utils::ClientPtr<carma_planning_msgs::srv::PlanTrajectory> stop_and_wait_plugin::StopandWaitNode::yield_client_
private

Definition at line 59 of file stop_and_wait_node.hpp.

Referenced by on_configure_plugin().


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