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.
route_state_worker.hpp
Go to the documentation of this file.
1#pragma once
2
3/*
4 * Copyright (C) 2020-2022 LEIDOS.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7 * use this file except in compliance with the License. You may obtain a copy of
8 * the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 * License for the specific language governing permissions and limitations under
16 * the License.
17 */
18
19#include <rclcpp/rclcpp.hpp>
20#include <stdexcept>
21
22namespace route {
23
44 };
45
46 // Stream operator for the RouteEvent enum
47 inline std::ostream &operator<<(std::ostream &output, const RouteEvent &e)
48 {
49 switch(e) {
50 case ROUTE_LOADED:
51 output << "ROUTE_LOADED";
52 break;
53 case ROUTE_SELECTED:
54 output << "ROUTE_SELECTED";
55 break;
56 case ROUTE_STARTED:
57 output << "ROUTE_STARTED";
58 break;
59 case ROUTE_COMPLETED:
60 output << "ROUTE_COMPLETED";
61 break;
62 case ROUTE_DEPARTED:
63 output << "ROUTE_DEPARTED";
64 break;
65 case ROUTE_ABORTED:
66 output << "ROUTE_ABORTED";
67 break;
69 output << "ROUTE_GEN_FAILED";
70 break;
72 output << "ROUTE_INVALIDATION";
73 break;
74 default:
75 output << "UNKNOWN_ROUTE_EVENT(" << static_cast<int>(e) << ")";
76 break;
77 }
78 return output;
79 }
92 };
93
94 // Stream operator for the RouteState enum
95 inline std::ostream &operator<<(std::ostream &output, const RouteState &s)
96 {
97 switch(s) {
98 case LOADING:
99 output << "LOADING";
100 break;
101 case SELECTION:
102 output << "SELECTION";
103 break;
104 case ROUTING:
105 output << "ROUTING";
106 break;
107 case FOLLOWING:
108 output << "FOLLOWING";
109 break;
110 default:
111 output << "UNKNOWN_ROUTE_STATE(" << static_cast<int>(s) << ")";
112 break;
113 }
114 return output;
115 }
116
117
119
120 public:
121
122 RouteStateWorker() = default;
123
128 void onRouteEvent(RouteEvent event);
129
134
135 void setLoggerInterface(rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger);
136
137 private:
138
139 // private local variable tracks the current route satte
141
142 // Logger interface
143 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger_;
144 };
145
146}
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger_
void setLoggerInterface(rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger)
RouteState getRouteState() const
Get current route state machine state.
void onRouteEvent(RouteEvent event)
Process route event based on designed state machine diagram.
std::ostream & operator<<(std::ostream &output, const RouteEvent &e)