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::LightBarManagerStateMachine Class Reference

#include <lightbar_manager_sm.hpp>

Collaboration diagram for lightbar_manager::LightBarManagerStateMachine:
Collaboration graph

Public Member Functions

 LightBarManagerStateMachine ()
 Default constructor for LightBarManagerStateMachine. More...
 
void next (const LightBarEvent &event)
 Transition to the next state of the LightBarStateMachine. More...
 
LightBarState getCurrentState ()
 Get current state machine status. More...
 
void handleStateChange (const carma_planning_msgs::msg::GuidanceState &msg)
 This function triggers the transitioning to the next state in LightBarStateMachine based on the guidance state change. More...
 

Private Member Functions

void onDisengage ()
 
void onActive ()
 
void onEngage ()
 

Private Attributes

uint8_t guidance_state_ = carma_planning_msgs::msg::GuidanceState::SHUTDOWN
 
carma_ros2_utils::ClientPtr< carma_msgs::srv::ReleaseIndicatorControl > request_control_client_
 
carma_ros2_utils::ClientPtr< carma_msgs::srv::RequestIndicatorControl > release_control_client_
 
carma_ros2_utils::ClientPtr< carma_driver_msgs::srv::SetLightBarIndicator > set_indicator_client_
 
LightBarState current_state_ = DISENGAGED
 

Detailed Description

Definition at line 53 of file lightbar_manager_sm.hpp.

Constructor & Destructor Documentation

◆ LightBarManagerStateMachine()

lightbar_manager::LightBarManagerStateMachine::LightBarManagerStateMachine ( )

Default constructor for LightBarManagerStateMachine.

Definition at line 22 of file lightbar_manager_sm.cpp.

22{}

Member Function Documentation

◆ getCurrentState()

LightBarState lightbar_manager::LightBarManagerStateMachine::getCurrentState ( )

Get current state machine status.

Definition at line 114 of file lightbar_manager_sm.cpp.

References current_state_.

Referenced by lightbar_manager::LightBarManagerWorker::getCurrentState().

Here is the caller graph for this function:

◆ handleStateChange()

void lightbar_manager::LightBarManagerStateMachine::handleStateChange ( const carma_planning_msgs::msg::GuidanceState &  msg)

This function triggers the transitioning to the next state in LightBarStateMachine based on the guidance state change.

Definition at line 62 of file lightbar_manager_sm.cpp.

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}

References lightbar_manager::ACTIVE, lightbar_manager::ENGAGED, guidance_state_, port_drayage_plugin::INACTIVE, onActive(), onDisengage(), onEngage(), and arbitrator::SHUTDOWN.

Referenced by lightbar_manager::LightBarManagerWorker::handleStateChange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ next()

void lightbar_manager::LightBarManagerStateMachine::next ( const LightBarEvent event)

Transition to the next state of the LightBarStateMachine.

Definition at line 25 of file lightbar_manager_sm.cpp.

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}

References lightbar_manager::ACTIVE, current_state_, lightbar_manager::DISENGAGED, lightbar_manager::ENGAGED, lightbar_manager::GUIDANCE_CONNECTED, lightbar_manager::GUIDANCE_DISCONNECTED, lightbar_manager::GUIDANCE_DISENGAGED, and lightbar_manager::GUIDANCE_ENGAGED.

Referenced by lightbar_manager::LightBarManagerWorker::next(), onActive(), onDisengage(), and onEngage().

Here is the caller graph for this function:

◆ onActive()

void lightbar_manager::LightBarManagerStateMachine::onActive ( )
private

Definition at line 98 of file lightbar_manager_sm.cpp.

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}
void next(const LightBarEvent &event)
Transition to the next state of the LightBarStateMachine.

References lightbar_manager::ENGAGED, lightbar_manager::GUIDANCE_CONNECTED, lightbar_manager::GUIDANCE_DISCONNECTED, guidance_state_, and next().

Referenced by handleStateChange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onDisengage()

void lightbar_manager::LightBarManagerStateMachine::onDisengage ( )
private

Definition at line 93 of file lightbar_manager_sm.cpp.

94{
96}

References lightbar_manager::GUIDANCE_DISENGAGED, and next().

Referenced by handleStateChange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onEngage()

void lightbar_manager::LightBarManagerStateMachine::onEngage ( )
private

Definition at line 108 of file lightbar_manager_sm.cpp.

109{
111}

References lightbar_manager::GUIDANCE_ENGAGED, and next().

Referenced by handleStateChange().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ current_state_

LightBarState lightbar_manager::LightBarManagerStateMachine::current_state_ = DISENGAGED
private

Definition at line 94 of file lightbar_manager_sm.hpp.

Referenced by getCurrentState(), and next().

◆ guidance_state_

uint8_t lightbar_manager::LightBarManagerStateMachine::guidance_state_ = carma_planning_msgs::msg::GuidanceState::SHUTDOWN
private

Definition at line 86 of file lightbar_manager_sm.hpp.

Referenced by handleStateChange(), and onActive().

◆ release_control_client_

carma_ros2_utils::ClientPtr<carma_msgs::srv::RequestIndicatorControl> lightbar_manager::LightBarManagerStateMachine::release_control_client_
private

Definition at line 90 of file lightbar_manager_sm.hpp.

◆ request_control_client_

carma_ros2_utils::ClientPtr<carma_msgs::srv::ReleaseIndicatorControl> lightbar_manager::LightBarManagerStateMachine::request_control_client_
private

Definition at line 89 of file lightbar_manager_sm.hpp.

◆ set_indicator_client_

carma_ros2_utils::ClientPtr<carma_driver_msgs::srv::SetLightBarIndicator> lightbar_manager::LightBarManagerStateMachine::set_indicator_client_
private

Definition at line 91 of file lightbar_manager_sm.hpp.


The documentation for this class was generated from the following files: