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_plugin::ApproachingEmergencyVehicleTransitionTable Class Reference

Class defining the state transition table behavior for the ApproachingEmergencyVehiclePlugin. More...

#include <approaching_emergency_vehicle_transition_table.hpp>

Collaboration diagram for approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable:
Collaboration graph

Public Types

using TransitionCallback = std::function< void(ApproachingEmergencyVehicleState prev_state, ApproachingEmergencyVehicleState new_state, ApproachingEmergencyVehicleEvent event)>
 

Public Member Functions

 ApproachingEmergencyVehicleTransitionTable ()=default
 ApproachingEmergencyVehicleTransitionTable Constructor. More...
 
ApproachingEmergencyVehicleState getState () const
 Returns the current state. More...
 
void event (ApproachingEmergencyVehicleEvent event)
 Trigger event 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 eventWhenNO_APPROACHING_ERV (ApproachingEmergencyVehicleEvent event)
 
void eventWhenMOVING_OVER_FOR_APPROACHING_ERV (ApproachingEmergencyVehicleEvent event)
 
void eventWhenSLOWING_DOWN_FOR_ERV (ApproachingEmergencyVehicleEvent event)
 
void logDebugEvent (ApproachingEmergencyVehicleEvent event) const
 Helper function for logging the provide event. More...
 
void setAndLogState (ApproachingEmergencyVehicleState new_state, ApproachingEmergencyVehicleEvent source_event)
 Function to change the current state and log the details of the transition. More...
 

Private Attributes

ApproachingEmergencyVehicleState state_ = ApproachingEmergencyVehicleState::NO_APPROACHING_ERV
 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 ApproachingEmergencyVehiclePlugin.

Definition at line 28 of file approaching_emergency_vehicle_transition_table.hpp.

Member Typedef Documentation

◆ TransitionCallback

Constructor & Destructor Documentation

◆ ApproachingEmergencyVehicleTransitionTable()

approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable::ApproachingEmergencyVehicleTransitionTable ( )
default

ApproachingEmergencyVehicleTransitionTable Constructor.

Parameters
modeDefines the operational mode of the state machine which modifies some of the state transitions

Member Function Documentation

◆ event()

void approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable::event ( ApproachingEmergencyVehicleEvent  event)

Trigger event for the transition table.

Parameters
eventThe event for the transition table to evaluate

Definition at line 27 of file approaching_emergency_vehicle_transition_table.cpp.

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}
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.

References event(), eventWhenMOVING_OVER_FOR_APPROACHING_ERV(), eventWhenNO_APPROACHING_ERV(), eventWhenSLOWING_DOWN_FOR_ERV(), approaching_emergency_vehicle_plugin::MOVING_OVER_FOR_APPROACHING_ERV, approaching_emergency_vehicle_plugin::NO_APPROACHING_ERV, approaching_emergency_vehicle_plugin::SLOWING_DOWN_FOR_ERV, and state_.

Referenced by approaching_emergency_vehicle_plugin::ApproachingEmergencyVehiclePlugin::checkForErvTimeout(), event(), eventWhenMOVING_OVER_FOR_APPROACHING_ERV(), eventWhenNO_APPROACHING_ERV(), eventWhenSLOWING_DOWN_FOR_ERV(), approaching_emergency_vehicle_plugin::ApproachingEmergencyVehiclePlugin::getSecondsUntilPassing(), approaching_emergency_vehicle_plugin::ApproachingEmergencyVehiclePlugin::incomingBsmCallback(), logDebugEvent(), and approaching_emergency_vehicle_plugin::ApproachingEmergencyVehiclePlugin::plan_maneuvers_callback().

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

◆ eventWhenMOVING_OVER_FOR_APPROACHING_ERV()

void approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable::eventWhenMOVING_OVER_FOR_APPROACHING_ERV ( ApproachingEmergencyVehicleEvent  event)
private

Definition at line 79 of file approaching_emergency_vehicle_transition_table.cpp.

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}
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.

References approaching_emergency_vehicle_plugin::APPROACHING_ERV_IN_PATH, approaching_emergency_vehicle_plugin::APPROACHING_ERV_NOT_IN_PATH, approaching_emergency_vehicle_plugin::ERV_PASSING_IN_PATH, approaching_emergency_vehicle_plugin::ERV_UPDATE_TIMEOUT, event(), logDebugEvent(), approaching_emergency_vehicle_plugin::MOVING_OVER_FOR_APPROACHING_ERV, approaching_emergency_vehicle_plugin::NO_APPROACHING_ERV, setAndLogState(), and approaching_emergency_vehicle_plugin::SLOWING_DOWN_FOR_ERV.

Referenced by event().

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

◆ eventWhenNO_APPROACHING_ERV()

void approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable::eventWhenNO_APPROACHING_ERV ( ApproachingEmergencyVehicleEvent  event)
private

◆ eventWhenSLOWING_DOWN_FOR_ERV()

void approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable::eventWhenSLOWING_DOWN_FOR_ERV ( ApproachingEmergencyVehicleEvent  event)
private

Definition at line 109 of file approaching_emergency_vehicle_transition_table.cpp.

References approaching_emergency_vehicle_plugin::APPROACHING_ERV_IN_PATH, approaching_emergency_vehicle_plugin::APPROACHING_ERV_NOT_IN_PATH, approaching_emergency_vehicle_plugin::ERV_PASSED, approaching_emergency_vehicle_plugin::ERV_PASSING_IN_PATH, approaching_emergency_vehicle_plugin::ERV_UPDATE_TIMEOUT, event(), logDebugEvent(), approaching_emergency_vehicle_plugin::MOVING_OVER_FOR_APPROACHING_ERV, approaching_emergency_vehicle_plugin::NO_APPROACHING_ERV, setAndLogState(), and approaching_emergency_vehicle_plugin::SLOWING_DOWN_FOR_ERV.

Referenced by event().

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

◆ getState()

◆ logDebugEvent()

void approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable::logDebugEvent ( ApproachingEmergencyVehicleEvent  event) const
private

Helper function for logging the provide event.

Parameters
eventThe event to be logged

Definition at line 143 of file approaching_emergency_vehicle_transition_table.cpp.

144{
145 RCLCPP_INFO_STREAM(rclcpp::get_logger("approaching_emergency_vehicle_plugin"), "ApproachingEmergencyVehicleTransitionTable received unsupported event of " << event << " while in state "
146 << state_);
147}

References event(), and state_.

Referenced by eventWhenMOVING_OVER_FOR_APPROACHING_ERV(), eventWhenNO_APPROACHING_ERV(), and eventWhenSLOWING_DOWN_FOR_ERV().

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

◆ setAndLogState()

void approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable::setAndLogState ( ApproachingEmergencyVehicleState  new_state,
ApproachingEmergencyVehicleEvent  source_event 
)
private

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

Parameters
new_stateThe state to set.
source_eventThe event which caused the new_state to be set

Definition at line 149 of file approaching_emergency_vehicle_transition_table.cpp.

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}
ApproachingEmergencyVehicleState
Enum describing the possible states of the ApproachingEmergencyVehiclePlugin (Strategic Plugin)

References state_, and transition_callback_.

Referenced by eventWhenMOVING_OVER_FOR_APPROACHING_ERV(), eventWhenNO_APPROACHING_ERV(), and eventWhenSLOWING_DOWN_FOR_ERV().

Here is the caller graph for this function:

◆ setTransitionCallback()

void approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable::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 event which caused the transition.

Definition at line 48 of file approaching_emergency_vehicle_transition_table.cpp.

49{
51}

References transition_callback_.

Member Data Documentation

◆ state_

ApproachingEmergencyVehicleState approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable::state_ = ApproachingEmergencyVehicleState::NO_APPROACHING_ERV
private

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

Definition at line 65 of file approaching_emergency_vehicle_transition_table.hpp.

Referenced by event(), getState(), logDebugEvent(), and setAndLogState().

◆ transition_callback_

TransitionCallback approaching_emergency_vehicle_plugin::ApproachingEmergencyVehicleTransitionTable::transition_callback_
private

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