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.
lightbar_manager_sm.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
18
19namespace lightbar_manager
20{
21// Default constructor
23
24
26{
27 // Set to DISENGAGED state if guidance is disingaged
30
31 return;
32 }
33
34 switch(current_state_)
35 {
36 case DISENGAGED:
39
40 }
41 else if(event == LightBarEvent::GUIDANCE_ENGAGED) {
43
44 }
45 break;
46 case ENGAGED:
49
50 }
51 break;
52 case ACTIVE:
55 }
56 break;
57 default:
58 break;
59 }
60}
61
62void LightBarManagerStateMachine::handleStateChange(const carma_planning_msgs::msg::GuidanceState& msg)
63{
64 // Check if the msg is as same as before
65 if (msg.state == guidance_state_)
66 return;
67
68 switch (msg.state)
69 {
70 case carma_planning_msgs::msg::GuidanceState::STARTUP:
73 break;
74
76 case carma_planning_msgs::msg::GuidanceState::DRIVERS_READY:
78 onActive();
79 break;
80
82 onEngage();
83 break;
84
85 default:
86 RCLCPP_WARN_STREAM(rclcpp::get_logger("lightbar_manager"),"LightBarManager received unknown state from guidance state machine:" << msg.state);
87 break;
88 }
89 // Update the current state
90 guidance_state_ = msg.state;
91}
92
94{
96}
97
99{
100 // Transitioning FROM ENGAGED state to Active
103 // Transitioning FROM all "OFF" states of guidance for lightbar (STARTUP, DRIVERS_READY, INACTIVE, OFF)
104 else
106}
107
109{
111}
112
113
115{
116 return current_state_;
117}
118
119} // namespace lightbar_manager
LightBarState getCurrentState()
Get current state machine status.
void next(const LightBarEvent &event)
Transition to the next state of the LightBarStateMachine.
void handleStateChange(const carma_planning_msgs::msg::GuidanceState &msg)
This function triggers the transitioning to the next state in LightBarStateMachine based on the guida...
LightBarManagerStateMachine()
Default constructor for LightBarManagerStateMachine.