Skip to content

Commit f3ec58e

Browse files
committed
changed order of calibration in systems to act upon raw rather than calibrated data
1 parent 002ac9e commit f3ec58e

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

MIDAS/src/esp_eeprom.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ ErrorCode EEPROMController::init() {
4646
MIDASEEPROM empty_setting;
4747
empty_setting.checksum = EEPROM_CHECKSUM;
4848
data = empty_setting;
49-
Serial.println("EEPROM INITIAL READ FAILED");
50-
commit(); // should we do this? essentially wipes eeprom. probably doesn't matter though if format is incompatible
49+
Serial.println("EEPROM CHECKSUM INCOMPATIBLE");
50+
// Clear EEPROM and write correct checksum
51+
commit();
5152
}
5253

5354
return ErrorCode::NoError;

MIDAS/src/hardware/IMU.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void IMUSensor::calib_reading(Acceleration lowg_reading, Acceleration highg_read
185185
if (_calib_valid_readings >= NUM_READINGS_FOR_CALIB) {
186186
float overall_offset = _calib_average / (NUM_READINGS_FOR_CALIB*2);
187187
Serial.println("[-X] Good.");
188-
calibration_sensor_bias.ax += overall_offset;
188+
calibration_sensor_bias.ax = overall_offset;
189189
_calib_average = 0.0;
190190
next_calib(buzzer_indicator, eeprom);
191191
}
@@ -213,7 +213,7 @@ void IMUSensor::calib_reading(Acceleration lowg_reading, Acceleration highg_read
213213
if (_calib_valid_readings >= NUM_READINGS_FOR_CALIB) {
214214
float overall_offset = _calib_average / (NUM_READINGS_FOR_CALIB*2);
215215
Serial.println("[-Y] Good.");
216-
calibration_sensor_bias.ay += overall_offset;
216+
calibration_sensor_bias.ay = overall_offset;
217217
_calib_average = 0.0;
218218
next_calib(buzzer_indicator, eeprom);
219219
}
@@ -242,7 +242,7 @@ void IMUSensor::calib_reading(Acceleration lowg_reading, Acceleration highg_read
242242
if (_calib_valid_readings >= NUM_READINGS_FOR_CALIB) {
243243
float overall_offset = _calib_average / (NUM_READINGS_FOR_CALIB*2);
244244
Serial.println("[-Z] Good.");
245-
calibration_sensor_bias.az += overall_offset;
245+
calibration_sensor_bias.az = overall_offset;
246246
_calib_average = 0.0;
247247
next_calib(buzzer_indicator, eeprom);
248248
}

MIDAS/src/systems.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,6 @@ DECLARE_THREAD(imuthread, RocketSystems *arg)
8383
IMU_SFLP hw_filter = arg->sensors.imu.read_sflp();
8484
xSemaphoreGive(spi_mutex);
8585

86-
// Sensor biases
87-
Acceleration bias = arg->sensors.imu.calibration_sensor_bias;
88-
89-
imudata.highg_acceleration.ax = imudata.highg_acceleration.ax + bias.ax;
90-
imudata.highg_acceleration.ay = imudata.highg_acceleration.ay + bias.ay;
91-
imudata.highg_acceleration.az = imudata.highg_acceleration.az + bias.az;
92-
93-
arg->rocket_data.imu.update(imudata);
94-
arg->rocket_data.hw_filtered.update(hw_filter);
95-
9686
// Sensor calibration, if it is triggered.
9787
if(arg->sensors.imu.calibration_state != IMUSensor::IMUCalibrationState::NONE) {
9888
arg->sensors.imu.calib_reading(imudata.lowg_acceleration, imudata.highg_acceleration, arg->buzzer, arg->eeprom);
@@ -102,6 +92,16 @@ DECLARE_THREAD(imuthread, RocketSystems *arg)
10292
arg->sensors.imu.abort_calibration(arg->buzzer, arg->eeprom);
10393
}
10494
}
95+
96+
// Sensor biases
97+
Acceleration bias = arg->sensors.imu.calibration_sensor_bias;
98+
99+
imudata.highg_acceleration.ax = imudata.highg_acceleration.ax + bias.ax;
100+
imudata.highg_acceleration.ay = imudata.highg_acceleration.ay + bias.ay;
101+
imudata.highg_acceleration.az = imudata.highg_acceleration.az + bias.az;
102+
103+
arg->rocket_data.imu.update(imudata);
104+
arg->rocket_data.hw_filtered.update(hw_filter);
105105

106106
THREAD_SLEEP(5);
107107
}

0 commit comments

Comments
 (0)