33 #ifndef ROSFLIGHT_FIRMWARE_SENSORS_H 34 #define ROSFLIGHT_FIRMWARE_SENSORS_H 40 #pragma GCC diagnostic push 41 #pragma GCC diagnostic ignored "-Wmissing-field-initializers" // Ignore warning about leaving struct fields blank 54 #pragma GCC diagnostic push // Allow anonymous nested unions and structs 55 #pragma GCC diagnostic ignored "-Wpedantic" 116 #pragma GCC diagnostic pop 128 float imu_temperature = 0;
129 uint64_t imu_time = 0;
131 float diff_pressure_velocity = 0;
132 float diff_pressure = 0;
133 float diff_pressure_temp = 0;
134 bool diff_pressure_valid =
false;
136 float baro_altitude = 0;
137 float baro_pressure = 0;
138 float baro_temperature = 0;
139 bool baro_valid =
false;
141 float sonar_range = 0;
142 bool sonar_range_valid =
false;
145 bool gnss_new_data =
false;
147 bool gnss_present =
false;
155 bool diff_pressure_present =
false;
169 void param_change_callback(uint16_t param_id);
172 bool start_imu_calibration(
void);
173 bool start_gyro_calibration(
void);
174 bool start_baro_calibration(
void);
175 bool start_diff_pressure_calibration(
void);
176 bool gyro_calibration_complete(
void);
183 imu_data_sent_ =
true;
209 void init(
float max_change_rate,
float update_rate,
float center);
210 bool update(
float new_val,
float *val);
220 NUM_LOW_PRIORITY_SENSORS
227 float accel_[3] = {0, 0, 0};
228 float gyro_[3] = {0, 0, 0};
230 bool calibrating_acc_flag_ =
false;
231 bool calibrating_gyro_flag_ =
false;
232 uint8_t next_sensor_to_update_ = BAROMETER;
234 void calibrate_accel(
void);
235 void calibrate_gyro(
void);
236 void calibrate_baro(
void);
237 void calibrate_diff_pressure(
void);
238 void correct_imu(
void);
239 void correct_mag(
void);
240 void correct_baro(
void);
241 void correct_diff_pressure(
void);
242 bool update_imu(
void);
243 void update_other_sensors(
void);
244 void look_for_disabled_sensors(
void);
245 uint32_t last_time_look_for_disarmed_sensors_ = 0;
246 uint32_t last_imu_update_ms_ = 0;
252 uint16_t gyro_calibration_count_ = 0;
254 uint16_t accel_calibration_count_ = 0;
257 float acc_temp_sum_ = 0.0f;
268 bool baro_calibrated_ =
false;
269 float ground_pressure_ = 0.0f;
270 uint16_t baro_calibration_count_ = 0;
271 uint32_t last_baro_cal_iter_ms_ = 0;
272 float baro_calibration_mean_ = 0.0f;
273 float baro_calibration_var_ = 0.0f;
276 bool diff_pressure_calibrated_ =
false;
277 uint16_t diff_pressure_calibration_count_ = 0;
278 uint32_t last_diff_pressure_cal_iter_ms_ = 0;
279 float diff_pressure_calibration_mean_ = 0.0f;
280 float diff_pressure_calibration_var_ = 0.0f;
291 #pragma GCC diagnostic pop // End ignore missing field initializers in structs 293 #endif // ROSFLIGHT_FIRMWARE_SENSORS_H
static volatile int16_t gyro[3]
struct rosflight_firmware::GNSSData::@109 ecef
static const float DIFF_SAMPLE_RATE
static const float SONAR_SAMPLE_RATE
static const float DIFF_MAX_CHANGE_RATE
void init(const M_string &remappings)
static const float BARO_MAX_CALIBRATION_VARIANCE
OutlierFilter baro_outlier_filt_
static const float DIFF_PRESSURE_MAX_CALIBRATION_VARIANCE
OutlierFilter diff_outlier_filt_
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
uint64_t prev_imu_read_time_us_
static volatile int16_t accel[3]
static const float BARO_SAMPLE_RATE
static const int SENSOR_CAL_CYCLES
rosflight_firmware::ROSflight * rosflight
uint64_t rosflight_timestamp
bool should_send_imu_data(void)
static const float BARO_MAX_CHANGE_RATE
turbomath::Vector accel_int_
static volatile float data_[3]
turbomath::Vector gyro_int_
uint64_t rosflight_timestamp
static const float SONAR_MAX_CHANGE_RATE
const Data & data() const
static const int SENSOR_CAL_DELAY_CYCLES
OutlierFilter sonar_outlier_filt_