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.
arbitrator::CapabilitiesInterface Class Reference

Generic interface for interacting with Plugins via their capabilities instead of directly by their topics. More...

#include <capabilities_interface.hpp>

Collaboration diagram for arbitrator::CapabilitiesInterface:
Collaboration graph

Public Member Functions

 CapabilitiesInterface (std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > nh)
 Constructor for Capabilities interface. More...
 
std::vector< std::string > get_topics_for_capability (const std::string &query_string)
 Initialize the Capabilities interface by querying the Health Monitor node and processing the plugins that are returned. More...
 
template<typename MSrvReq , typename MSrvRes >
std::map< std::string, std::shared_ptr< MSrvRes > > multiplex_service_call_for_capability (const std::string &query_string, std::shared_ptr< MSrvReq > msg)
 Template function for calling all nodes which respond to a service associated with a particular capability. Will send the service request to all nodes and aggregate the responses. More...
 

Static Public Attributes

static const std::string STRATEGIC_PLAN_CAPABILITY = "strategic_plan/plan_maneuvers"
 

Private Attributes

std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > nh_
 
std::unordered_map< std::string, carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanManeuvers > > registered_strategic_plugins_
 
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::GetPluginApi > sc_s_
 
std::unordered_set< std::string > capabilities_
 

Detailed Description

Generic interface for interacting with Plugins via their capabilities instead of directly by their topics.

Definition at line 38 of file capabilities_interface.hpp.

Constructor & Destructor Documentation

◆ CapabilitiesInterface()

arbitrator::CapabilitiesInterface::CapabilitiesInterface ( std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode >  nh)
inline

Constructor for Capabilities interface.

Parameters
nhA CarmaLifecycleNode pointer this interface will work with

Definition at line 45 of file capabilities_interface.hpp.

45 : nh_(nh) {
46 sc_s_ = nh_->create_client<carma_planning_msgs::srv::GetPluginApi>("plugins/get_strategic_plugins_by_capability");
47 };
std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > nh_
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::GetPluginApi > sc_s_

References nh_, and sc_s_.

Member Function Documentation

◆ get_topics_for_capability()

std::vector< std::string > arbitrator::CapabilitiesInterface::get_topics_for_capability ( const std::string &  query_string)

Initialize the Capabilities interface by querying the Health Monitor node and processing the plugins that are returned.

Get the list of topics that respond to the capability specified by the query string

Parameters
query_stringThe string name of the capability to look for
Returns
A list of all responding topics, if any are found.

Definition at line 26 of file capabilities_interface.cpp.

27 {
28 std::vector<std::string> topics = {};
29
30 auto srv = std::make_shared<carma_planning_msgs::srv::GetPluginApi::Request>();
31 srv->capability = "";
32
33 auto plan_response = sc_s_->async_send_request(srv);
34
35 auto future_status = plan_response.wait_for(std::chrono::milliseconds(200));
36
37 if (query_string == STRATEGIC_PLAN_CAPABILITY && future_status == std::future_status::ready)
38 {
39 topics = plan_response.get()->plan_service;
40
41 // Log the topics
42 std::ostringstream stream;
43 stream << "Received Topics: ";
44 for (const auto& topic : topics) {
45 stream << topic << ", ";
46 }
47 stream << std::endl;
48 RCLCPP_INFO_STREAM(nh_->get_logger(), stream.str().c_str());
49 }
50 else
51 {
52 RCLCPP_ERROR_STREAM(nh_->get_logger(), "service call failed...");
53 RCLCPP_ERROR_STREAM(nh_->get_logger(), "client: " << sc_s_);
54 }
55
56 return topics;
57
58 }
static const std::string STRATEGIC_PLAN_CAPABILITY

References nh_, sc_s_, srv, STRATEGIC_PLAN_CAPABILITY, and process_bag::topics.

◆ multiplex_service_call_for_capability()

template<typename MSrvReq , typename MSrvRes >
std::map< std::string, std::shared_ptr< MSrvRes > > arbitrator::CapabilitiesInterface::multiplex_service_call_for_capability ( const std::string &  query_string,
std::shared_ptr< MSrvReq >  msg 
)

Template function for calling all nodes which respond to a service associated with a particular capability. Will send the service request to all nodes and aggregate the responses.

Template Parameters
MSrvReqThe typename of the service message request
MSrvResThe typename of the service message response
Parameters
query_stringThe string name of the capability to look for
Themessage itself to send
Returns
A map matching the topic name that responded -> the response

Member Data Documentation

◆ capabilities_

std::unordered_set<std::string> arbitrator::CapabilitiesInterface::capabilities_
private

Definition at line 88 of file capabilities_interface.hpp.

◆ nh_

std::shared_ptr<carma_ros2_utils::CarmaLifecycleNode> arbitrator::CapabilitiesInterface::nh_
private

Definition at line 84 of file capabilities_interface.hpp.

Referenced by CapabilitiesInterface(), and get_topics_for_capability().

◆ registered_strategic_plugins_

std::unordered_map<std::string,carma_ros2_utils::ClientPtr<carma_planning_msgs::srv::PlanManeuvers> > arbitrator::CapabilitiesInterface::registered_strategic_plugins_
private

Definition at line 85 of file capabilities_interface.hpp.

◆ sc_s_

carma_ros2_utils::ClientPtr<carma_planning_msgs::srv::GetPluginApi> arbitrator::CapabilitiesInterface::sc_s_
private

Definition at line 87 of file capabilities_interface.hpp.

Referenced by CapabilitiesInterface(), and get_topics_for_capability().

◆ STRATEGIC_PLAN_CAPABILITY

const std::string arbitrator::CapabilitiesInterface::STRATEGIC_PLAN_CAPABILITY = "strategic_plan/plan_maneuvers"
static

Definition at line 81 of file capabilities_interface.hpp.

Referenced by get_topics_for_capability().


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