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.
lci_strategic_plugin::LCIStrategicStateTransitionTable Class Reference

Class defining the state transition table behavior for the LCIStrategic Strategic Plugin. More...

#include <lci_state_transition_table.hpp>

Collaboration diagram for lci_strategic_plugin::LCIStrategicStateTransitionTable:
Collaboration graph

Public Types

using TransitionCallback = std::function< void(TransitState prev_state, TransitState new_state, TransitEvent signal)>
 

Public Member Functions

 LCIStrategicStateTransitionTable ()=default
 Default Constructor. More...
 
TransitState getState () const
 Returns the current state. More...
 
void signal (TransitEvent signal)
 Trigger signal for the transition table. More...
 
void setTransitionCallback (TransitionCallback cb)
 Callback setting function. The provided callback will be triggered any time the current state changes to a new state. More...
 

Private Member Functions

void signalWhenUNAVAILABLE (TransitEvent signal)
 
void signalWhenAPPROACHING (TransitEvent signal)
 
void signalWhenWAITING (TransitEvent signal)
 
void signalWhenDEPARTING (TransitEvent signal)
 
void logDebugSignal (TransitEvent signal) const
 Helper function for logging the provide signal. More...
 
void setAndLogState (TransitState new_state, TransitEvent source_signal)
 Function to change the current state and log the details of the transition. More...
 

Private Attributes

TransitState state_ = TransitState::UNAVAILABLE
 Current state. This state should only ever be set using the setAndLogState() function. More...
 
TransitionCallback transition_callback_
 

Detailed Description

Class defining the state transition table behavior for the LCIStrategic Strategic Plugin.

Definition at line 25 of file lci_state_transition_table.hpp.

Member Typedef Documentation

◆ TransitionCallback

Constructor & Destructor Documentation

◆ LCIStrategicStateTransitionTable()

lci_strategic_plugin::LCIStrategicStateTransitionTable::LCIStrategicStateTransitionTable ( )
default

Default Constructor.

Member Function Documentation

◆ getState()

TransitState lci_strategic_plugin::LCIStrategicStateTransitionTable::getState ( ) const

Returns the current state.

Returns
Current state

Definition at line 29 of file lci_state_transition_table.cpp.

30{
31 return state_;
32}
TransitState state_
Current state. This state should only ever be set using the setAndLogState() function.

References state_.

Referenced by lci_strategic_plugin::LCIStrategicPlugin::plan_maneuvers_callback().

Here is the caller graph for this function:

◆ logDebugSignal()

void lci_strategic_plugin::LCIStrategicStateTransitionTable::logDebugSignal ( TransitEvent  signal) const
private

Helper function for logging the provide signal.

Parameters
signalThe signal to be logged

Definition at line 118 of file lci_state_transition_table.cpp.

119{
120 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("lci_strategic_plugin"), "LCIStrategicStateTransitionTable received unsupported signal of " << signal << " while in state "
121 << state_);
122}
void signal(TransitEvent signal)
Trigger signal for the transition table.

References signal(), and state_.

Referenced by signalWhenAPPROACHING(), signalWhenDEPARTING(), signalWhenUNAVAILABLE(), and signalWhenWAITING().

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

◆ setAndLogState()

void lci_strategic_plugin::LCIStrategicStateTransitionTable::setAndLogState ( TransitState  new_state,
TransitEvent  source_signal 
)
private

Function to change the current state and log the details of the transition.

Parameters
new_stateThe state to set.
source_signalThe signal which caused the new_state to be set

Definition at line 124 of file lci_state_transition_table.cpp.

125{
126 if (new_state == state_)
127 {
128 return; // State was unchanged no need to log or trigger callbacks
129 }
130
131 RCLCPP_INFO_STREAM(rclcpp::get_logger("lci_strategic_plugin"), "LCIStrategicStateTransitionTable changed LCIStrategic Strategic Plugin state from "
132 << state_ << " to " << new_state << " because of signal " << source_signal);
133
134 TransitState prev_state = state_;
135 state_ = new_state; // Set new state
136
137 if (transition_callback_) // Trigger callback if available
138 {
139 transition_callback_(prev_state, state_, source_signal);
140 }
141}
TransitState
Enum describing the possible states of the LCIStrategic Strategic Plugin.
Definition: lci_states.hpp:25

References state_, and transition_callback_.

Referenced by signalWhenAPPROACHING(), signalWhenDEPARTING(), signalWhenUNAVAILABLE(), and signalWhenWAITING().

Here is the caller graph for this function:

◆ setTransitionCallback()

void lci_strategic_plugin::LCIStrategicStateTransitionTable::setTransitionCallback ( TransitionCallback  cb)

Callback setting function. The provided callback will be triggered any time the current state changes to a new state.

Parameters
cbThe callback function which will be provided with the previous state, new current state, and the signal which caused the transition.

Definition at line 59 of file lci_state_transition_table.cpp.

60{
62}

References transition_callback_.

◆ signal()

void lci_strategic_plugin::LCIStrategicStateTransitionTable::signal ( TransitEvent  signal)

Trigger signal for the transition table.

Parameters
signalThe signal for the transition table to evaluate

Definition at line 34 of file lci_state_transition_table.cpp.

References lci_strategic_plugin::APPROACHING, lci_strategic_plugin::DEPARTING, signal(), signalWhenAPPROACHING(), signalWhenDEPARTING(), signalWhenUNAVAILABLE(), signalWhenWAITING(), state_, lci_strategic_plugin::UNAVAILABLE, and lci_strategic_plugin::WAITING.

Referenced by logDebugSignal(), lci_strategic_plugin::LCIStrategicPlugin::planWhenAPPROACHING(), lci_strategic_plugin::LCIStrategicPlugin::planWhenDEPARTING(), lci_strategic_plugin::LCIStrategicPlugin::planWhenUNAVAILABLE(), lci_strategic_plugin::LCIStrategicPlugin::planWhenWAITING(), signal(), signalWhenAPPROACHING(), signalWhenDEPARTING(), signalWhenUNAVAILABLE(), and signalWhenWAITING().

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

◆ signalWhenAPPROACHING()

void lci_strategic_plugin::LCIStrategicStateTransitionTable::signalWhenAPPROACHING ( TransitEvent  signal)
private

Definition at line 76 of file lci_state_transition_table.cpp.

77{
78 switch (signal)
79 {
82 break;
83
86 break;
87
88 default:
90 break;
91 }
92}
void logDebugSignal(TransitEvent signal) const
Helper function for logging the provide signal.
void setAndLogState(TransitState new_state, TransitEvent source_signal)
Function to change the current state and log the details of the transition.

References lci_strategic_plugin::CROSSED_STOP_BAR, lci_strategic_plugin::DEPARTING, logDebugSignal(), setAndLogState(), signal(), lci_strategic_plugin::STOPPED, and lci_strategic_plugin::WAITING.

Referenced by signal().

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

◆ signalWhenDEPARTING()

void lci_strategic_plugin::LCIStrategicStateTransitionTable::signalWhenDEPARTING ( TransitEvent  signal)
private

Definition at line 106 of file lci_state_transition_table.cpp.

References lci_strategic_plugin::INTERSECTION_EXIT, logDebugSignal(), setAndLogState(), signal(), and lci_strategic_plugin::UNAVAILABLE.

Referenced by signal().

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

◆ signalWhenUNAVAILABLE()

void lci_strategic_plugin::LCIStrategicStateTransitionTable::signalWhenUNAVAILABLE ( TransitEvent  signal)
private

Definition at line 64 of file lci_state_transition_table.cpp.

References lci_strategic_plugin::APPROACHING, lci_strategic_plugin::IN_STOPPING_RANGE, logDebugSignal(), setAndLogState(), and signal().

Referenced by signal().

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

◆ signalWhenWAITING()

void lci_strategic_plugin::LCIStrategicStateTransitionTable::signalWhenWAITING ( TransitEvent  signal)
private

Definition at line 94 of file lci_state_transition_table.cpp.

References lci_strategic_plugin::DEPARTING, logDebugSignal(), lci_strategic_plugin::RED_TO_GREEN_LIGHT, setAndLogState(), and signal().

Referenced by signal().

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

Member Data Documentation

◆ state_

TransitState lci_strategic_plugin::LCIStrategicStateTransitionTable::state_ = TransitState::UNAVAILABLE
private

Current state. This state should only ever be set using the setAndLogState() function.

Definition at line 59 of file lci_state_transition_table.hpp.

Referenced by getState(), logDebugSignal(), setAndLogState(), and signal().

◆ transition_callback_

TransitionCallback lci_strategic_plugin::LCIStrategicStateTransitionTable::transition_callback_
private

Definition at line 61 of file lci_state_transition_table.hpp.

Referenced by setAndLogState(), and setTransitionCallback().


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