mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 17:23:34 +08:00
Add mag bias estimator to CAN GPS units with IMUs
- run `sensors` hub to process sensor_mag and publish vehicle_magnetometer - update uavcannode to use vehicle_magnetometer
This commit is contained in:
@@ -116,4 +116,4 @@ PARAM_DEFINE_INT32(SENS_MAG_MODE, 1);
|
||||
* @category system
|
||||
* @group Sensors
|
||||
*/
|
||||
PARAM_DEFINE_INT32(SENS_MAG_AUTOCAL, 0);
|
||||
PARAM_DEFINE_INT32(SENS_MAG_AUTOCAL, 1);
|
||||
|
||||
@@ -205,6 +205,8 @@ void VehicleMagnetometer::UpdateMagBiasEstimate()
|
||||
if (_param_sens_mag_autocal.get() && !_armed && mag_bias_est.stable[mag_index]
|
||||
&& (_calibration[mag_index].device_id() != 0) && !_calibration[mag_index].calibrated()) {
|
||||
|
||||
const Vector3f old_offset = _calibration[mag_index].offset();
|
||||
|
||||
// set initial mag calibration
|
||||
const Vector3f offset = _calibration[mag_index].BiasCorrectedSensorOffset(_calibration_estimator_bias[mag_index]);
|
||||
|
||||
@@ -212,6 +214,13 @@ void VehicleMagnetometer::UpdateMagBiasEstimate()
|
||||
// save parameters with preferred calibration slot to current sensor index
|
||||
_calibration[mag_index].ParametersSave(mag_index);
|
||||
|
||||
PX4_INFO("mag %d (%" PRIu32 ") setting offsets [%.3f, %.3f, %.3f]->[%.3f, %.3f, %.3f]",
|
||||
mag_index, _calibration[mag_index].device_id(),
|
||||
(double)old_offset(0), (double)old_offset(1), (double)old_offset(2),
|
||||
(double)_calibration[mag_index].offset()(0),
|
||||
(double)_calibration[mag_index].offset()(1),
|
||||
(double)_calibration[mag_index].offset()(2));
|
||||
|
||||
_calibration_estimator_bias[mag_index].zero();
|
||||
|
||||
parameters_notify = true;
|
||||
|
||||
Reference in New Issue
Block a user