File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -66,9 +66,10 @@ impl OrientationFilter {
6666 let angular_velocity_sum = measured_angular_velocity. abs ( ) . inner . sum ( ) ;
6767
6868 let mut recalibrated_this_cycle = false ;
69+ let is_steady = angular_velocity_sum < * context. calibration_steady_threshold ;
6970 match & mut self . calibration_state {
7071 State :: WaitingForSteady => {
71- if angular_velocity_sum < * context . calibration_steady_threshold {
72+ if is_steady {
7273 self . calibration_state = State :: CalibratingGravity {
7374 filtered_gravity : LowPassFilter :: with_smoothing_factor (
7475 measured_acceleration,
@@ -82,7 +83,7 @@ impl OrientationFilter {
8283 filtered_gravity,
8384 number_of_cycles,
8485 } => ' update: {
85- if angular_velocity_sum >= * context . calibration_steady_threshold {
86+ if !is_steady {
8687 self . calibration_state = State :: WaitingForSteady ;
8788 break ' update;
8889 }
Original file line number Diff line number Diff line change @@ -82,9 +82,10 @@ impl SensorDataReceiver {
8282 let measured_roll_pitch = sensor_data. inertial_measurement_unit . roll_pitch ;
8383 let angular_velocity_sum = measured_angular_velocity. abs ( ) . inner . sum ( ) ;
8484
85+ let is_steady = angular_velocity_sum < * context. calibration_steady_threshold ;
8586 match & mut self . calibration_state {
8687 State :: WaitingForSteady => {
87- if angular_velocity_sum < * context . calibration_steady_threshold {
88+ if is_steady {
8889 self . calibration_state = State :: CalibratingGravity {
8990 filtered_gravity : LowPassFilter :: with_smoothing_factor (
9091 measured_acceleration,
@@ -103,7 +104,7 @@ impl SensorDataReceiver {
103104 filtered_roll_pitch,
104105 remaining_cycles,
105106 } => {
106- if angular_velocity_sum < * context . calibration_steady_threshold {
107+ if is_steady {
107108 filtered_gravity. update ( measured_acceleration) ;
108109 filtered_roll_pitch. update ( measured_roll_pitch) ;
109110 * remaining_cycles -= 1 ;
You can’t perform that action at this time.
0 commit comments