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.
|
PluginBaseNode provides default functionality for all carma guidance plugins. This includes basic state machine management (largely delegated to ROS2 lifecycle behavior), required interfaces, and plugin discovery. More...
#include <plugin_base_node.hpp>
Public Member Functions | |
PluginBaseNode (const rclcpp::NodeOptions &) | |
PluginBaseNode constructor. More... | |
virtual | ~PluginBaseNode ()=default |
Virtual destructor for safe deletion. More... | |
virtual std::shared_ptr< carma_wm::WMListener > | get_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 Member Functions | |
void | discovery_timer_callback () |
Callback for the plugin discovery timer which will publish the plugin discovery message. More... | |
void | lazy_wm_initialization () |
Helper function for lazy initialization of wm_listener_. If already initialized method returns (ie. not a reset) More... | |
Private Attributes | |
rclcpp::Publisher< carma_planning_msgs::msg::Plugin >::SharedPtr | plugin_discovery_pub_ |
Publisher for plugin discovery. This publisher will begin publishing. More... | |
rclcpp::TimerBase::SharedPtr | discovery_timer_ |
Timer to trigger publication of the plugin discovery message at a fixed frequency. More... | |
std::shared_ptr< carma_wm::WMListener > | wm_listener_ |
carma_wm::WorldModelConstPtr | wm_ |
PluginBaseNode provides default functionality for all carma guidance plugins. This includes basic state machine management (largely delegated to ROS2 lifecycle behavior), required interfaces, and plugin discovery.
Extending classes must implement the on_configure_plugin method to load parameters, and my override the other state transitions methods on_<state>_plugin if desired. Additionally, extending classes must implement the methods such as get_version_id() which are used to populate the plugin discovery message.
NOTE: At the moment, this class and all extending classes are setup to support only single threading.
Definition at line 40 of file plugin_base_node.hpp.
|
explicit |
PluginBaseNode constructor.
Definition at line 25 of file plugin_base_node.cpp.
References discovery_timer_, and discovery_timer_callback().
|
virtualdefault |
Virtual destructor for safe deletion.
|
private |
Callback for the plugin discovery timer which will publish the plugin discovery message.
Definition at line 141 of file plugin_base_node.cpp.
References get_activation_status(), get_availability(), get_capability(), get_plugin_name_and_ns(), get_type(), get_version_id(), and plugin_discovery_pub_.
Referenced by PluginBaseNode().
carma_guidance_plugins::PluginBaseNode::FRIEND_TEST | ( | carma_guidance_plugins_test | , |
connections_test | |||
) |
|
finalvirtual |
Returns the activation status of this plugin. The plugins API callbacks will only be triggered when this method returns true.
Definition at line 72 of file plugin_base_node.cpp.
Referenced by discovery_timer_callback(), carma_guidance_plugins::ControlPlugin::handle_on_configure(), carma_guidance_plugins::StrategicPlugin::handle_on_configure(), and carma_guidance_plugins::TacticalPlugin::handle_on_configure().
|
pure virtual |
Get the availability status of this plugin based on the current operating environment. Method must be overriden by extending classes.
Implemented in lci_strategic_plugin::LCIStrategicPlugin, route_following_plugin::RouteFollowingPlugin, sci_strategic_plugin::SCIStrategicPlugin, stop_and_dwell_strategic_plugin::StopAndDwellStrategicPlugin, stop_controlled_intersection_tactical_plugin::StopControlledIntersectionTacticalPlugin, approaching_emergency_vehicle_plugin::ApproachingEmergencyVehiclePlugin, cooperative_lanechange::CooperativeLaneChangePlugin, inlanecruising_plugin::InLaneCruisingPluginNode, intersection_transit_maneuvering::IntersectionTransitManeuveringNode, light_controlled_intersection_tactical_plugin::LightControlledIntersectionTransitPluginNode, platooning_control::PlatooningControlPlugin, platoon_strategic_ihp::Node, platooning_tactical_plugin::Node, pure_pursuit_wrapper::PurePursuitWrapperNode, stop_and_wait_plugin::StopandWaitNode, SUB::Node, SUB::Node, SUB::Node, trajectory_follower_wrapper::TrajectoryFollowerWrapperNode, and yield_plugin::YieldPluginNode.
Referenced by discovery_timer_callback().
|
pure virtual |
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.
Implemented in carma_guidance_plugins::ControlPlugin, carma_guidance_plugins::StrategicPlugin, and carma_guidance_plugins::TacticalPlugin.
Referenced by discovery_timer_callback().
std::string carma_guidance_plugins::PluginBaseNode::get_plugin_name | ( | ) | const |
Return the name of this plugin.
Definition at line 50 of file plugin_base_node.cpp.
Referenced by light_controlled_intersection_tactical_plugin::LightControlledIntersectionTransitPluginNode::on_configure_plugin(), and stop_controlled_intersection_tactical_plugin::StopControlledIntersectionTacticalPlugin::plan_trajectory_callback().
std::string carma_guidance_plugins::PluginBaseNode::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()
Definition at line 55 of file plugin_base_node.cpp.
Referenced by discovery_timer_callback().
|
virtual |
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.
Reimplemented in carma_guidance_plugins::ControlPlugin, carma_guidance_plugins::StrategicPlugin, and carma_guidance_plugins::TacticalPlugin.
Definition at line 134 of file plugin_base_node.cpp.
Referenced by discovery_timer_callback().
|
pure virtual |
Returns the version id of this plugin.
Implemented in lci_strategic_plugin::LCIStrategicPlugin, route_following_plugin::RouteFollowingPlugin, sci_strategic_plugin::SCIStrategicPlugin, stop_and_dwell_strategic_plugin::StopAndDwellStrategicPlugin, stop_controlled_intersection_tactical_plugin::StopControlledIntersectionTacticalPlugin, approaching_emergency_vehicle_plugin::ApproachingEmergencyVehiclePlugin, cooperative_lanechange::CooperativeLaneChangePlugin, intersection_transit_maneuvering::IntersectionTransitManeuveringNode, light_controlled_intersection_tactical_plugin::LightControlledIntersectionTransitPluginNode, platooning_control::PlatooningControlPlugin, platoon_strategic_ihp::Node, platooning_tactical_plugin::Node, pure_pursuit_wrapper::PurePursuitWrapperNode, SUB::Node, SUB::Node, SUB::Node, trajectory_follower_wrapper::TrajectoryFollowerWrapperNode, inlanecruising_plugin::InLaneCruisingPluginNode, stop_and_wait_plugin::StopandWaitNode, and yield_plugin::YieldPluginNode.
Referenced by discovery_timer_callback().
|
finalvirtual |
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.
Definition at line 66 of file plugin_base_node.cpp.
References lazy_wm_initialization(), and wm_.
Referenced by approaching_emergency_vehicle_plugin::ApproachingEmergencyVehiclePlugin::on_configure_plugin(), cooperative_lanechange::CooperativeLaneChangePlugin::on_configure_plugin(), inlanecruising_plugin::InLaneCruisingPluginNode::on_configure_plugin(), lci_strategic_plugin::LCIStrategicPlugin::on_configure_plugin(), platoon_strategic_ihp::Node::on_configure_plugin(), platooning_tactical_plugin::Node::on_configure_plugin(), route_following_plugin::RouteFollowingPlugin::on_configure_plugin(), sci_strategic_plugin::SCIStrategicPlugin::on_configure_plugin(), stop_and_dwell_strategic_plugin::StopAndDwellStrategicPlugin::on_configure_plugin(), stop_and_wait_plugin::StopandWaitNode::on_configure_plugin(), yield_plugin::YieldPluginNode::on_configure_plugin(), light_controlled_intersection_tactical_plugin::LightControlledIntersectionTransitPluginNode::on_configure_plugin(), and stop_controlled_intersection_tactical_plugin::StopControlledIntersectionTacticalPlugin::on_configure_plugin().
|
finalvirtual |
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.
Definition at line 60 of file plugin_base_node.cpp.
References lazy_wm_initialization(), and wm_listener_.
Referenced by route_following_plugin::RouteFollowingPlugin::on_configure_plugin().
|
override |
Definition at line 109 of file plugin_base_node.cpp.
References on_activate_plugin().
Referenced by carma_guidance_plugins::ControlPlugin::handle_on_activate(), carma_guidance_plugins::StrategicPlugin::handle_on_activate(), and carma_guidance_plugins::TacticalPlugin::handle_on_activate().
|
override |
Definition at line 119 of file plugin_base_node.cpp.
References on_cleanup_plugin().
Referenced by carma_guidance_plugins::ControlPlugin::handle_on_cleanup(), carma_guidance_plugins::StrategicPlugin::handle_on_cleanup(), and carma_guidance_plugins::TacticalPlugin::handle_on_cleanup().
|
override |
Definition at line 104 of file plugin_base_node.cpp.
References on_configure_plugin().
Referenced by carma_guidance_plugins::ControlPlugin::handle_on_configure(), carma_guidance_plugins::StrategicPlugin::handle_on_configure(), and carma_guidance_plugins::TacticalPlugin::handle_on_configure().
|
override |
Definition at line 114 of file plugin_base_node.cpp.
References on_deactivate_plugin().
Referenced by carma_guidance_plugins::ControlPlugin::handle_on_deactivate(), carma_guidance_plugins::StrategicPlugin::handle_on_deactivate(), and carma_guidance_plugins::TacticalPlugin::handle_on_deactivate().
|
override |
Definition at line 129 of file plugin_base_node.cpp.
References on_error_plugin().
Referenced by carma_guidance_plugins::ControlPlugin::handle_on_error(), carma_guidance_plugins::StrategicPlugin::handle_on_error(), and carma_guidance_plugins::TacticalPlugin::handle_on_error().
|
override |
Definition at line 124 of file plugin_base_node.cpp.
References on_shutdown_plugin().
Referenced by carma_guidance_plugins::ControlPlugin::handle_on_shutdown(), carma_guidance_plugins::StrategicPlugin::handle_on_shutdown(), and carma_guidance_plugins::TacticalPlugin::handle_on_shutdown().
|
private |
Helper function for lazy initialization of wm_listener_. If already initialized method returns (ie. not a reset)
Definition at line 36 of file plugin_base_node.cpp.
References wm_, and wm_listener_.
Referenced by get_world_model(), and get_world_model_listener().
|
virtual |
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.
Reimplemented in approaching_emergency_vehicle_plugin::ApproachingEmergencyVehiclePlugin, lci_strategic_plugin::LCIStrategicPlugin, route_following_plugin::RouteFollowingPlugin, sci_strategic_plugin::SCIStrategicPlugin, and stop_and_dwell_strategic_plugin::StopAndDwellStrategicPlugin.
Definition at line 78 of file plugin_base_node.cpp.
Referenced by handle_on_activate().
|
virtual |
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.
Reimplemented in platoon_strategic_ihp::Node.
Definition at line 88 of file plugin_base_node.cpp.
Referenced by handle_on_cleanup().
|
pure virtual |
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.
Implemented in approaching_emergency_vehicle_plugin::ApproachingEmergencyVehiclePlugin, cooperative_lanechange::CooperativeLaneChangePlugin, inlanecruising_plugin::InLaneCruisingPluginNode, lci_strategic_plugin::LCIStrategicPlugin, platoon_strategic_ihp::Node, platooning_tactical_plugin::Node, route_following_plugin::RouteFollowingPlugin, sci_strategic_plugin::SCIStrategicPlugin, stop_and_dwell_strategic_plugin::StopAndDwellStrategicPlugin, stop_and_wait_plugin::StopandWaitNode, SUB::Node, SUB::Node, SUB::Node, yield_plugin::YieldPluginNode, intersection_transit_maneuvering::IntersectionTransitManeuveringNode, light_controlled_intersection_tactical_plugin::LightControlledIntersectionTransitPluginNode, platooning_control::PlatooningControlPlugin, pure_pursuit_wrapper::PurePursuitWrapperNode, stop_controlled_intersection_tactical_plugin::StopControlledIntersectionTacticalPlugin, and trajectory_follower_wrapper::TrajectoryFollowerWrapperNode.
Referenced by handle_on_configure().
|
virtual |
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.
Definition at line 83 of file plugin_base_node.cpp.
Referenced by handle_on_deactivate().
|
virtual |
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.
exception_string | The exception description |
Definition at line 98 of file plugin_base_node.cpp.
Referenced by handle_on_error().
|
virtual |
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.
Definition at line 93 of file plugin_base_node.cpp.
Referenced by handle_on_shutdown().
|
private |
Timer to trigger publication of the plugin discovery message at a fixed frequency.
Definition at line 51 of file plugin_base_node.hpp.
Referenced by PluginBaseNode().
|
private |
Publisher for plugin discovery. This publisher will begin publishing.
Definition at line 47 of file plugin_base_node.hpp.
Referenced by discovery_timer_callback().
|
private |
Definition at line 61 of file plugin_base_node.hpp.
Referenced by get_world_model(), and lazy_wm_initialization().
|
private |
Definition at line 56 of file plugin_base_node.hpp.
Referenced by get_world_model_listener(), and lazy_wm_initialization().