如果使用外部视觉或者GPS的yaw角进行融合,磁力计就不会起作用,具体是noOtherYawAidingThanMag()函数起作用
EKF\mag_control.cpp
void Ekf::controlMagFusion()
{
// handle undefined behaviour
if (_params.mag_fusion_type > MAG_FUSE_TYPE_NONE) {
return;
}
// When operating without a magnetometer and no other source of yaw aiding is active,
// yaw fusion is run selectively to enable yaw gyro bias learning when stationary on
// ground and to prevent uncontrolled yaw variance growth
if (_params.mag_fusion_type == MAG_FUSE_TYPE_NONE) {
if (noOtherYawAidingThanMag())
{
_yaw_use_inhibit = true;
fuseHeading();
}
return;
}
updateMagFilter();
checkMagFieldStrength();
// If we are on ground, reset the flight alignment flag so that the mag fields will be
// re-initialised next time we achieve flight altitude
if (!_control_status.flags.in_air) {
_control_status.flags.mag_aligned_in_flight = false;
_num_bad_flight_yaw_events = 0;
}
if (_control_status.flags.mag_fault || !_control_status.flags.yaw_align) {
stopMagFusion();
return;
}
if (noOtherYawAidingThanMag() && _mag_data_ready) {
if (_control_status.flags.in_air) {
checkHaglYawResetReq();
runInAirYawReset();
runVelPosReset();
} else {
runOnGroundYawReset();
}
// Determine if we should use simple magnetic heading fusion which works better when
// there are large external disturbances or the more accurate 3-axis fusion
switch (_params.mag_fusion_type) {
case MAG_FUSE_TYPE_AUTO:
selectMagAuto();
break;
case MAG_FUSE_TYPE_INDOOR:
/* fallthrough */
case MAG_FUSE_TYPE_HEADING:
startMagHdgFusion();
break;
case MAG_FUSE_TYPE_3D:
startMag3DFusion();
break;
default:
selectMagAuto();
break;
}
checkMagDeclRequired();
checkMagInhibition();
runMagAndMagDeclFusions();
}
}
|