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.
approaching_emergency_vehicle_transition_table.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022-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
18
20{
21
23{
24 return state_;
25}
26
28{
29 switch (state_)
30 {
33 break;
34
37 break;
38
41 break;
42
43 default:
44 throw std::invalid_argument("Transition table in unsupported state");
45 }
46}
47
49{
51}
52
54{
55 switch (event)
56 {
59 break;
60
63 break;
64
67 break;
68
71 break;
72
73 default:
75 break;
76 }
77}
78
80{
81 switch (event)
82 {
85 break;
86
89 break;
90
93 break;
94
97 break;
98
101 break;
102
103 default:
105 break;
106 }
107}
108
110{
111 switch (event)
112 {
115 break;
116
119 break;
120
123 break;
124
127 break;
128
131 break;
132
135 break;
136
137 default:
139 break;
140 }
141}
142
144{
145 RCLCPP_INFO_STREAM(rclcpp::get_logger("approaching_emergency_vehicle_plugin"), "ApproachingEmergencyVehicleTransitionTable received unsupported event of " << event << " while in state "
146 << state_);
147}
148
150{
151 if (new_state == state_)
152 {
153 return; // State was unchanged no need to log or trigger callbacks
154 }
155
156 RCLCPP_INFO_STREAM(rclcpp::get_logger("approaching_emergency_vehicle_plugin"), "ApproachingEmergencyVehicleTransitionTable changed ApproachingEmergencyVehicle Strategic Plugin state from "
157 << state_ << " to " << new_state << " because of event " << source_event);
158
160 state_ = new_state; // Set new state
161
162 if (transition_callback_) // Trigger callback if available
163 {
164 transition_callback_(prev_state, state_, source_event);
165 }
166}
167
168} // namespace approaching_emergency_vehicle_plugin
void logDebugEvent(ApproachingEmergencyVehicleEvent event) const
Helper function for logging the provide event.
void setAndLogState(ApproachingEmergencyVehicleState new_state, ApproachingEmergencyVehicleEvent source_event)
Function to change the current state and log the details of the transition.
void event(ApproachingEmergencyVehicleEvent event)
Trigger event for the transition table.
ApproachingEmergencyVehicleState state_
Current state. This state should only ever be set using the setAndLogState() function.
void setTransitionCallback(TransitionCallback cb)
Callback setting function. The provided callback will be triggered any time the current state changes...
std::function< void(ApproachingEmergencyVehicleState prev_state, ApproachingEmergencyVehicleState new_state, ApproachingEmergencyVehicleEvent event)> TransitionCallback
ApproachingEmergencyVehicleEvent
Enum describing the possible signals to change the current ApproachingEmergencyVehicleState.
ApproachingEmergencyVehicleState
Enum describing the possible states of the ApproachingEmergencyVehiclePlugin (Strategic Plugin)