Class PlatformStateMachine

Class Documentation

class PlatformStateMachine

This class implements the Platform State Machine, which is in charge of handling the state of the platform using a FSM (Finite State Machine). This state machine consist on 6 states:

  • DISARMED -> The platform is not armed.

  • LANDED -> The platform is armed and landed.

  • TAKING_OFF -> The platform is taking off.

  • FLYING -> The platform is on air.

  • LANDING -> The platform is landing.

  • EMERGENCY -> The platform is in emergency mode.

The events that can trigger the state machine are:

  • ARM

  • DISARM

  • TAKE_OFF

  • TOOK_OFF

  • LAND

  • LANDED

  • EMERGENCY TODO(miferco97): add figure of the state machine ../_images/test.jpg

Public Functions

explicit PlatformStateMachine(as2::Node *node)

Constructor of the Platform State Machine.

Parameters:

node_ptr – Pointer to an aerostack2 node.

~PlatformStateMachine()
bool processEvent(const int8_t &event)

This function is in charge of handling the state machine.

Parameters:

event – The event that triggers the state machine.

Returns:

true If the event is valid in current State.

bool processEvent(const Event &event)

This function is in charge of handling the state machine.

Parameters:

event – The event that triggers the state machine.

Returns:

true If the event is valid in current State.

StateMachineTransition getTransition(const int8_t &current_state, const int8_t &event)

Get the Transition object.

Parameters:
  • current_state

  • event

Returns:

StateMachineTransition

inline as2_msgs::msg::PlatformStatus getState()

This function returns the current state of the state machine.

Returns:

The current Platform Status of the state machine

inline void setState(as2_msgs::msg::PlatformStatus state)

Set the State of the FSM to the desired state. (THIS MAY BE USED ONLY FOR TESTING PURPOSES)

Parameters:

state

inline void setState(const int8_t &state)