mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 09:23:33 +08:00
msgs/sensor_mag: remove unused raw, add timestamp_asmple, shrink error count
- move mpu9250 sensitivity handling back to driver (this isn't common)
This commit is contained in:
@@ -148,7 +148,7 @@ bool MPU9250_mag::_measure(const hrt_abstime ×tamp_sample, const ak8963_reg
|
||||
int16_t x = combine(data.HXH, data.HXL);
|
||||
int16_t y = -combine(data.HYH, data.HYL);
|
||||
int16_t z = -combine(data.HZH, data.HZL);
|
||||
_px4_mag.update(timestamp_sample, x, y, z);
|
||||
_px4_mag.update(timestamp_sample, x * _ak8963_ASA[0], y * _ak8963_ASA[1], z * _ak8963_ASA[2]);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -244,19 +244,17 @@ MPU9250_mag::ak8963_read_adjustments()
|
||||
|
||||
write_reg_through_mpu9250(AK8963REG_CNTL1, AK8963_POWERDOWN_MODE);
|
||||
|
||||
float ak8963_ASA[3] {};
|
||||
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (0 != response[i] && 0xff != response[i]) {
|
||||
ak8963_ASA[i] = ((float)(response[i] - 128) / 256.0f) + 1.0f;
|
||||
_ak8963_ASA[i] = ((float)(response[i] - 128) / 256.0f) + 1.0f;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_px4_mag.set_sensitivity(ak8963_ASA[0], ak8963_ASA[1], ak8963_ASA[2]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,8 @@ private:
|
||||
|
||||
MPU9250 *_parent;
|
||||
|
||||
float _ak8963_ASA[3] {1.f, 1.f, 1.f};
|
||||
|
||||
bool _mag_reading_data{false};
|
||||
|
||||
perf_counter_t _mag_overruns;
|
||||
|
||||
Reference in New Issue
Block a user