1- use std:: { collections:: VecDeque , time:: Duration } ;
1+ use core:: panic;
2+ use std:: { collections:: VecDeque , time:: SystemTime } ;
23
34use color_eyre:: Result ;
4- use coordinate_systems:: { Field , Robot } ;
55use hardware:: PathsInterface ;
6- use linear_algebra:: { Orientation3 , Vector2 , Vector3 } ;
7- use num_traits:: float:: TotalOrder ;
86use serde:: { Deserialize , Serialize } ;
97
108use context_attribute:: context;
119use framework:: { deserialize_not_implemented, MainOutput } ;
1210use 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 ) ]
1814pub struct FallStateDetection {
@@ -55,7 +51,7 @@ pub struct CycleContext {
5551#[ context]
5652#[ derive( Default ) ]
5753pub struct MainOutputs {
58- pub fall_state : MainOutput < FallState > ,
54+ pub fall_state_tinyml : MainOutput < FallState > ,
5955}
6056
6157impl 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