38 if (base_return != cr2::CallbackReturn::SUCCESS) {
39 RCLCPP_ERROR(get_logger(),
"Guidance Controller could not configure");
50 std::vector<std::string> guidance_plugin_nodes;
52 std::copy_if(base_managed_nodes.begin(), base_managed_nodes.end(),
53 std::back_inserter(guidance_plugin_nodes),
54 [plugin_namespace](
const std::string& s) { return s.rfind(plugin_namespace, 0) == 0; });
56 std::vector<std::string> non_plugin_guidance_nodes =
get_non_intersecting_set(base_managed_nodes, guidance_plugin_nodes);
64 RCLCPP_INFO_STREAM(get_logger(),
"Config: " <<
config_);
67 auto plugin_lifecycle_manager = std::make_shared<ros2_lifecycle_manager::Ros2LifecycleManager>(
68 get_node_base_interface(), get_node_graph_interface(), get_node_logging_interface(), get_node_services_interface());
73 plugin_lifecycle_manager,
74 [
this](){ return get_current_state().id(); },
75 [
this](
auto node,
auto ns){ return get_service_names_and_types_by_node(node, ns); },
80 "plugin_discovery", 50,
84 "plugins/get_registered_plugins",
88 "plugins/get_active_plugins",
92 "plugins/activate_plugin",
96 "plugins/get_strategic_plugins_by_capability",
100 "plugins/get_tactical_plugins_by_capability",
104 "plugins/get_control_plugins_by_capability",
115 }
catch(
const std::runtime_error& e) {
116 RCLCPP_ERROR_STREAM(get_logger(),
"Error configuring plugin manager " << e.what());
125 RCLCPP_INFO_STREAM(get_logger(),
"Subsystem able to configure");
126 return CallbackReturn::SUCCESS;
131 RCLCPP_INFO_STREAM(get_logger(),
"Subsystem unable to configure");
132 return CallbackReturn::FAILURE;
141 if (base_return != cr2::CallbackReturn::SUCCESS) {
142 RCLCPP_ERROR(get_logger(),
"Guidance Controller could not activate");
149 }
catch(
const std::runtime_error& e) {
150 RCLCPP_ERROR_STREAM(get_logger(),
"Error activating plugin manager " << e.what());
157 RCLCPP_INFO_STREAM(get_logger(),
"Subsystem able to activate");
158 return CallbackReturn::SUCCESS;
163 RCLCPP_INFO_STREAM(get_logger(),
"Subsystem unable to activate");
164 return CallbackReturn::FAILURE;
173 if (base_return != cr2::CallbackReturn::SUCCESS) {
174 RCLCPP_ERROR(get_logger(),
"Guidance Controller could not deactivate");
181 }
catch(
const std::runtime_error& e) {
182 RCLCPP_ERROR_STREAM(get_logger(),
"Error deactivating plugin manager " << e.what());
189 RCLCPP_INFO_STREAM(get_logger(),
"Subsystem able to deactivate");
190 return CallbackReturn::SUCCESS;
195 RCLCPP_INFO_STREAM(get_logger(),
"Subsystem unable to deactivate");
196 return CallbackReturn::FAILURE;
204 if (base_return != cr2::CallbackReturn::SUCCESS) {
205 RCLCPP_ERROR(get_logger(),
"Guidance Controller could not cleanup");
212 }
catch(
const std::runtime_error& e) {
213 RCLCPP_ERROR_STREAM(get_logger(),
"Error cleaning up plugin manager " << e.what());
220 RCLCPP_INFO_STREAM(get_logger(),
"Subsystem able to cleanup");
221 return CallbackReturn::SUCCESS;
226 RCLCPP_INFO_STREAM(get_logger(),
"Subsystem unable to cleanup");
227 return CallbackReturn::FAILURE;
235 if (base_return != cr2::CallbackReturn::SUCCESS) {
236 RCLCPP_ERROR(get_logger(),
"Guidance Controller could not shutdown");
245 RCLCPP_INFO_STREAM(get_logger(),
"Subsystem able to shutdown cleanly");
246 return CallbackReturn::SUCCESS;
251 RCLCPP_INFO_STREAM(get_logger(),
"Subsystem unable to shutdown cleanly");
252 return CallbackReturn::FAILURE;
259#include "rclcpp_components/register_node_macro.hpp"
std::chrono::milliseconds std_msec
A base class for all subsystem_controllers which provides default lifecycle behavior for subsystems.
BaseSubSystemControllerConfig base_config_
The configuration struct.
virtual carma_ros2_utils::CallbackReturn handle_on_shutdown(const rclcpp_lifecycle::State &prev_state)
virtual carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &prev_state)
virtual carma_ros2_utils::CallbackReturn handle_on_deactivate(const rclcpp_lifecycle::State &prev_state)
virtual carma_ros2_utils::CallbackReturn handle_on_activate(const rclcpp_lifecycle::State &prev_state)
std::vector< std::string > get_non_intersecting_set(const std::vector< std::string > &set_a, const std::vector< std::string > &set_b) const
Returns all elements of the provided set_a which are NOT contained in the provided set_b.
bool trigger_managed_nodes_configure_from_base_class_
Collection of flags which, if true, will cause the base class to make lifecycle service calls to mana...
ros2_lifecycle_manager::Ros2LifecycleManager lifecycle_mgr_
Lifecycle Manager which will track the managed nodes and call their lifecycle services on request.
virtual carma_ros2_utils::CallbackReturn handle_on_cleanup(const rclcpp_lifecycle::State &prev_state)
cr2::SubPtr< carma_planning_msgs::msg::Plugin > plugin_discovery_sub_
ROS handles.
cr2::ServicePtr< carma_planning_msgs::srv::GetPluginApi > get_control_plugins_by_capability_server_
cr2::CallbackReturn handle_on_activate(const rclcpp_lifecycle::State &)
cr2::ServicePtr< carma_planning_msgs::srv::GetPluginApi > get_strategic_plugins_by_capability_server_
cr2::CallbackReturn handle_on_deactivate(const rclcpp_lifecycle::State &)
cr2::ServicePtr< carma_planning_msgs::srv::GetPluginApi > get_tactical_plugins_by_capability_server_
cr2::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &)
GuidanceControllerNode()=delete
cr2::ServicePtr< carma_planning_msgs::srv::PluginList > get_active_plugins_server_
cr2::ServicePtr< carma_planning_msgs::srv::PluginActivation > activate_plugin_server_
cr2::CallbackReturn handle_on_cleanup(const rclcpp_lifecycle::State &)
cr2::ServicePtr< carma_planning_msgs::srv::PluginList > get_registered_plugins_server_
GuidanceControllerConfig config_
Config for user provided parameters.
cr2::CallbackReturn handle_on_shutdown(const rclcpp_lifecycle::State &)
std::shared_ptr< PluginManager > plugin_manager_
Plugin manager to handle all the plugin specific discovery and reporting.
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.
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.
void update_plugin_status(carma_planning_msgs::msg::Plugin::UniquePtr msg)
Update the status of a certain plugin.
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.
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.
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.
void activate_plugin(SrvHeader, carma_planning_msgs::srv::PluginActivation::Request::SharedPtr req, carma_planning_msgs::srv::PluginActivation::Response::SharedPtr res)
Activate the specified plugin.
std::chrono::milliseconds std_msec
int service_timeout_ms
Timeout in ms for service availability.
std::string subsystem_namespace
Node Namespace. Any node under this namespace shall have its lifecycle managed by this controller.
int call_timeout_ms
Timeout in ms for service calls.
Stuct containing the algorithm configuration values for the GuidanceController.
std::vector< std::string > auto_activated_plugins
List of guidance plugins which are not required but the user wishes to have automatically activated.
std::vector< std::string > required_plugins
List of guidance plugins (node name) to consider required and who's failure shall result in automatio...