File tree Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -63,13 +63,12 @@ impl OrientationFilter {
6363 . sensor_data
6464 . inertial_measurement_unit
6565 . linear_acceleration ;
66+ let angular_velocity_sum = measured_angular_velocity. abs ( ) . inner . sum ( ) ;
6667
6768 let mut recalibrated_this_cycle = false ;
6869 match & mut self . calibration_state {
6970 State :: WaitingForSteady => {
70- if measured_angular_velocity. abs ( ) . inner . sum ( )
71- < * context. calibration_steady_threshold
72- {
71+ if angular_velocity_sum < * context. calibration_steady_threshold {
7372 self . calibration_state = State :: CalibratingGravity {
7473 filtered_gravity : LowPassFilter :: with_smoothing_factor (
7574 measured_acceleration,
@@ -83,9 +82,7 @@ impl OrientationFilter {
8382 filtered_gravity,
8483 number_of_cycles,
8584 } => ' update: {
86- if measured_angular_velocity. abs ( ) . inner . sum ( )
87- >= * context. calibration_steady_threshold
88- {
85+ if angular_velocity_sum >= * context. calibration_steady_threshold {
8986 self . calibration_state = State :: WaitingForSteady ;
9087 break ' update;
9188 }
Original file line number Diff line number Diff line change @@ -80,12 +80,11 @@ impl SensorDataReceiver {
8080 let measured_angular_velocity = sensor_data. inertial_measurement_unit . angular_velocity ;
8181 let measured_acceleration = sensor_data. inertial_measurement_unit . linear_acceleration ;
8282 let measured_roll_pitch = sensor_data. inertial_measurement_unit . roll_pitch ;
83+ let angular_velocity_sum = measured_angular_velocity. abs ( ) . inner . sum ( ) ;
8384
8485 match & mut self . calibration_state {
8586 State :: WaitingForSteady => {
86- if measured_angular_velocity. abs ( ) . inner . sum ( )
87- < * context. calibration_steady_threshold
88- {
87+ if angular_velocity_sum < * context. calibration_steady_threshold {
8988 self . calibration_state = State :: CalibratingGravity {
9089 filtered_gravity : LowPassFilter :: with_smoothing_factor (
9190 measured_acceleration,
@@ -104,9 +103,7 @@ impl SensorDataReceiver {
104103 filtered_roll_pitch,
105104 remaining_cycles,
106105 } => {
107- if measured_angular_velocity. abs ( ) . inner . sum ( )
108- < * context. calibration_steady_threshold
109- {
106+ if angular_velocity_sum < * context. calibration_steady_threshold {
110107 filtered_gravity. update ( measured_acceleration) ;
111108 filtered_roll_pitch. update ( measured_roll_pitch) ;
112109 * remaining_cycles -= 1 ;
You can’t perform that action at this time.
0 commit comments