Generic interface for interacting with Plugins via their capabilities instead of directly by their topics.
More...
#include <capabilities_interface.hpp>
|
| 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...
|
|
|
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_ |
|
Generic interface for interacting with Plugins via their capabilities instead of directly by their topics.
Definition at line 38 of file capabilities_interface.hpp.
◆ CapabilitiesInterface()
arbitrator::CapabilitiesInterface::CapabilitiesInterface |
( |
std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > |
nh | ) |
|
|
inline |
Constructor for Capabilities interface.
- Parameters
-
nh | A CarmaLifecycleNode pointer this interface will work with |
Definition at line 45 of file capabilities_interface.hpp.
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_.
◆ 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_string | The 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
38 {
39 topics = plan_response.get()->plan_service;
40
41
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
57
58 }
static const std::string STRATEGIC_PLAN_CAPABILITY
References nh_, sc_s_, 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
-
MSrvReq | The typename of the service message request |
MSrvRes | The typename of the service message response |
- Parameters
-
query_string | The string name of the capability to look for |
The | message itself to send |
- Returns
- A map matching the topic name that responded -> the response
◆ capabilities_
std::unordered_set<std::string> arbitrator::CapabilitiesInterface::capabilities_ |
|
private |
◆ nh_
std::shared_ptr<carma_ros2_utils::CarmaLifecycleNode> arbitrator::CapabilitiesInterface::nh_ |
|
private |
◆ registered_strategic_plugins_
std::unordered_map<std::string,carma_ros2_utils::ClientPtr<carma_planning_msgs::srv::PlanManeuvers> > arbitrator::CapabilitiesInterface::registered_strategic_plugins_ |
|
private |
◆ sc_s_
carma_ros2_utils::ClientPtr<carma_planning_msgs::srv::GetPluginApi> arbitrator::CapabilitiesInterface::sc_s_ |
|
private |
◆ STRATEGIC_PLAN_CAPABILITY
const std::string arbitrator::CapabilitiesInterface::STRATEGIC_PLAN_CAPABILITY = "strategic_plan/plan_maneuvers" |
|
static |
The documentation for this class was generated from the following files: