@@ -2,7 +2,9 @@ use core::panic;
22use std:: { collections:: VecDeque , time:: SystemTime } ;
33
44use color_eyre:: Result ;
5+ use coordinate_systems:: Field ;
56use hardware:: PathsInterface ;
7+ use linear_algebra:: Orientation3 ;
68use serde:: { Deserialize , Serialize } ;
79
810use context_attribute:: context;
@@ -41,11 +43,10 @@ pub struct CycleContext {
4143 // _gravity_acceleration: Parameter<f32, "physical_constants.gravity_acceleration">,
4244 // _sitting_pose: Parameter<Joints<f32>, "fall_state_estimation.sitting_pose">,
4345 // _catching_steps_enabled: Parameter<bool, "walking_engine.catching_steps.enabled">,
44- //
45- // _robot_orientation: RequiredInput<Option<Orientation3<Field>>, "robot_orientation?">,
46- // _sensor_data: Input<SensorData, "sensor_data">,
46+ robot_orientation : RequiredInput < Option < Orientation3 < Field > > , "robot_orientation?" > ,
47+ // sensor_data: Input<SensorData, "sensor_data">,
4748 // _cycle_time: Input<CycleTime, "cycle_time">,
48- // _has_ground_contact : Input<bool, "has_ground_contact">,
49+ has_ground_contact : Input < bool , "has_ground_contact" > ,
4950}
5051
5152#[ context]
@@ -75,7 +76,12 @@ impl FallStateDetection {
7576
7677 // let cycle_start = context.cycle_time.start_time;
7778 // let inertial_measurement_unit = context.sensor_data.inertial_measurement_unit;
78- // let (roll, pitch, _) = context.robot_orientation.inner.euler_angles();
79+ let ( roll, pitch, yaw) = context. robot_orientation . inner . euler_angles ( ) ;
80+ let has_ground_contact = if * context. has_ground_contact {
81+ 1.0
82+ } else {
83+ 0.0
84+ } ;
7985
8086 let resolver = BuiltinOpResolver :: default ( ) ;
8187
@@ -98,10 +104,10 @@ impl FallStateDetection {
98104 let input_tensor = interpreter. tensor_info ( input_index) . unwrap ( ) ;
99105 // dbg!(&input_tensor.dims);
100106
101- self . data . push_back ( 0.0 ) ;
102- self . data . push_back ( 0.0 ) ;
103- self . data . push_back ( 0.0 ) ;
104- self . data . push_back ( 0.0 ) ;
107+ self . data . push_back ( pitch ) ;
108+ self . data . push_back ( roll ) ;
109+ self . data . push_back ( yaw ) ;
110+ self . data . push_back ( has_ground_contact ) ;
105111
106112 let max_size = input_tensor. dims [ 1 ] * input_tensor. dims [ 2 ] ;
107113 while self . data . len ( ) > max_size {
0 commit comments