Avionics
Core avionics package for CURE flight computers
Loading...
Searching...
No Matches
StateMachine Class Reference

Nominal flight state machine using launch/apogee detection and VVE. More...

#include <StateMachine.h>

Inheritance diagram for StateMachine:
Inheritance graph
Collaboration diagram for StateMachine:
Collaboration graph

Public Member Functions

 StateMachine (IDataSaver *dataSaver, LaunchDetector *launchDetector, ApogeeDetector *apogeeDetector, VerticalVelocityEstimator *verticalVelocityEstimator, FastLaunchDetector *fastLaunchDetector)
 Wire dependencies for the state machine.
int update (const AccelerationTriplet &accel, const DataPoint &alt) override
 Process new sensor data and transition states if thresholds are met.
Public Member Functions inherited from BaseStateMachine
 BaseStateMachine (FlightState initialState=STATE_UNARMED)
virtual ~BaseStateMachine ()=default
virtual uint8_t getState () const
 Current discrete state identifier.
bool registerOnStateEntry (FlightState targetState, StateEntryCallback functionPtr)
 Register a callback to invoke each time a target state is entered.

Additional Inherited Members

Public Types inherited from BaseStateMachine
using StateEntryCallback = void (*)()
Static Public Member Functions inherited from BaseStateMachine
static constexpr std::size_t getMaxStateEntryCallbacks ()
Static Public Attributes inherited from BaseStateMachine
static constexpr std::size_t kMaxStateEntryCallbacks = 32
Protected Member Functions inherited from BaseStateMachine
bool changeState (FlightState newState)
 Transition to a new state and trigger registered on-entry callbacks.
FlightState getFlightState () const
 Current state as FlightState enum.

Detailed Description

Nominal flight state machine using launch/apogee detection and VVE.

Note
When to use: standard flights where launch->coast->descent transitions are driven by detectors and logging is desired at each change.

Definition at line 18 of file StateMachine.h.

Constructor & Destructor Documentation

◆ StateMachine()

StateMachine::StateMachine ( IDataSaver * dataSaver,
LaunchDetector * launchDetector,
ApogeeDetector * apogeeDetector,
VerticalVelocityEstimator * verticalVelocityEstimator,
FastLaunchDetector * fastLaunchDetector )

Wire dependencies for the state machine.

Parameters
dataSaverLogger used to persist state changes.
launchDetectorLaunch detector instance.
apogeeDetectorApogee detector instance.
verticalVelocityEstimatorVertical velocity estimator instance.
Note
When to use: build once during setup with already configured estimator/detector instances.

Definition at line 8 of file StateMachine.cpp.

Member Function Documentation

◆ update()

int StateMachine::update ( const AccelerationTriplet & accel,
const DataPoint & alt )
overridevirtual

Process new sensor data and transition states if thresholds are met.

Parameters
accelLatest acceleration measurements.
altLatest altitude sample.
Note
When to use: call on every control loop iteration.

Implements BaseStateMachine.

Definition at line 22 of file StateMachine.cpp.


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