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.
capabilities_interface.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 LEIDOS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
18#include <carma_planning_msgs/srv/plan_maneuvers.hpp>
19#include <exception>
20#include <sstream>
21
22namespace arbitrator
23{
24 const std::string CapabilitiesInterface::STRATEGIC_PLAN_CAPABILITY = "strategic_plan/plan_maneuvers";
25
26 std::vector<std::string> CapabilitiesInterface::get_topics_for_capability(const std::string& query_string)
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 }
59}
static const std::string STRATEGIC_PLAN_CAPABILITY
std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > nh_
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::GetPluginApi > sc_s_
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 ...