Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion flight-computer/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub enum State {
Thrusting { last_velocity: f32 },
Coasting,
Descend,
MainDescend,
Touchdown,
Shutdown,
}

Expand All @@ -21,7 +23,7 @@ impl State {
avionics: &mut MessageSender<AvionicsCommandMessage>,
) {
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");
Expand All @@ -36,6 +38,18 @@ impl State {
*self = State::Descend;
}
}
State::Descend => {
if inputs.location.altitude < 3000.0 {
println!("We are so great");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you both are 🫶

let _ = avionics.send(&AvionicsCommandMessage::DeployMain).await;
*self = State::MainDescend;
}
}
State::MainDescend => {
if inputs.location.altitude < 0.1 && inputs.velocity.down.abs() < 0.1 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the docs of Location, it is above sea level. Which for wichlen means we would never go into touchdown state.

*self = State::Touchdown;
}
}
}
}

Expand Down
Loading