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.hpp
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#pragma once
18
19#include <rclcpp/rclcpp.hpp>
20#include <carma_planning_msgs/msg/guidance_state.hpp>
21#include <carma_ros2_utils/carma_lifecycle_node.hpp>
22
23#include <carma_msgs/srv/request_indicator_control.hpp>
24#include <carma_msgs/srv/release_indicator_control.hpp>
25#include <carma_driver_msgs/srv/set_light_bar_indicator.hpp>
26
27namespace lightbar_manager
28{
29
30// Common LightBarManager enumerations and their meanings
36
37// Cooperative Driving Automation message types: A, B, C, D.
38// These message types can be used to set the corresponding indicator specified in ROS param.
40
41// Custom exceptions for lightbar manager
42class LIGHTBAR_MANAGER_ERROR : public std::exception
43{
44 std::string err_;
45public:
46 LIGHTBAR_MANAGER_ERROR(const std::string& err = "LIGHTBAR_MANAGER_ERROR"):err_(err){};
47 char const* what() const throw() {return err_.c_str();};
48};
49
52
54{
55 public:
56
61
65 void next(const LightBarEvent& event);
66
71
76 void handleStateChange(const carma_planning_msgs::msg::GuidanceState& msg);
77
78 private:
79
80 // Helper functions for interpreting guidance state change into lightbar manager event
81 void onDisengage();
82 void onActive();
83 void onEngage();
84
85 // Guidance state local copy for checking any change in state
87
88 // ROS Service
89 carma_ros2_utils::ClientPtr<carma_msgs::srv::ReleaseIndicatorControl> request_control_client_;
90 carma_ros2_utils::ClientPtr<carma_msgs::srv::RequestIndicatorControl> release_control_client_;
91 carma_ros2_utils::ClientPtr<carma_driver_msgs::srv::SetLightBarIndicator> set_indicator_client_;
92
93 // a local variable keeps the current state machine state
95
96};
97
98} //namespace lightbar_manager
LIGHTBAR_MANAGER_ERROR(const std::string &err="LIGHTBAR_MANAGER_ERROR")
LightBarState getCurrentState()
Get current state machine status.
carma_ros2_utils::ClientPtr< carma_driver_msgs::srv::SetLightBarIndicator > set_indicator_client_
carma_ros2_utils::ClientPtr< carma_msgs::srv::RequestIndicatorControl > release_control_client_
carma_ros2_utils::ClientPtr< carma_msgs::srv::ReleaseIndicatorControl > request_control_client_
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.