Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_NavEKF: add option to align ExtNav position when using OptFlow #26632

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions libraries/AP_DAL/AP_DAL_VisualOdom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
#include "AP_DAL.h"
#include <AP_Vehicle/AP_Vehicle_Type.h>

// request sensor's yaw be aligned with vehicle's AHRS/EKF attitude
void AP_DAL_VisualOdom::request_align_yaw_to_ahrs()
{
#if !APM_BUILD_TYPE(APM_BUILD_AP_DAL_Standalone)
auto *vo = AP::visualodom();
vo->request_align_yaw_to_ahrs();
#endif
}

/*
update position offsets to align to AHRS position
should only be called when this library is not being used as the position source
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_DAL/AP_DAL_VisualOdom.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class AP_DAL_VisualOdom {
return RVOH.pos_offset;
}

// request sensor's yaw be aligned with vehicle's AHRS/EKF attitude
void request_align_yaw_to_ahrs();

// update position offsets to align to AHRS position
// should only be called when this library is not being used as the position source
void align_position_to_ahrs(bool align_xy, bool align_z);
Expand Down
14 changes: 14 additions & 0 deletions libraries/AP_NavEKF/AP_NavEKF_Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,20 @@ void AP_NavEKF_Source::align_inactive_sources()
}
}
visual_odom->align_position_to_ahrs(align_posxy, align_posz);

// consider aligning yaw:
if ((getYawSource() == SourceYaw::COMPASS) ||
(getYawSource() == SourceYaw::GPS) ||
(getYawSource() == SourceYaw::GPS_COMPASS_FALLBACK) ||
(getYawSource() == SourceYaw::GSF)) {
for (uint8_t i=0; i<AP_NAKEKF_SOURCE_SET_MAX; i++) {
if (_source_set[i].yaw == SourceYaw::EXTNAV) {
// ExtNav could potentially be used, so align it
visual_odom->request_align_yaw_to_ahrs();
break;
}
}
}
#endif
}

Expand Down
Loading