HFSM

Contains all of the states and the root pointer for the state machine library used in this project. This project has no executables. See MainDriver to see how to implement HFSM library.

Root

Contains all common variables and functions accessible to every state in the state machine. It is important to note that we have some variables for display mode, DO NOT RUN DISPLAY MODE, IT DOESN’T WORK

class Root
#include <Root.h>

Contains all common variables and functions accessible to every state in the state machine.

Public Functions

Root()

Construct a new Root object.

Root(bool is_unit_fsm)

Construct a new Root object.

Parameters:

is_unit_fsm – Boolean indicating if it is in display mode (normally false)

~Root()

Destroy the Root object.

void addState(State *the_state)

Will add a state to the state machine.

Parameters:

the_state – The state being added to the state machine

double getCurrentTime()

Get the current time in ms.

Returns:

double representing the current time

float angleToPulseWidth(double pulse_max, double pulse_min, double range, float angle)

Converts servo angle to pulse width through linear interpolation.

Parameters:
  • pulse_max – Maximum pulse width

  • pulse_min – Minimum pulse width

  • range – Angle range of the servo

  • angle – Desired angle to move the servo

Returns:

float representing the appropriate pulse width

float pressure2Altitude(float t0, float p0, float g0, float p)

Finds altitude based on pressure.

Parameters:
  • t0 – Baseline temperature in Kelvin

  • p0 – Baseline pressure in kPa

  • g0 – Baseline gravity in m/s^2

  • p – Current pressure in kPa

Returns:

float representing the current altitude above ground level in m

float calcArrayAverage(float array[], int size)

Calculates average of all array values.

Parameters:
  • array – Given float array for calculation

  • size – Number of elements in the float array

Returns:

float representing the average array

bool terminateConnections(VnSensor *imu)

Disconnects IMU.

Parameters:

imu – VN sensor to be disconnected

Returns:

true IMU was successfully disconnected

Returns:

false IMU was not successfully disconnected

void activeSleep(float sleep_time, VnSensor *imu, ImuMeasurementsRegister &response, Log &log)

Similar to sleep() command but still records and logs IMU data.

Parameters:
  • sleep_time – Amount of time to sleep for

  • imu – VN-100 sensor

  • response – Register containing IMU data

  • logLog output file

bool isTimeExceeded(double launch_time, double trigger_time)

Checks if flight has gone on for too long.

Parameters:
  • launch_time – Time of launch in ms

  • trigger_time – Time threshold until the time has been exceeded

Returns:

true Flight has gone on too long

Returns:

false Flight is under time threshold

bool cameraCheck(std::string camera_check)

Checks if given camera stream is operational.

Parameters:

camera_check – Camera stream to check

Returns:

true Camera stream is functional

Returns:

false Camera stream is not functional

void realCamThreadLanding(cv::VideoCapture *cap, std::vector<cv::VideoWriter> *videos, int cam_number)

Image capture thread for flight.

Parameters:
  • cap – VideoCapture object

  • videos – List of videos that will be written out during flight

  • cam_number – Camera stream number

void realCamThreadRCB(cv::VideoCapture *cap, cv::VideoWriter *video)

Image capture thread for RCB.

Parameters:
  • cap – VideoCapture object

  • video – RCB output video

void realCamThreadLift(cv::VideoCapture *cap, cv::VideoWriter *video)

Image capture thread for Lift.

Parameters:
  • cap – VideoCapture object

  • video – Lift output video

Public Members

bool gpio_initialized_ = false

Boolean indicating if GPIO pins have been initialized.

double start_time_

Start time of program in milliseconds (arbitrary number)

bool is_unit_fsm_

Boolean indicating if it is in display mode (normally false, and should probably delete this)

int unit_test_delay_ms_ = 1000000

Delay between each motor/servo movement in display state machine.

std::string date_timestamp_ = ""

Time and date of when program starts.

int steps_per_revolution_ = 200

Number of steps required to fully rotate stepper motor in nacelle.

int stepper_speed_ = 10

Speed of stepper motor in nacelle.

int num_steps_ = 40

Number of steps to rotate stepper motor 60 degrees.

int stepper_threshold_ = 5000

Time threshold for how long stepper should run in display mode.

int pwm_motor_max_ = 255

PWM Signal to move motor at max speed.

int stepper_1_standby_pin_ = 0

RPi GPIO Pin for stepper 1 standby.

int stepper_1_pin_1_ = 11

RPi GPIO Pin for stepper 1 pin 1.

int stepper_1_pin_2_ = 9

RPi GPIO Pin for stepper 1 pin 2.

int stepper_1_pin_3_ = 5

RPi GPIO Pin for stepper 1 pin 3.

int stepper_1_pin_4_ = 6

RPi GPIO Pin for stepper 1 pin 4.

int stepper_2_standby_pin_ = 27

RPi GPIO Pin for stepper 2 standby.

int stepper_2_pin_1_ = 17

RPi GPIO Pin for stepper 2 pin 1.

int stepper_2_pin_2_ = 4

RPi GPIO Pin for stepper 2 pin 2.

int stepper_2_pin_3_ = 22

RPi GPIO Pin for stepper 2 pin 3.

int stepper_2_pin_4_ = 10

RPi GPIO Pin for stepper 2 pin 4.

std::vector<std::string> aac_camera_streams_

List of strings where each string represents functional camera stream.

std::vector<cv::VideoCapture> aac_camera_captures_

List of VideoCapture objects representing camera streams used during mission.

std::vector<std::string> aac_camera_captures_strings_

List of strings where each string represents a camera stream during mission (we are not using all functional camera streams from aac_camera_streams_, only a subset)

cv::VideoCapture cap1

VideoCapture object for cam 1.

cv::VideoCapture cap2

VideoCapture object for cam 2.

cv::VideoCapture cap3

VideoCapture object for cam 3.

bool launch_detected_ = false

Boolean indicating if launch has been detected yet.

bool apogee_detected_ = false

Boolean indicating if apogee has been detected yet.

bool landing_detected_ = false

Boolean indicating if landing has been detected yet.

int aac_pic_num_cam_1_ = 1

Number of pictures taken by camera 1 during flight.

int aac_pic_num_cam_2_ = 1

Number of pictures taken by camera 2 during flight.

int aac_pic_num_cam_3_ = 1

Number of pictures taken by camera 3 during flight.

int stepper_3_standby_pin_ = 8

RPi GPIO pin for nacelle stepper 3 standby.

int stepper_3_pin_1_ = 7

RPi GPIO pin for nacelle stepper 3 pin 1.

int stepper_3_pin_2_ = 1

RPi GPIO pin for nacelle stepper 3 pin 2.

int stepper_3_pin_3_ = 25

RPi GPIO pin for nacelle stepper 3 pin 3.

int stepper_3_pin_4_ = 24

RPi GPIO pin for nacelle stepper 3 pin 4.

Stepper stepper_1_

Stepper controller object for nacelle stepper 1.

Stepper stepper_2_

Stepper controller object for nacelle stepper 2.

Stepper stepper_3_

Stepper controller object for nacelle stepper 3.

int rcb_p_ = 26

RPi GPIO Pin for positive RCB motor terminal.

int rcb_n_ = 19

RPi GPIO Pin for negative RCB motor terminal.

int rcb_enable_ = 13

RPi GPIO Pin for enable RCB motor.

int rcb_lift_standby_ = 21

RPi GPIO Pin for standby pin for RCB and Lift Motor Controller.

int rcb_time_threshold_ = 5000

Time threshold for RCB to rotate in display mode (Note: Display mode will just tick each motor in order and has no perception)

double rcb_angle_threshold_ = 1

Error threshold for RCB motor error (+/- rcb_angle_threshold_ meaning total error is twice as big)

bool is_aligned_ = false

Boolean indicating if RCB is finished (aligned)

int full_rcb_time_threshold_ = 75000

Maximum time to run RCB during payload before transitioning to next state.

double landing_time_

Time in milliseconds of landing.

size_t n_photo_bit_size_ = 5

Number of leading zeroes in AAC saved photos filename.

int nacelle_servo_ = 14

RPi GPIO pin for nacelle locking servo.

uint16_t servo_pulse_min_ = 500

Minimum servo pulse width (only for display mode, which doesn’t work at the moment)

uint16_t servo_pulse_max_ = 2250

Maximum servo pulse width (only display mode)

uint8_t servo_deg_range_ = 90

Servo angle range.

int nacelle_lock_ = 1375

Servo pulse width to lock nacelles.

int nacelle_unlock_ = 755

Servo pulse width to unlock nacelles.

bool lift_done_ = false

Boolean indicating if the lift state is done.

int lift_servo_ = 2

RPi GPIO pin for lift servo.

int lift_final_limit_switch_ = 23

RPi GPIO pin for top limit switch for lift.

int lift_unit_time_threshold_ = 2000

Time the lift motor will run in display mode.

int lift_lock_ = 1500

Pulse width to lock the lift.

int lift_unlock_ = 1150

Pulse width to unlock the lift.

int lift_p_ = 20

RPi GPIO Pin for positive lift motor terminal.

int lift_n_ = 16

RPi GPIO Pin for negative lift motor terminal.

int lift_enable_ = 12

RPi GPIO Pin for the Lift motor enable.

int lift_time_threshold_ = 30000

Maximum amount of time (ms) to run lift before transitioning to next state.

int lift_backwards_time_threshold_ = 1068

Amount of time to move the lift back down to prevent wire tension.

int lift_min_threshold_ = 15000

Minimum amount of time (ms) to run lift.

int level_servo_ = 3

RPi GPIO Pin for level servo.

int num_level_samples_ = 20

Number of IMU measurements taken to determine pitch error for level.

double ideal_level_angle_ = 180

Ground truth angle for pitch level.

int min_angle_ = -10

Maximum angle the level can tilt up.

int min_pulse_width_ = 1200

Corresponding pulse width to tilt level up at the maximum angle.

int max_angle_ = 20

Maximum angle the level can tilt down.

int max_pulse_width_ = 1950

Corresponding pulse width to tilt level down at the maximum angle.

int rafco_pic_num_ = 1

Number of RAFCO pictures taken (used for photo saving)

std::map<StateName, State*> states_

Map every state name to a state.

std::vector<std::thread> threads_

Threads for flight photos.

float ft_2_m_ = 0.3048

Feet to meters conversion factor.

float m_2_ft_ = 1 / ft_2_m_

Meters to feet conversion factor.

float c_2_k_ = 273.15

Celsius to Kelvin conversion factor.

float km_2_m_ = 0.001

Kilometers to meters conversion factor.

float r_ = 287

Universal gas constant (kg/JK)

float b_ = 6.5 * km_2_m_

Variation of temperature within the troposphere (K/m)

float t_burn_ = 1.9

Motor burn time (s)

float sampling_frequency_ = 20

Speed the IMU samples data (Hz)

bool restart_ = false

Tells program if we NO-GOed.

bool time_delay_enabled_ = false

Flight relies on time thresholds if true rather than IMU data.

int fps_ = 30

Flight video frames per second.

int frame_width_ = 640

Flight video frame width.

int frame_height_ = 480

Flight video frame height.

int max_proper_flight_time_ = 3 * 60

Maximum flight recording time.

int vid_clip_time_ = 3

Time of individual video clip recording (individual 3 second videos are written out and saved)

int frames_per_vid_ = fps_ * vid_clip_time_

Numnber of frames per individual 3 second video.

std::vector<cv::VideoWriter> videos1_

List of all individual videos from camera 1.

std::vector<cv::VideoWriter> videos2_

List of all individual videos from camera 2.

std::vector<cv::VideoWriter> videos3_

List of all individual videos from camera 3.

cv::VideoCapture lift_and_level_cap_

Videocapture object for lift and level video.

cv::VideoWriter lift_and_level_video_

Videowriter object for lift and level video.

std::thread lift_thread_

Thread to record lift video.

float accel_roof_ = 3.5

Acceleration to detect launch (g’s)

int num_data_points_checked_4_launch_ = 8

how many acceleration points are averaged to see if data set is over accel_roof_

int num_data_points_checked_4_apogee_ = 10

how many altitude points must a new max not be found for apogee to be declared

int num_seconds_no_new_minimum_ = 10

[s] number of seconds to wait for no new minimum to determine landing

int num_data_points_checked_4_landing_ = num_seconds_no_new_minimum_ * sampling_frequency_

how many altitude points must a new min not be found for landing to be declared

int z_threshold_for_landing_ = 175 * ft_2_m_

[m] threshold that the altitude must be within for landing

int max_flight_time_ = 10 * 60

[s] max allowable flight time, if exceeded program ends (accounts for if we switched drogue amd main)

int length_collect_rafco_ = 20 * 60

[s] amount of time to collect RAFCO signals and perform image processing

std::string rafco_freq_ = "144.900M"

Frequency for RAFCO transmissions.

std::string callsign_ = "KQ4CTL"

Callsign to look for.

int source_ssid_ = 6

Service Set Identifier, probably used for TCP Packet Receiver, Ask Meredith Hunter.

int pds_delay_ = 60 * 1000

[ms] aditional time to wait for PDS

bool rafco_redo_ = false

Boolean that is true if we had to use backup cameras, but we want to try to redo RAFCO for the primary camera.

uint16_t num_sample_readings_ = 60

amount of samples taken and averaged to find ground P and T

int imu_wait_ = 60

number of samples to get from IMU before actually starting to use + save data

float p0_

Baseline pressure reading.

float t0_

Baseline temperature reading.

float g0_

Baseline gravity reading.

double launch_time_

Time of launch in ms.

float z_current_ = 0

Current altitude.

VnSensor *m_vn_

VN Sensor Object.

ImuMeasurementsRegister response_

IMU Register storing the data.

std::string input_file_name_ = "packets_" + std::to_string(start_time_).substr(0, std::to_string(start_time_).find(".")) + ".txt"

String with the name for APRS Packet filename.

std::string flight_log_name_ = "flightDataLog"

String with name for flight data log.

std::string program_log_name_ = "programDataLog"

String with name for program data log.

Log m_log_

Log object for flight data.

bool is_imu_connected_ = false

Boolean indicating if the IMU is still connected.

std::string config1_ = "/home/vadl/FullscalePrime/sdr1.conf"

String for first SDR configuration file.

std::string config2_ = "/home/vadl/FullscalePrime/sdr2.conf"

String for second SDR configuration file.

PacketReceiver radio1_ = PacketReceiver(100, rafco_freq_, 8001, config1_)

Packet Receiver object for first SDR.

PacketReceiver radio2_ = PacketReceiver(200, rafco_freq_, 9001, config2_)

Packet Receiver object for second SDR.

std::vector<std::string> camera_streams_

List of all possible camera streams.

std::string primary_camera_stream_

String indicating the primary camera stream.

bool rcb_done_ = false

Boolean indicating if the RCB state is done.

State

Base state.

class State
#include <State.h>

Base state.

Subclassed by State_Apogee_Detection, State_Camera_Check, State_Full_Level, State_Full_Lift, State_Full_RCB, State_Landing_Detection, State_Launch_Detection, State_Level_Servo, State_Lift_Motor, State_Lift_Servo, State_Nacelle_Servo, State_PDS_Delay, State_Prelaunch, State_RAFCO_Mission, State_RCB_Motor, State_SDR1, State_SDR2, State_Stepper1, State_Stepper2, State_Stepper3

Public Functions

State()

Construct a new State object.

State(StateName &name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute()

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute()

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

StateName getName()

Get the name of the state.

Returns:

StateName (Name of the state)

StateName getNextState(EventName curr_event)

Get the next state based on the event that occured during state machine execution.

Parameters:

curr_event – The event that just occured in execution

Returns:

StateName The next state to be transitioned to in the state machine

Protected Attributes

Root *root_

Root object containing variables and methods accessible to all states.

StateName name_

Name of the state.

std::map<EventName, StateName> state_transitions_

Map of transitions to map events occuring in the state machine to the next state.

State_RAFCO_Mission

State responsible for receiving APRS packets and perform image processing with camera nacelles

class State_RAFCO_Mission : public State
#include <State_RAFCO_Mission.h>

State responsible for receiving APRS packets and perform image processing with camera nacelles.

Public Functions

State_RAFCO_Mission()

Construct a new State_RAFCO_Mission object.

State_RAFCO_Mission(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_RAFCO_Mission object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Enums

Contains all StateName and EventName enums used in project

Enums

enum StateName

Different possible states that can be run in this state machine.

Values:

enumerator STATE_RCB_MOTOR

State to test RCB Motor.

enumerator STATE_NACELLE_SERVO

State to test nacelle servo.

enumerator STATE_LIFT_SERVO

State to test lift locking servo.

enumerator STATE_LIFT_MOTOR

State to test lift motor.

enumerator STATE_LEVEL_SERVO

State to test level servo.

enumerator STATE_STEPPER1

State to test stepper for nacelle 1.

enumerator STATE_STEPPER2

State to test stepper for nacelle 2.

enumerator STATE_STEPPER3

State to test stepper for nacelle 3.

enumerator STATE_SDR1

State to test SDR 1.

enumerator STATE_SDR2

State to test SDR 2.

enumerator STATE_PRELAUNCH

State run before launch detection to double check parameters.

enumerator STATE_LAUNCH_DETECTION

State responsible for detecting launch.

enumerator STATE_APOGEE_DETECTION

State responsible for detecting apogee.

enumerator STATE_LANDING_DETECTION

State responsible for detecting landing.

enumerator STATE_FULL_LIFT

State responsible for elevating the lift during the payload mission.

enumerator STATE_FULL_LEVEL

State responsible for leveling the key nacelle parallel with the horizon.

enumerator STATE_FULL_RCB

State responsible for rotating RCB to put key nacelle on top.

enumerator STATE_PDS_DELAY

State responsible for “sleeping” the program until PDS is detached from Teensy.

enumerator STATE_RAFCO_MISSION

State responsible for receiving RAFCO packets and performing the proper image filtering.

enumerator STATE_CAMERA_CHECK

State responsible for determining the primary nacelle.

enumerator END_STATE

State responsible for terminating the program.

enum EventName

Different possible events that can occur in this state machine.

Values:

enumerator INITIALIZE

Occurs when state machine has been initialized.

enumerator BASIC_SWIVEL

Occurs when stepper motor has swiveled nacelle.

enumerator BASIC_ROTATE

Occurs when DC motor has rotated.

enumerator BASIC_SERVO

Occurs when servo moves.

enumerator RECEIVED_PACKETS

Occurs when program receives packets.

enumerator DELAY_1_SECOND

Occurs when the program has been delayed by a second.

enumerator DELAY

Occurs when the program has been delayed by some time threshold.

enumerator TERMINATE

Occurs when the program needs to be terminated.

enumerator PRELAUNCH_COMPLETE

Occurs when the prelaunch state has been completed.

enumerator LAUNCH_DETECTED

Occurs when launch has been detected.

enumerator APOGEE_DETECTED

Occurs when apogee has been detected.

enumerator LANDING_DETECTED

Occurs when landing has been detected.

enumerator LIFT_SUCCESS

Occurs when the lift is successful.

enumerator LIFT_FAILURE

Occurs when there has been an error in the lift state.

enumerator LEVEL_SUCCESS

Occurs when the level is successful.

enumerator LEVEL_FAILURE

Occurs when there has been an error in the level.

enumerator RCB_SUCCESS

Occurs when the RCB state is successful.

enumerator RCB_FAILURE

Occurs when there has been an error in the RCB state.

enumerator RAFCO_COMPLETE

Occurs when RAFCO state is successfully completed.

enumerator RAFCO_REDO

Occurs when backup RAFCO is completed, and want to try it with primary.

enumerator CAMERA_PICKED

Occurs when camera has been selected.

State_RCB_Motor

State responsible for testing RCB motor without IMU

class State_RCB_Motor : public State
#include <State_RCB_Motor.h>

State responsible for testing RCB motor without IMU.

Public Functions

State_RCB_Motor()

Construct a new State_RCB_Motor object.

State_RCB_Motor(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_RCB_Motor object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Camera_Check

State responsible for determining primary camera for RCB

class State_Camera_Check : public State
#include <State_Camera_Check.h>

State responsible for determining primary camera for RCB.

Public Functions

State_Camera_Check()

Construct a new State_Camera_Check object.

State_Camera_Check(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Camera_Check object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Lift_Motor

State responsible for testing lift motor without limit switch

class State_Lift_Motor : public State
#include <State_Lift_Motor.h>

State responsible for testing lift motor without limit switch sensors.

Public Functions

State_Lift_Motor()

Construct a new State_Lift_Motor object.

State_Lift_Motor(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Lift_Motor object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Nacelle_Servo

State responsible for testing nacelle locking servo movement

class State_Nacelle_Servo : public State
#include <State_Nacelle_Servo.h>

State responsible for testing nacelle locking servo movement.

Public Functions

State_Nacelle_Servo()

Construct a new State_Nacelle_Servo object.

State_Nacelle_Servo(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Nacelle_Servo object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Lift_Servo

State responsible for testing lift servo to see if it can move

class State_Lift_Servo : public State
#include <State_Lift_Servo.h>

State responsible for testing lift servo to see if it can move.

Public Functions

State_Lift_Servo()

Construct a new State_Lift_Servo object.

State_Lift_Servo(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Lift_Servo object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Level_Servo

State responsible for testing movement for the level servo

class State_Level_Servo : public State
#include <State_Level_Servo.h>

State responsible for testing movement for the level servo.

Public Functions

State_Level_Servo()

Construct a new State_Level_Servo object.

State_Level_Servo(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Level_Servo object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Stepper1

State responsible for testing movement for nacelle 1

class State_Stepper1 : public State
#include <State_Stepper1.h>

State responsible for testing movement for nacelle 1.

Public Functions

State_Stepper1()

Construct a new State_Stepper1 object.

State_Stepper1(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Stepper1 object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Stepper2

State responsible for testing movement for nacelle 2

class State_Stepper2 : public State
#include <State_Stepper2.h>

State responsible for testing movement for nacelle 2.

Public Functions

State_Stepper2()

Construct a new State_Stepper2 object.

State_Stepper2(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Stepper2 object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Stepper3

State responsible for testing movement for nacelle 3

class State_Stepper3 : public State
#include <State_Stepper3.h>

State responsible for testing movement for nacelle 3.

Public Functions

State_Stepper3()

Construct a new State_Stepper3 object.

State_Stepper3(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Stepper3 object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Prelaunch

State responsible for verifying parameters before launch detection

class State_Prelaunch : public State
#include <State_Prelaunch.h>

State responsible for verifying parameters before launch detection.

Public Functions

State_Prelaunch()

Construct a new State_Prelaunch object.

State_Prelaunch(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Prelaunch object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Launch_Detection

State responsible for detecting launch with IMU

class State_Launch_Detection : public State
#include <State_Launch_Detection.h>

State responsible for detecting launch with IMU.

Public Functions

State_Launch_Detection()

Construct a new State_Launch_Detection object.

State_Launch_Detection(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Launch_Detection object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Apogee_Detection

State responsible for detecting apogee with IMU

class State_Apogee_Detection : public State
#include <State_Apogee_Detection.h>

State responsible for detecting apogee with IMU.

Public Functions

State_Apogee_Detection()

Construct a new State_Apogee_Detection object.

State_Apogee_Detection(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Apogee_Detection object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Landing_Detection

State responsible for detecting landing with the IMU

class State_Landing_Detection : public State
#include <State_Landing_Detection.h>

State responsible for detecting landing with the IMU.

Public Functions

State_Landing_Detection()

Construct a new State_Landing_Detection object.

State_Landing_Detection(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Landing_Detection object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Full_Lift

State responsible for elevating the key nacelle with the lift

class State_Full_Lift : public State
#include <State_Full_Lift.h>

State responsible for elevating the key nacelle with the lift.

Public Functions

State_Full_Lift()

Construct a new State_Full_Lift object.

State_Full_Lift(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Full_Lift object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Full_Level

State responsible for levelling the key nacelle parallel with the horizon

class State_Full_Level : public State
#include <State_Full_Level.h>

State responsible for levelling the key nacelle parallel with the horizon.

Public Functions

State_Full_Level()

Construct a new State_Full_Level object.

State_Full_Level(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Full_Level object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_Full_RCB

State responsible for RCB to rotate key nacelle on top

class State_Full_RCB : public State
#include <State_Full_RCB.h>

State responsible for RCB to rotate key nacelle on top.

Public Functions

State_Full_RCB()

Construct a new State_Full_RCB object.

State_Full_RCB(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_Full_RCB object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_PDS_Delay

State responsible for program to “sleep” while waiting for Teensy parachute to detach

class State_PDS_Delay : public State
#include <State_PDS_Delay.h>

State responsible for program to “sleep” while waiting for Teensy parachute to detach.

Public Functions

State_PDS_Delay()

Construct a new State_PDS_Delay object.

State_PDS_Delay(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_PDS_Delay object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_SDR1

State responsible for debugging SDR 1

class State_SDR1 : public State
#include <State_SDR1.h>

State responsible for debugging SDR 1.

Public Functions

State_SDR1()

Construct a new State_SDR1 object.

State_SDR1(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_SDR1 object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State_SDR2

State responsible for debugging SDR 2

class State_SDR2 : public State
#include <State_SDR2.h>

State responsible for debugging SDR 2.

Public Functions

State_SDR2()

Construct a new State_SDR2 object.

State_SDR2(StateName name, std::map<EventName, StateName> &state_transitions, Root *root)

Construct a new State_SDR2 object.

Parameters:
  • name – String representing state name

  • state_transitions – Map of transitions to determine what the next state will be

  • rootRoot variable used for state machine

virtual EventName execute() override

Main execution method for state.

Returns:

Result of state execution

virtual EventName unitExecute() override

Execution method for state in display mode (DOESN’T WORK)

Returns:

Result of state execution

State Generation Script

The writestate.py script should be able to automatically write a state header and cpp file along with update the CMakeLists. It should update the State Enum header, but it may not add any events. python writestate.py -n <STATE_NAME>