diff --git a/flight-computer/src/state_machine.rs b/flight-computer/src/state_machine.rs index 0cba44a..0d05bfb 100644 --- a/flight-computer/src/state_machine.rs +++ b/flight-computer/src/state_machine.rs @@ -10,6 +10,8 @@ pub enum State { Thrusting { last_velocity: f32 }, Coasting, Descend, + MainDescend, + Touchdown, Shutdown, } @@ -21,7 +23,7 @@ impl State { avionics: &mut MessageSender, ) { match self { - State::Idle | State::Shutdown | State::Descend => {} + State::Idle | State::Shutdown | State::Touchdown => {} State::Thrusting { last_velocity } => { if inputs.velocity.down.abs() < *last_velocity { println!("Starting to decelerate"); @@ -36,6 +38,18 @@ impl State { *self = State::Descend; } } + State::Descend => { + if inputs.location.altitude < 3000.0 { + println!("We are so great"); + let _ = avionics.send(&AvionicsCommandMessage::DeployMain).await; + *self = State::MainDescend; + } + } + State::MainDescend => { + if inputs.location.altitude < 0.1 && inputs.velocity.down.abs() < 0.1 { + *self = State::Touchdown; + } + } } }