From 292c7a162ceebda7b53043751c264cff6ae46b31 Mon Sep 17 00:00:00 2001 From: ryescholin Date: Wed, 22 May 2024 13:49:04 -0700 Subject: [PATCH 01/13] add therm --- pod-operation/src/state_machine.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index 0261bbbf..dae2c4e7 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -1,12 +1,12 @@ use std::time::Duration; +use crate::components::lim_temperature::LimTemperature; use enum_map::{enum_map, EnumMap}; use once_cell::sync::Lazy; use socketioxide::extract::AckSender; use socketioxide::{extract::SocketRef, SocketIo}; use tokio::sync::Mutex; use tracing::info; - // use crate::components::signal_light::SignalLight; const TICK_INTERVAL: Duration = Duration::from_millis(500); @@ -28,6 +28,7 @@ pub struct StateMachine { enter_actions: EnumMap, state_transitions: EnumMap>, io: SocketIo, + ads1015: LimTemperature, } impl StateMachine { @@ -72,6 +73,7 @@ impl StateMachine { enter_actions, state_transitions, io, + ads1015: LimTemperature::new(ads1x1x::SlaveAddr::Default), } } @@ -161,7 +163,9 @@ impl StateMachine { /// Perform operations when the pod is running fn _running_periodic(&mut self) -> State { info!("Rolling Running state"); - // TODO: add actual decision logic + if self.ads1015.read_lim_temps() > 150.0 { + State::Halted + } State::Running } From cb9f4aac427b7e4f90348e89ea8da00a8dd4b5e5 Mon Sep 17 00:00:00 2001 From: Sam Der Date: Wed, 22 May 2024 14:14:44 -0700 Subject: [PATCH 02/13] Fix compilation issues --- pod-operation/src/state_machine.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index dae2c4e7..ab849e1d 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -11,6 +11,8 @@ use tracing::info; const TICK_INTERVAL: Duration = Duration::from_millis(500); +const LIM_TEMP_THRESHOLD: f32 = 150.0; + #[derive(Clone, Copy, Debug, PartialEq, Eq, enum_map::Enum)] pub enum State { Init, @@ -163,8 +165,13 @@ impl StateMachine { /// Perform operations when the pod is running fn _running_periodic(&mut self) -> State { info!("Rolling Running state"); - if self.ads1015.read_lim_temps() > 150.0 { - State::Halted + let (a0_reading, a1_reading, a2_reading, a3_reading) = self.ads1015.read_lim_temps(); + if a0_reading > LIM_TEMP_THRESHOLD + || a1_reading > LIM_TEMP_THRESHOLD + || a2_reading > LIM_TEMP_THRESHOLD + || a3_reading > LIM_TEMP_THRESHOLD + { + return State::Halted; } State::Running } From 4909a03abc68e77f643a3fc615475696a582af52 Mon Sep 17 00:00:00 2001 From: ryescholin Date: Wed, 22 May 2024 14:17:21 -0700 Subject: [PATCH 03/13] fix state transitions --- pod-operation/src/state_machine.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index ab849e1d..924d6930 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -149,11 +149,13 @@ impl StateMachine { fn _enter_stopped(&mut self) { info!("Entering Stopped state"); // self.signal_light.disable(); + State::Load } fn _enter_halted(&mut self) { info!("Entering Halted state"); // self.hvs.disable() + State::Load } /// Perform operations when the pod is loading From 352704ea7a50ac81a56acec3bce00d26f8b6f775 Mon Sep 17 00:00:00 2001 From: ryescholin Date: Wed, 22 May 2024 14:46:09 -0700 Subject: [PATCH 04/13] add second ads --- pod-operation/src/state_machine.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index 924d6930..b94652e8 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -1,6 +1,5 @@ use std::time::Duration; -use crate::components::lim_temperature::LimTemperature; use enum_map::{enum_map, EnumMap}; use once_cell::sync::Lazy; use socketioxide::extract::AckSender; @@ -8,6 +7,7 @@ use socketioxide::{extract::SocketRef, SocketIo}; use tokio::sync::Mutex; use tracing::info; // use crate::components::signal_light::SignalLight; +use crate::components::lim_temperature::LimTemperature; const TICK_INTERVAL: Duration = Duration::from_millis(500); @@ -30,7 +30,8 @@ pub struct StateMachine { enter_actions: EnumMap, state_transitions: EnumMap>, io: SocketIo, - ads1015: LimTemperature, + ads1015_1: LimTemperature, + ads1015_2: LimTemperature, } impl StateMachine { @@ -75,7 +76,8 @@ impl StateMachine { enter_actions, state_transitions, io, - ads1015: LimTemperature::new(ads1x1x::SlaveAddr::Default), + ads1015_1: LimTemperature::new(ads1x1x::SlaveAddr::Default), + ads1015_2: LimTemperature::new(ads1x1x::SlaveAddr::Alternative), } } @@ -167,14 +169,16 @@ impl StateMachine { /// Perform operations when the pod is running fn _running_periodic(&mut self) -> State { info!("Rolling Running state"); - let (a0_reading, a1_reading, a2_reading, a3_reading) = self.ads1015.read_lim_temps(); - if a0_reading > LIM_TEMP_THRESHOLD - || a1_reading > LIM_TEMP_THRESHOLD - || a2_reading > LIM_TEMP_THRESHOLD - || a3_reading > LIM_TEMP_THRESHOLD + let default_readings: [f32; 4] = self.ads1015_1.read_lim_temps().into(); + let alternative_readings: [f32; 4] = self.ads1015_2.read_lim_temps().into(); + let all_readings = [default_readings, alternative_readings].concat(); + if all_readings + .iter() + .any(|&reading| reading > LIM_TEMP_THRESHOLD) { return State::Halted; } + State::Running } From a96e86ae135be235d50b79053c7ee7dfa9c1c800 Mon Sep 17 00:00:00 2001 From: ryescholin Date: Wed, 22 May 2024 14:53:46 -0700 Subject: [PATCH 05/13] fix --- pod-operation/src/state_machine.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index b94652e8..a7b0d5be 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -151,13 +151,11 @@ impl StateMachine { fn _enter_stopped(&mut self) { info!("Entering Stopped state"); // self.signal_light.disable(); - State::Load } fn _enter_halted(&mut self) { info!("Entering Halted state"); // self.hvs.disable() - State::Load } /// Perform operations when the pod is loading From ae9ce5c8096a517627eecded989ae935272531c4 Mon Sep 17 00:00:00 2001 From: ryescholin Date: Wed, 22 May 2024 14:58:08 -0700 Subject: [PATCH 06/13] fix --- pod-operation/src/state_machine.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index a7b0d5be..e1b70b19 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -77,7 +77,7 @@ impl StateMachine { state_transitions, io, ads1015_1: LimTemperature::new(ads1x1x::SlaveAddr::Default), - ads1015_2: LimTemperature::new(ads1x1x::SlaveAddr::Alternative), + ads1015_2: LimTemperature::new(ads1x1x::SlaveAddr::Alternative((false), (true))), } } From 07bfd7cb4542629d250ede2f18b02d8231736500 Mon Sep 17 00:00:00 2001 From: ryescholin Date: Wed, 22 May 2024 15:01:48 -0700 Subject: [PATCH 07/13] im sorry --- pod-operation/src/state_machine.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index e1b70b19..73cee1be 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -77,7 +77,7 @@ impl StateMachine { state_transitions, io, ads1015_1: LimTemperature::new(ads1x1x::SlaveAddr::Default), - ads1015_2: LimTemperature::new(ads1x1x::SlaveAddr::Alternative((false), (true))), + ads1015_2: LimTemperature::new(ads1x1x::SlaveAddr::Alternative(false, true)), } } From 5e6f87d67148ebb90a08f6c729884860c568c4ca Mon Sep 17 00:00:00 2001 From: ryescholin Date: Thu, 23 May 2024 01:15:56 -0700 Subject: [PATCH 08/13] requests --- pod-operation/src/state_machine.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index 73cee1be..11701b23 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -11,7 +11,7 @@ use crate::components::lim_temperature::LimTemperature; const TICK_INTERVAL: Duration = Duration::from_millis(500); -const LIM_TEMP_THRESHOLD: f32 = 150.0; +const LIM_TEMP_THRESHOLD: f32 = 150.0; //°C #[derive(Clone, Copy, Debug, PartialEq, Eq, enum_map::Enum)] pub enum State { @@ -30,8 +30,8 @@ pub struct StateMachine { enter_actions: EnumMap, state_transitions: EnumMap>, io: SocketIo, - ads1015_1: LimTemperature, - ads1015_2: LimTemperature, + lim_temperature_port: LimTemperature, + lim_temperature_starboard: LimTemperature, } impl StateMachine { @@ -76,8 +76,10 @@ impl StateMachine { enter_actions, state_transitions, io, - ads1015_1: LimTemperature::new(ads1x1x::SlaveAddr::Default), - ads1015_2: LimTemperature::new(ads1x1x::SlaveAddr::Alternative(false, true)), + lim_temperature_port: LimTemperature::new(ads1x1x::SlaveAddr::Default), + lim_temperature_starboard: LimTemperature::new(ads1x1x::SlaveAddr::Alternative( + false, true, + )), } } @@ -167,8 +169,8 @@ impl StateMachine { /// Perform operations when the pod is running fn _running_periodic(&mut self) -> State { info!("Rolling Running state"); - let default_readings: [f32; 4] = self.ads1015_1.read_lim_temps().into(); - let alternative_readings: [f32; 4] = self.ads1015_2.read_lim_temps().into(); + let default_readings: [f32; 4] = self.lim_temperature_port.read_lim_temps().into(); + let alternative_readings: [f32; 4] = self.lim_temperature_starboard.read_lim_temps().into(); let all_readings = [default_readings, alternative_readings].concat(); if all_readings .iter() From 8a1ad6392a12b5672e78b0b2e89f01cbfcf892b9 Mon Sep 17 00:00:00 2001 From: ryescholin Date: Thu, 23 May 2024 01:23:22 -0700 Subject: [PATCH 09/13] temp update --- pod-operation/src/state_machine.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index 88cd00f8..28540bc3 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -12,7 +12,7 @@ use crate::components::lim_temperature::LimTemperature; const TICK_INTERVAL: Duration = Duration::from_millis(500); -const LIM_TEMP_THRESHOLD: f32 = 150.0; //°C +const LIM_TEMP_THRESHOLD: f32 = 65.0; //°C #[derive(Clone, Copy, Debug, PartialEq, Eq, enum_map::Enum)] pub enum State { From aaea65dd5a4461266e38e4129900f2121b5b7e8b Mon Sep 17 00:00:00 2001 From: ryescholin Date: Thu, 23 May 2024 01:29:59 -0700 Subject: [PATCH 10/13] more temp fix --- pod-operation/src/state_machine.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index 28540bc3..88cd00f8 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -12,7 +12,7 @@ use crate::components::lim_temperature::LimTemperature; const TICK_INTERVAL: Duration = Duration::from_millis(500); -const LIM_TEMP_THRESHOLD: f32 = 65.0; //°C +const LIM_TEMP_THRESHOLD: f32 = 150.0; //°C #[derive(Clone, Copy, Debug, PartialEq, Eq, enum_map::Enum)] pub enum State { From 1ab0dbecbc78e1459067417641497ebadb00094b Mon Sep 17 00:00:00 2001 From: ryescholin Date: Thu, 23 May 2024 13:51:16 -0700 Subject: [PATCH 11/13] seventy one --- pod-operation/src/state_machine.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index 88cd00f8..ecb8d814 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -12,7 +12,7 @@ use crate::components::lim_temperature::LimTemperature; const TICK_INTERVAL: Duration = Duration::from_millis(500); -const LIM_TEMP_THRESHOLD: f32 = 150.0; //°C +const LIM_TEMP_THRESHOLD: f32 = 71.0; //°C #[derive(Clone, Copy, Debug, PartialEq, Eq, enum_map::Enum)] pub enum State { From 583552b172dc622dd076ce18ab54aeb6a1a113cb Mon Sep 17 00:00:00 2001 From: ryescholin Date: Fri, 24 May 2024 13:06:05 -0700 Subject: [PATCH 12/13] chk --- pod-operation/src/state_machine.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index 702906f9..c626e545 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -1,16 +1,17 @@ use std::time::Duration; +use crate::components::brakes::Brakes; +use crate::components::lim_temperature::LimTemperature; +use crate::components::pressure_transducer::PressureTransducer; +use crate::components::signal_light::SignalLight; +use crate::components::wheel_encoder::WheelEncoder; + use enum_map::{enum_map, EnumMap}; use once_cell::sync::Lazy; use socketioxide::extract::AckSender; use socketioxide::{extract::SocketRef, SocketIo}; use tokio::sync::Mutex; use tracing::info; -use crate::components::brakes::Brakes; -use crate::components::pressure_transducer::PressureTransducer; -use crate::components::signal_light::SignalLight; -use crate::components::wheel_encoder::WheelEncoder; -use crate::components::lim_temperature::LimTemperature; const TICK_INTERVAL: Duration = Duration::from_millis(10); const STOP_THRESHOLD: f32 = 37.0; // Meters From e1647feb3825f45df477d292e867a9d114053950 Mon Sep 17 00:00:00 2001 From: Taesung Hwang <44419552+taesungh@users.noreply.github.com> Date: Sat, 25 May 2024 10:23:54 -0700 Subject: [PATCH 13/13] Reorder imports --- pod-operation/src/state_machine.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index c626e545..643a1b5d 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -1,11 +1,5 @@ use std::time::Duration; -use crate::components::brakes::Brakes; -use crate::components::lim_temperature::LimTemperature; -use crate::components::pressure_transducer::PressureTransducer; -use crate::components::signal_light::SignalLight; -use crate::components::wheel_encoder::WheelEncoder; - use enum_map::{enum_map, EnumMap}; use once_cell::sync::Lazy; use socketioxide::extract::AckSender; @@ -13,6 +7,12 @@ use socketioxide::{extract::SocketRef, SocketIo}; use tokio::sync::Mutex; use tracing::info; +use crate::components::brakes::Brakes; +use crate::components::lim_temperature::LimTemperature; +use crate::components::pressure_transducer::PressureTransducer; +use crate::components::signal_light::SignalLight; +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