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.
port_drayage_plugin::PortDrayageStateMachine Class Reference

#include <port_drayage_state_machine.hpp>

Collaboration diagram for port_drayage_plugin::PortDrayageStateMachine:
Collaboration graph

Public Member Functions

 PortDrayageStateMachine (rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger)
 Constructor the PortDrayageStateMachine. More...
 
void processEvent (PortDrayageEvent event)
 
PortDrayageState getState () const
 Get the current state of the state machine. More...
 
void setOnSystemStartupCallback (const std::function< void()> &cb)
 Set the callback to be invoked upon transitioning out of the inactive state. More...
 
void setOnReceivedNewDestinationCallback (const std::function< void()> &cb)
 Set the callback to be invoked upon transitioning into the EN_ROUTE state. More...
 
void setOnArrivedAtDestinationCallback (const std::function< void()> &cb)
 Set the callback to be invoked upon transitioning into the AWAITING_DESTINATION state. More...
 
void setOnDrayageCompletedCallback (const std::function< void()> &cb)
 Set the callback to be invoked upon transitioning into the inactive state. More...
 

Private Attributes

PortDrayageState state_
 
std::function< void()> on_system_startup_
 
std::function< void()> on_received_new_destination_
 
std::function< void()> on_arrived_at_destination_
 
std::function< void()> on_drayage_completed_
 
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger_
 

Detailed Description

\Brief An implementation of the state machine for the PortDrayagePlugin.

The state machine accepts events as inputs which drive the internal state changes. This state can be queried at any given point in time, but also each transition into a state has an associated callback which will be invoked when that state is entered.

Definition at line 71 of file port_drayage_state_machine.hpp.

Constructor & Destructor Documentation

◆ PortDrayageStateMachine()

port_drayage_plugin::PortDrayageStateMachine::PortDrayageStateMachine ( rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr  logger)
inline

Constructor the PortDrayageStateMachine.

The system initially starts in INACTIVE state.

Definition at line 89 of file port_drayage_state_machine.hpp.

Member Function Documentation

◆ getState()

PortDrayageState port_drayage_plugin::PortDrayageStateMachine::getState ( ) const

Get the current state of the state machine.

Returns
The current state value

Definition at line 59 of file port_drayage_state_machine.cpp.

59 {
60 return state_;
61 }

References state_.

Referenced by port_drayage_plugin::PortDrayageWorker::composeArrivalMessage(), port_drayage_plugin::PortDrayageWorker::getPortDrayageState(), port_drayage_plugin::PortDrayageWorker::onGuidanceState(), and port_drayage_plugin::PortDrayageWorker::onRouteEvent().

Here is the caller graph for this function:

◆ processEvent()

void port_drayage_plugin::PortDrayageStateMachine::processEvent ( PortDrayageEvent  event)

\Brief Inform the state machine that an event has transpired.

Parameters
eventThe event that took place.

Definition at line 21 of file port_drayage_state_machine.cpp.

21 {
22 switch (state_)
23 {
27 }
28 break;
33 }
35 }
36 break;
41 }
43 }
44 break;
50 }
51 }
52 break;
53 default:
54 RCLCPP_ERROR_STREAM(logger_->get_logger(), "Unhandled port drayage state: " << state_ << "!");
55 throw std::invalid_argument("Unhandled port drayage state");
56 }
57 }

References port_drayage_plugin::ARRIVED_AT_DESTINATION, port_drayage_plugin::AWAITING_DIRECTION, port_drayage_plugin::DRAYAGE_START, port_drayage_plugin::EN_ROUTE_TO_INITIAL_DESTINATION, port_drayage_plugin::EN_ROUTE_TO_RECEIVED_DESTINATION, port_drayage_plugin::INACTIVE, logger_, on_arrived_at_destination_, on_received_new_destination_, port_drayage_plugin::RECEIVED_NEW_DESTINATION, and state_.

Referenced by port_drayage_plugin::PortDrayageWorker::onGuidanceState(), port_drayage_plugin::PortDrayageWorker::onInboundMobilityOperation(), and port_drayage_plugin::PortDrayageWorker::onRouteEvent().

Here is the caller graph for this function:

◆ setOnArrivedAtDestinationCallback()

void port_drayage_plugin::PortDrayageStateMachine::setOnArrivedAtDestinationCallback ( const std::function< void()> &  cb)

Set the callback to be invoked upon transitioning into the AWAITING_DESTINATION state.

Parameters
cbThe std::function callback object

Definition at line 71 of file port_drayage_state_machine.cpp.

71 {
73 }

References on_arrived_at_destination_.

Referenced by port_drayage_plugin::PortDrayageWorker::PortDrayageWorker().

Here is the caller graph for this function:

◆ setOnDrayageCompletedCallback()

void port_drayage_plugin::PortDrayageStateMachine::setOnDrayageCompletedCallback ( const std::function< void()> &  cb)

Set the callback to be invoked upon transitioning into the inactive state.

Parameters
cbThe std::function callback object

Definition at line 75 of file port_drayage_state_machine.cpp.

References on_drayage_completed_.

◆ setOnReceivedNewDestinationCallback()

void port_drayage_plugin::PortDrayageStateMachine::setOnReceivedNewDestinationCallback ( const std::function< void()> &  cb)

Set the callback to be invoked upon transitioning into the EN_ROUTE state.

Parameters
cbThe std::function callback object

Definition at line 67 of file port_drayage_state_machine.cpp.

67 {
69 }

References on_received_new_destination_.

Referenced by port_drayage_plugin::PortDrayageWorker::PortDrayageWorker().

Here is the caller graph for this function:

◆ setOnSystemStartupCallback()

void port_drayage_plugin::PortDrayageStateMachine::setOnSystemStartupCallback ( const std::function< void()> &  cb)

Set the callback to be invoked upon transitioning out of the inactive state.

Parameters
cbThe std::function callback object

Definition at line 63 of file port_drayage_state_machine.cpp.

References on_system_startup_.

Member Data Documentation

◆ logger_

rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr port_drayage_plugin::PortDrayageStateMachine::logger_
private

Definition at line 81 of file port_drayage_state_machine.hpp.

Referenced by processEvent().

◆ on_arrived_at_destination_

std::function<void()> port_drayage_plugin::PortDrayageStateMachine::on_arrived_at_destination_
private

◆ on_drayage_completed_

std::function<void()> port_drayage_plugin::PortDrayageStateMachine::on_drayage_completed_
private

Definition at line 78 of file port_drayage_state_machine.hpp.

Referenced by setOnDrayageCompletedCallback().

◆ on_received_new_destination_

std::function<void()> port_drayage_plugin::PortDrayageStateMachine::on_received_new_destination_
private

◆ on_system_startup_

std::function<void()> port_drayage_plugin::PortDrayageStateMachine::on_system_startup_
private

Definition at line 75 of file port_drayage_state_machine.hpp.

Referenced by setOnSystemStartupCallback().

◆ state_

PortDrayageState port_drayage_plugin::PortDrayageStateMachine::state_
private

Definition at line 74 of file port_drayage_state_machine.hpp.

Referenced by getState(), and processEvent().


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