Skip to content

Commit 53972e6

Browse files
committed
Clean up
1 parent 792fd56 commit 53972e6

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

crates/control/src/fall_state_detection.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
use std::{collections::VecDeque, time::Duration};
1+
use core::panic;
2+
use std::{collections::VecDeque, time::SystemTime};
23

34
use color_eyre::Result;
4-
use coordinate_systems::{Field, Robot};
55
use hardware::PathsInterface;
6-
use linear_algebra::{Orientation3, Vector2, Vector3};
7-
use num_traits::float::TotalOrder;
86
use serde::{Deserialize, Serialize};
97

108
use context_attribute::context;
119
use framework::{deserialize_not_implemented, MainOutput};
1210
use tflite::{ops::builtin::BuiltinOpResolver, FlatBufferModel, InterpreterBuilder};
13-
use types::{
14-
cycle_time::CycleTime, fall_state::FallState, joints::Joints, sensor_data::SensorData,
15-
};
11+
use types::fall_state::{Direction, FallState, Kind, Side};
1612

1713
#[derive(Deserialize, Serialize)]
1814
pub struct FallStateDetection {
@@ -55,7 +51,7 @@ pub struct CycleContext {
5551
#[context]
5652
#[derive(Default)]
5753
pub struct MainOutputs {
58-
pub fall_state: MainOutput<FallState>,
54+
pub fall_state_tinyml: MainOutput<FallState>,
5955
}
6056

6157
impl FallStateDetection {
@@ -122,7 +118,6 @@ impl FallStateDetection {
122118
interpreter.invoke()?;
123119

124120
let output: &[f32] = interpreter.tensor_data(output_index)?;
125-
dbg!(output);
126121

127122
let guess = output
128123
.iter()
@@ -131,10 +126,20 @@ impl FallStateDetection {
131126
.unwrap()
132127
.0;
133128

134-
dbg!(guess);
129+
let fall_state = match guess {
130+
0 => FallState::Upright,
131+
1 => FallState::Falling {
132+
start_time: SystemTime::UNIX_EPOCH,
133+
direction: Direction::Forward { side: Side::Left },
134+
},
135+
2 => FallState::Fallen {
136+
kind: Kind::FacingUp,
137+
},
138+
_ => panic!(),
139+
};
135140

136141
Ok(MainOutputs {
137-
fall_state: FallState::default().into(),
142+
fall_state_tinyml: fall_state.into(),
138143
})
139144
}
140145
}

0 commit comments

Comments
 (0)