Skip to content

Commit

Permalink
Implement emergency stop in FSM using Lidar (#95)
Browse files Browse the repository at this point in the history
* add lidar limit

* uncomment
  • Loading branch information
ryescholin authored May 31, 2024
1 parent 13ef3f6 commit 84ab1b7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pod-operation/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use tracing::info;

use crate::components::brakes::Brakes;
use crate::components::high_voltage_system::HighVoltageSystem;
use crate::components::lidar::Lidar;
use crate::components::lim_temperature::LimTemperature;
use crate::components::pressure_transducer::PressureTransducer;
use crate::components::signal_light::SignalLight;
Expand All @@ -17,7 +18,7 @@ use crate::components::wheel_encoder::WheelEncoder;
const TICK_INTERVAL: Duration = Duration::from_millis(10);
const STOP_THRESHOLD: f32 = 37.0; // Meters
const MIN_PRESSURE: f32 = 126.0; // PSI

const END_OF_TRACK: f32 = 8.7; // Meters
const LIM_TEMP_THRESHOLD: f32 = 71.0; //°C

#[derive(Clone, Copy, Debug, PartialEq, Eq, enum_map::Enum)]
Expand Down Expand Up @@ -46,6 +47,7 @@ pub struct StateMachine {
lim_temperature_port: LimTemperature,
lim_temperature_starboard: LimTemperature,
high_voltage_system: HighVoltageSystem,
lidar: Lidar,
}

impl StateMachine {
Expand Down Expand Up @@ -102,6 +104,7 @@ impl StateMachine {
false, true,
)),
high_voltage_system: HighVoltageSystem::new(),
lidar: Lidar::new(),
}
}

Expand Down Expand Up @@ -229,6 +232,10 @@ impl StateMachine {
{
return State::Faulted;
}
// Last 20% of the track, as indicated by braking
if self.lidar.read_distance() < END_OF_TRACK {
return State::Faulted;
}

State::Running
}
Expand Down

0 comments on commit 84ab1b7

Please sign in to comment.