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.
|
The PluginManager serves as a component to manage CARMA Guidance Plugins via their ros2 lifecycle interfaces. More...
#include <plugin_manager.h>
Public Member Functions | |
PluginManager (const std::vector< std::string > &required_plugins, const std::vector< std::string > &auto_activated_plugins, std::shared_ptr< ros2_lifecycle_manager::LifecycleManagerInterface > plugin_lifecycle_mgr, GetParentNodeStateFunc get_parent_state_func, ServiceNamesAndTypesFunc get_service_names_and_types_func, std::chrono::nanoseconds service_timeout, std::chrono::nanoseconds call_timeout) | |
Constructor for PluginManager. More... | |
bool | configure () |
bool | activate () |
bool | deactivate () |
bool | cleanup () |
bool | shutdown () |
void | update_plugin_status (carma_planning_msgs::msg::Plugin::UniquePtr msg) |
Update the status of a certain plugin. More... | |
void | get_registered_plugins (SrvHeader, carma_planning_msgs::srv::PluginList::Request::SharedPtr req, carma_planning_msgs::srv::PluginList::Response::SharedPtr res) |
Returns the list of known plugins. More... | |
void | get_active_plugins (SrvHeader, carma_planning_msgs::srv::PluginList::Request::SharedPtr req, carma_planning_msgs::srv::PluginList::Response::SharedPtr res) |
Get the list of currently active plugins. More... | |
void | activate_plugin (SrvHeader, carma_planning_msgs::srv::PluginActivation::Request::SharedPtr req, carma_planning_msgs::srv::PluginActivation::Response::SharedPtr res) |
Activate the specified plugin. More... | |
void | get_strategic_plugins_by_capability (SrvHeader, carma_planning_msgs::srv::GetPluginApi::Request::SharedPtr req, carma_planning_msgs::srv::GetPluginApi::Response::SharedPtr res) |
Get strategic plugins by capability. More... | |
void | get_tactical_plugins_by_capability (SrvHeader, carma_planning_msgs::srv::GetPluginApi::Request::SharedPtr req, carma_planning_msgs::srv::GetPluginApi::Response::SharedPtr res) |
Get tactical plugins by capability. More... | |
void | get_control_plugins_by_capability (SrvHeader, carma_planning_msgs::srv::GetPluginApi::Request::SharedPtr req, carma_planning_msgs::srv::GetPluginApi::Response::SharedPtr res) |
Get control plugins by capability. More... | |
Protected Member Functions | |
void | add_plugin (const Entry &plugin) |
Add the specified entry to our plugin management This function will attempt to move the newly detected plugin to the required state based on this nodes own state. More... | |
bool | matching_capability (const std::vector< std::string > &base_capability_levels, const std::vector< std::string > &compared_capability_levels) |
Returns true if the provided base capability hierarchy can achieve the requested capability hierarchy A capability hierarchy is described as a list of strings where the first string is the most generic description of the capability while the last string the is the most detailed description. More... | |
bool | is_ros2_lifecycle_node (const std::string &node) |
Returns true if the specified fully qualified node name is a ROS2 lifecycle node. More... | |
Protected Attributes | |
std::unordered_set< std::string > | required_plugins_ |
Set of required plugins a failure of which necessitates system shutdown. More... | |
std::unordered_set< std::string > | auto_activated_plugins_ |
Set of use specified auto activated plugins which will automatically started without need for user input. More... | |
std::shared_ptr< ros2_lifecycle_manager::LifecycleManagerInterface > | plugin_lifecycle_mgr_ |
Lifecycle Manager which will track the plugin nodes and call their lifecycle services on request. More... | |
GetParentNodeStateFunc | get_parent_state_func_ |
Callback to retrieve the lifecycle state of the parent process. More... | |
ServiceNamesAndTypesFunc | get_service_names_and_types_func_ |
Callback to get service names and types for the given node. More... | |
EntryManager | em_ |
Entry manager to keep track of detected plugins. More... | |
std::chrono::nanoseconds | service_timeout_ |
The timeout for services to be available. More... | |
std::chrono::nanoseconds | call_timeout_ |
The timeout for service calls to return. More... | |
const std::string | plan_maneuvers_suffix_ = "/plan_maneuvers" |
Base service name of plan_trajectory service. More... | |
const std::string | plan_trajectory_suffix_ = "/plan_trajectory" |
Base service name of plan_trajectory service. More... | |
const std::string | control_trajectory_suffix_ = "/plan_trajectory" |
Base topic name of control plugin trajectory input topic. More... | |
The PluginManager serves as a component to manage CARMA Guidance Plugins via their ros2 lifecycle interfaces.
Definition at line 48 of file plugin_manager.h.
subsystem_controllers::PluginManager::PluginManager | ( | const std::vector< std::string > & | required_plugins, |
const std::vector< std::string > & | auto_activated_plugins, | ||
std::shared_ptr< ros2_lifecycle_manager::LifecycleManagerInterface > | plugin_lifecycle_mgr, | ||
GetParentNodeStateFunc | get_parent_state_func, | ||
ServiceNamesAndTypesFunc | get_service_names_and_types_func, | ||
std::chrono::nanoseconds | service_timeout, | ||
std::chrono::nanoseconds | call_timeout | ||
) |
Constructor for PluginManager.
required_plugins | The set of plugins which will be treated as required. A failure in these plugins will result in an exception |
auto_activated_plugins | The set of plugins which will be automatically activated at first system activation but not treated specially after that. |
plugin_lifecycle_mgr | A fully initialized lifecycle manager which will be used trigger plugin transitions |
get_parent_state_func | A callback which will allow this object to access the parent process lifecycle state |
get_service_names_and_types_func | A callback which returns a map of service names to service types based on the provided base node name and namespace |
service_timeout | The timeout for plugin services to be available in nanoseconds |
call_timeout | The timeout for calls to plugin services to fail in nanoseconds |
Definition at line 28 of file plugin_manager.cpp.
References auto_activated_plugins_, em_, plugin_lifecycle_mgr_, required_plugins_, and subsystem_controllers::EntryManager::update_entry().
bool subsystem_controllers::PluginManager::activate | ( | ) |
Definition at line 166 of file plugin_manager.cpp.
References subsystem_controllers::Entry::active_, auto_activated_plugins_, subsystem_controllers::Entry::available_, call_timeout_, em_, subsystem_controllers::EntryManager::get_entries(), plugin_lifecycle_mgr_, required_plugins_, service_timeout_, subsystem_controllers::EntryManager::update_entry(), and subsystem_controllers::Entry::user_requested_activation_.
void subsystem_controllers::PluginManager::activate_plugin | ( | SrvHeader | , |
carma_planning_msgs::srv::PluginActivation::Request::SharedPtr | req, | ||
carma_planning_msgs::srv::PluginActivation::Response::SharedPtr | res | ||
) |
Activate the specified plugin.
header | Middle ware header | |
req | The req details containing the plugin to activate | |
[out] | res | The response containing the success flag |
Definition at line 320 of file plugin_manager.cpp.
References call_timeout_, em_, subsystem_controllers::EntryManager::get_entry_by_name(), plugin_lifecycle_mgr_, service_timeout_, and subsystem_controllers::EntryManager::update_entry().
Referenced by subsystem_controllers::GuidanceControllerNode::handle_on_configure().
|
protected |
Add the specified entry to our plugin management This function will attempt to move the newly detected plugin to the required state based on this nodes own state.
plugin | The entry representing the plugin to add |
std::runtime_error | if this was a required plugin and it could not be transitioned as needed |
Definition at line 64 of file plugin_manager.cpp.
References subsystem_controllers::Entry::active_, subsystem_controllers::Entry::available_, call_timeout_, em_, get_parent_state_func_, subsystem_controllers::Entry::name_, plugin_lifecycle_mgr_, required_plugins_, service_timeout_, and subsystem_controllers::EntryManager::update_entry().
Referenced by update_plugin_status().
bool subsystem_controllers::PluginManager::cleanup | ( | ) |
Definition at line 248 of file plugin_manager.cpp.
References subsystem_controllers::Entry::active_, subsystem_controllers::Entry::available_, call_timeout_, em_, subsystem_controllers::EntryManager::get_entries(), plugin_lifecycle_mgr_, required_plugins_, service_timeout_, subsystem_controllers::EntryManager::update_entry(), and subsystem_controllers::Entry::user_requested_activation_.
bool subsystem_controllers::PluginManager::configure | ( | ) |
Below are the state transition methods which will cause this manager to trigger the corresponding state transitions in the managed plugins.
std::runtime_error | If a required node could not transition successfully |
Definition at line 131 of file plugin_manager.cpp.
References subsystem_controllers::Entry::active_, subsystem_controllers::Entry::available_, call_timeout_, em_, subsystem_controllers::EntryManager::get_entries(), plugin_lifecycle_mgr_, required_plugins_, service_timeout_, subsystem_controllers::EntryManager::update_entry(), and subsystem_controllers::Entry::user_requested_activation_.
bool subsystem_controllers::PluginManager::deactivate | ( | ) |
Definition at line 214 of file plugin_manager.cpp.
References subsystem_controllers::Entry::active_, subsystem_controllers::Entry::available_, call_timeout_, em_, subsystem_controllers::EntryManager::get_entries(), plugin_lifecycle_mgr_, required_plugins_, service_timeout_, subsystem_controllers::EntryManager::update_entry(), and subsystem_controllers::Entry::user_requested_activation_.
void subsystem_controllers::PluginManager::get_active_plugins | ( | SrvHeader | , |
carma_planning_msgs::srv::PluginList::Request::SharedPtr | req, | ||
carma_planning_msgs::srv::PluginList::Response::SharedPtr | res | ||
) |
Get the list of currently active plugins.
header | Middle ware header | |
req | The req details | |
[out] | res | The response containing the list of active plugins |
Definition at line 302 of file plugin_manager.cpp.
References em_, and subsystem_controllers::EntryManager::get_entries().
Referenced by subsystem_controllers::GuidanceControllerNode::handle_on_configure().
void subsystem_controllers::PluginManager::get_control_plugins_by_capability | ( | SrvHeader | , |
carma_planning_msgs::srv::GetPluginApi::Request::SharedPtr | req, | ||
carma_planning_msgs::srv::GetPluginApi::Response::SharedPtr | res | ||
) |
Get control plugins by capability.
header | Middle ware header |
req | The req which identifies which capability is required |
res | The res which identifies the control plugins with the requested capability |
Definition at line 375 of file plugin_manager.cpp.
References control_trajectory_suffix_, em_, subsystem_controllers::EntryManager::get_entries(), matching_capability(), and process_traj_logs::split.
Referenced by subsystem_controllers::GuidanceControllerNode::handle_on_configure().
void subsystem_controllers::PluginManager::get_registered_plugins | ( | SrvHeader | , |
carma_planning_msgs::srv::PluginList::Request::SharedPtr | req, | ||
carma_planning_msgs::srv::PluginList::Response::SharedPtr | res | ||
) |
Returns the list of known plugins.
req | The req details | |
[out] | res | The response containing the list of known plugins |
Definition at line 287 of file plugin_manager.cpp.
References em_, and subsystem_controllers::EntryManager::get_entries().
Referenced by subsystem_controllers::GuidanceControllerNode::handle_on_configure().
void subsystem_controllers::PluginManager::get_strategic_plugins_by_capability | ( | SrvHeader | , |
carma_planning_msgs::srv::GetPluginApi::Request::SharedPtr | req, | ||
carma_planning_msgs::srv::GetPluginApi::Response::SharedPtr | res | ||
) |
Get strategic plugins by capability.
header | Middle ware header |
req | The req which identifies which capability is required |
res | The res which identifies the strategic plugins with the requested capability |
Definition at line 423 of file plugin_manager.cpp.
References em_, subsystem_controllers::EntryManager::get_entries(), matching_capability(), plan_maneuvers_suffix_, and process_traj_logs::split.
Referenced by subsystem_controllers::GuidanceControllerNode::handle_on_configure().
void subsystem_controllers::PluginManager::get_tactical_plugins_by_capability | ( | SrvHeader | , |
carma_planning_msgs::srv::GetPluginApi::Request::SharedPtr | req, | ||
carma_planning_msgs::srv::GetPluginApi::Response::SharedPtr | res | ||
) |
Get tactical plugins by capability.
header | Middle ware header |
req | The req which identifies which capability is required |
res | The res which identifies the tactical plugins with the requested capability |
Definition at line 399 of file plugin_manager.cpp.
References em_, subsystem_controllers::EntryManager::get_entries(), matching_capability(), plan_trajectory_suffix_, and process_traj_logs::split.
Referenced by subsystem_controllers::GuidanceControllerNode::handle_on_configure().
|
protected |
Returns true if the specified fully qualified node name is a ROS2 lifecycle node.
node | The fully specified name of the node to evaluate |
|
protected |
Returns true if the provided base capability hierarchy can achieve the requested capability hierarchy A capability hierarchy is described as a list of strings where the first string is the most generic description of the capability while the last string the is the most detailed description.
For example the capability "tactical_plan/plan_trajectory" would be described as ["tactical_plan", "plan_trajectory"] if the user wanted to match this to "tactical_plan/plan_trajectory/platooning_trajectory" then the compared_capability_levels would be ["tactical_plan", "plan_trajectory", "compared_capability_levels"] Matching those two inputs as ( ["tactical_plan", "plan_trajectory"], ["tactical_plan", "plan_trajectory", "compared_capability_levels"]) would be false because the compared_capability_levels is more detailed than the base. By contrast, matching ( ["tactical_plan", "plan_trajectory", "compared_capability_levels"], ["tactical_plan", "plan_trajectory"] ) would be true since the base is more generic then the request
// TODO check with Kyle on this because it maybe should be the reverse since a more specific capability may require specific meta data.
base_capability_levels | The base hierarchy to check for compatability |
compared_capability_levels | The compared_capability_levels which are being checked against the base |
Definition at line 364 of file plugin_manager.cpp.
References process_bag::i.
Referenced by get_control_plugins_by_capability(), get_strategic_plugins_by_capability(), and get_tactical_plugins_by_capability().
bool subsystem_controllers::PluginManager::shutdown | ( | ) |
Definition at line 282 of file plugin_manager.cpp.
References call_timeout_, em_, subsystem_controllers::EntryManager::get_entry_names(), plugin_lifecycle_mgr_, and service_timeout_.
void subsystem_controllers::PluginManager::update_plugin_status | ( | carma_planning_msgs::msg::Plugin::UniquePtr | msg | ) |
Update the status of a certain plugin.
msg | A plugin status message |
Definition at line 348 of file plugin_manager.cpp.
References add_plugin(), em_, subsystem_controllers::EntryManager::get_entry_by_name(), and subsystem_controllers::EntryManager::update_entry().
Referenced by subsystem_controllers::GuidanceControllerNode::handle_on_configure().
|
protected |
Set of use specified auto activated plugins which will automatically started without need for user input.
Definition at line 194 of file plugin_manager.h.
Referenced by PluginManager(), and activate().
|
protected |
The timeout for service calls to return.
Definition at line 212 of file plugin_manager.h.
Referenced by activate(), activate_plugin(), add_plugin(), cleanup(), configure(), deactivate(), and shutdown().
|
protected |
Base topic name of control plugin trajectory input topic.
Definition at line 221 of file plugin_manager.h.
Referenced by get_control_plugins_by_capability().
|
protected |
Entry manager to keep track of detected plugins.
Definition at line 206 of file plugin_manager.h.
Referenced by PluginManager(), activate(), activate_plugin(), add_plugin(), cleanup(), configure(), deactivate(), get_active_plugins(), get_control_plugins_by_capability(), get_registered_plugins(), get_strategic_plugins_by_capability(), get_tactical_plugins_by_capability(), shutdown(), and update_plugin_status().
|
protected |
Callback to retrieve the lifecycle state of the parent process.
Definition at line 200 of file plugin_manager.h.
Referenced by add_plugin().
|
protected |
Callback to get service names and types for the given node.
Definition at line 203 of file plugin_manager.h.
|
protected |
Base service name of plan_trajectory service.
Definition at line 215 of file plugin_manager.h.
Referenced by get_strategic_plugins_by_capability().
|
protected |
Base service name of plan_trajectory service.
Definition at line 218 of file plugin_manager.h.
Referenced by get_tactical_plugins_by_capability().
|
protected |
Lifecycle Manager which will track the plugin nodes and call their lifecycle services on request.
Definition at line 197 of file plugin_manager.h.
Referenced by PluginManager(), activate(), activate_plugin(), add_plugin(), cleanup(), configure(), deactivate(), and shutdown().
|
protected |
Set of required plugins a failure of which necessitates system shutdown.
Definition at line 190 of file plugin_manager.h.
Referenced by PluginManager(), activate(), add_plugin(), cleanup(), configure(), and deactivate().
|
protected |
The timeout for services to be available.
Definition at line 209 of file plugin_manager.h.
Referenced by activate(), activate_plugin(), add_plugin(), cleanup(), configure(), deactivate(), and shutdown().