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.
itm_service.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 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 */
17
19#include <rclcpp/rclcpp.hpp>
20#include <vector>
21#include <carma_planning_msgs/msg/trajectory_plan.hpp>
22#include <carma_planning_msgs/msg/trajectory_plan_point.hpp>
23#include <carma_planning_msgs/msg/plugin.hpp>
24#include <carma_planning_msgs/msg/maneuver.hpp>
25#include <boost/shared_ptr.hpp>
26#include <carma_ros2_utils/carma_lifecycle_node.hpp>
27#include <boost/geometry.hpp>
28#include <carma_planning_msgs/srv/plan_trajectory.hpp>
29
31{
32
34
35 void Servicer::call(carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr req, carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr& resp)
36 {
37 std::shared_future<carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr> resp_future = client->async_send_request(req);
38
39 auto future_status = resp_future.wait_for(std::chrono::milliseconds(500));
40
41 if (future_status == std::future_status::ready) {
42 resp = resp_future.get();
43
44 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("intersection_transit_maneuvering"), "Responsible tactical plugin was called and got trajectory size: " << resp->trajectory_plan.trajectory_points.size());
45 }
46 else
47 {
48 RCLCPP_DEBUG(rclcpp::get_logger("intersection_transit_maneuvering"), "Failed to call the responsible tactical plugin from intersection_transit_maneuvering");
49 }
50 return;
51
52 }
53
54
55 void Servicer::set_client( carma_ros2_utils::ClientPtr<carma_planning_msgs::srv::PlanTrajectory> srv_client)
56 {
57 client = srv_client;
58 }
59}
void call(carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr req, carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr &resp)
Method that uses the ros::Service::call() definition as specified in the ROS API.
Definition: itm_service.cpp:35
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > client
Definition: itm_service.hpp:58
Servicer()
Construct a new Servicer object.
Definition: itm_service.cpp:33
void set_client(carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > srv_client)
set the trajectory service client
Definition: itm_service.cpp:55