Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Context

Path Manager is a state machine in ZeroPilot that determines how we get our plane from point A to B. Over the past few months, Path Manager’s complexity has increased grealty with the introduction of landing and takeoff states. In the future, it will only get more complex. To make Path Manager more modular and expandible, it will need to be redesigned. This document contains one such proposal, which will introduce sub-state macines (dubbed Modes) with their own states (dubbed Stages).

States, Modes, and Stages

Before we go forward, we must define these three words:

State - Lives in pathManager and is a child class to pathManagerState

Mode - Is a type of flight exhibited by our aircraft. It includes, but is not limited to: landing, takeoff, cruising, and taxiing. Each mode is a sub-state machine to Path Manager (meaning its execution methods are called exclusively by Path Manager)

Stage - Is a specific function executed by an aircraft in a mode of flight. Stages are the states for the Modes (sub-state machines).

  • For example, takeoff has two stages: rolling and climb.

  • Another example is landing, which has five stages: transition, slope, flare, decrab, and touchdown. Each mode will have at least one stage.

Intended Final Result

  1. Path Manager (that is, pathManager, pathManagerState, and their children) should not know which mode of flight we are in.

  2. Each mode needs to be an independent unit, ensuring expandibility

  3. Modes must be able to switch between each other without the help of Path Manager states.

  4. The modes must all be called via one singular execute() method call in a Path Manager state.

In the end, Path Manager will look like the following flowchart

The Enums

We will need to introduce a few new enums to represent different modes and stages within each mode:

Modes

enum ModeEnum{MODE_TAKEOFF = 0, MODE_CRUISING, MODE_LANDING, MODE_TAXIING};

Stages

Takeoff

enum TakeoffStages{
  TAKEOFF_ROLL = 0,
  TAKEOFF_CLIMB
};

Cruising

enum CruisingStages{
  CRUISING = 0
};

Lol only one stage here…

Landing

enum LandingStages{
  LANDING_TARANSITION = 0,
  LANDING_SLOPE,
  LANDING_FLARE,
  LANDING_DECRAB,
  LANDING_TOUCHDOWN
};

Taxiing

tbd…

The Classes

Abstraction layer that Path Manager interacts with directly. It ensures that Path Manager never knows what Mode of flight we are in

ModeSelector (Singleton)

- current_mode : Mode*

- current_mode_enum : ModeEnum

- telemetry_data : Telemetry_PIGO_t

- sensor_fusion_output : SFOutput_t

- private member variables for all required raw sensor data

// The following are all output data

- altitude_airspeed_input : AltitudeAirspeedInput_t

- altitude_airspeed_input : AltitudeAirspeedInput_t

- Individual member variables that will need to be used/sent down by telemetry

- ModeSelector()

+ execute(Telemetry_PIGO_t, SFOutput_t, …) → void // Input data sent in via parameters

+ getCurrentMode() → Mode*

+ getCurrentModeEnum() → ModeEnum

+ setMode(Mode&) → void

+ getters and setters for all output data

Is akin to the pathManager class in ZeroPilot. One of these classes will exist for each mode of flight: Crusing, Landing, Takeoff, Taxiing, etc.

Mode

- current_stage : ModeStage*

- stage_status : STAGE_ENUM

- mode_selector : ModeSelector

- current_status : PathMan::_Path_Manager_Cycle_Status

+ getCurrentStage() → ModeStage*

+ execute() → void

+ setStage(ModeStage&

) → void

+ getStageStatus() → STAGE_ENUM

+ getSelector() → ModeSelector&

+ Gettes and setters to access data in ModeSelector

* STAGE_ENUM is a substitute for TakeoffStages, LandingStages, etc.

Is akin to the pathManagerState class in ZeroPilot. Each of these classes will represent a stage in a mode of flight (ex. landingFlareStage in landing or takeoffClimbStage in takeoff). This will be a ABC.

ModeStage (ABC)

+ operator ==(const ModeStage&) const → bool

+ enter(Mode*) = 0 → void

+ execute(Mode*) = 0 → void

+ exit(Mode*) = 0 → void

+ ~ModeStage() → void

Each individual stage class is like the state classes (ex. crusingState) in Path Manager.

Stage (Singleton)

- Stage()

- Stage(const Stage&)

- Stage& operator =(const Stage&)

- any additional parameters

+ enter(Mode*) → void

+ execute(Mode*) → void

+ exit(Mode*) → void

+ static getInstance() → Stage&

+ getters for private data

Flow of Code

Here’s the flow of code:


  • No labels