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_utils.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
17#include "arbitrator_utils.hpp"
18#include <carma_planning_msgs/msg/maneuver.hpp>
19#include <exception>
20
21
22namespace arbitrator_utils
23{
24 rclcpp::Time get_plan_end_time(const carma_planning_msgs::msg::ManeuverPlan &plan)
25 {
26 if (plan.maneuvers.empty())
27 {
28 throw std::invalid_argument("arbitrator::get_plan_end_time called on empty maneuver plan");
29 }
30
31 carma_planning_msgs::msg::Maneuver m = plan.maneuvers.back();
32
33 return get_maneuver_end_time(m);
34 }
35
36 double get_plan_end_distance(const carma_planning_msgs::msg::ManeuverPlan &plan)
37 {
38 if (plan.maneuvers.empty())
39 {
40 throw std::invalid_argument("arbitrator::get_plan_end_dist called on empty maneuver plan");
41 }
42
43 carma_planning_msgs::msg::Maneuver m = plan.maneuvers.back();
45 }
46
47 rclcpp::Time get_plan_start_time(const carma_planning_msgs::msg::ManeuverPlan &plan)
48 {
49 if (plan.maneuvers.empty())
50 {
51 throw std::invalid_argument("arbitrator::get_plan_start_time called on empty maneuver plan");
52 }
53
54 carma_planning_msgs::msg::Maneuver m = plan.maneuvers.front();
56 }
57
58 double get_plan_start_distance(const carma_planning_msgs::msg::ManeuverPlan &plan)
59 {
60 if (plan.maneuvers.empty())
61 {
62 throw std::invalid_argument("arbitrator::get_plan_start_dist called on empty maneuver plan");
63 }
64
65 carma_planning_msgs::msg::Maneuver m = plan.maneuvers.front();
67 }
68
69 rclcpp::Time get_maneuver_end_time(const carma_planning_msgs::msg::Maneuver &mvr)
70 {
71 return GET_MANEUVER_PROPERTY(mvr, end_time);
72 }
73
74 rclcpp::Time get_maneuver_start_time(const carma_planning_msgs::msg::Maneuver &mvr)
75 {
76 return GET_MANEUVER_PROPERTY(mvr, start_time);
77 }
78
79 double get_maneuver_end_distance(const carma_planning_msgs::msg::Maneuver &mvr)
80 {
81 return GET_MANEUVER_PROPERTY(mvr, end_dist);
82 }
83
84 double get_maneuver_start_distance(const carma_planning_msgs::msg::Maneuver &mvr)
85 {
86 return GET_MANEUVER_PROPERTY(mvr, start_dist);
87 }
88} // namespace arbitrator_utils
#define GET_MANEUVER_PROPERTY(mvr, property)
Macro definition to enable easier access to fields shared across the maneuver types.
rclcpp::Time get_plan_start_time(const carma_planning_msgs::msg::ManeuverPlan &)
Get the start time of the first maneuver in the plan.
rclcpp::Time get_maneuver_end_time(const carma_planning_msgs::msg::Maneuver &)
Get the end time of the specified maneuver.
double get_maneuver_start_distance(const carma_planning_msgs::msg::Maneuver &)
Get the start distance the specified maneuver.
double get_maneuver_end_distance(const carma_planning_msgs::msg::Maneuver &)
Get the end distance of the specified maneuver.
rclcpp::Time get_plan_end_time(const carma_planning_msgs::msg::ManeuverPlan &)
Get the end time of the first maneuver in the plan.
double get_plan_end_distance(const carma_planning_msgs::msg::ManeuverPlan &)
Get the end distance of the first maneuver in the plan.
rclcpp::Time get_maneuver_start_time(const carma_planning_msgs::msg::Maneuver &)
Get the start time of the specified maneuver.
double get_plan_start_distance(const carma_planning_msgs::msg::ManeuverPlan &)
Get the start distance of the first maneuver in the plan.