Skip to content

Commit

Permalink
AP_ExternalAHRS: added set_origin() call
Browse files Browse the repository at this point in the history
and remove code that aligns origin to AHRS, this will be handled by
the AHRS common origin logic
  • Loading branch information
tridge committed Aug 15, 2024
1 parent c17849f commit b3f4fa0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
23 changes: 11 additions & 12 deletions libraries/AP_ExternalAHRS/AP_ExternalAHRS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,17 @@ bool AP_ExternalAHRS::get_origin(Location &loc)
return false;
}

bool AP_ExternalAHRS::set_origin(const Location &loc)
{
WITH_SEMAPHORE(state.sem);
if (state.have_origin) {
return false;
}
state.origin = loc;
state.have_origin = true;
return true;
}

bool AP_ExternalAHRS::get_location(Location &loc)
{
if (!state.have_location) {
Expand Down Expand Up @@ -312,19 +323,7 @@ void AP_ExternalAHRS::update(void)
backend->update();
}

/*
if backend has not supplied an origin and AHRS has an origin
then use that origin so we get a common origin for minimum
disturbance when switching backends
*/
WITH_SEMAPHORE(state.sem);
if (!state.have_origin) {
Location origin;
if (AP::ahrs().get_origin(origin)) {
state.origin = origin;
state.have_origin = true;
}
}
#if HAL_LOGGING_ENABLED
const uint32_t now_ms = AP_HAL::millis();
if (log_rate.get() > 0 && now_ms - last_log_ms >= uint32_t(1000U/log_rate.get())) {
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_ExternalAHRS/AP_ExternalAHRS.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class AP_ExternalAHRS {
bool initialised(void) const;
bool get_quaternion(Quaternion &quat);
bool get_origin(Location &loc);
bool set_origin(const Location &loc);
bool get_location(Location &loc);
Vector2f get_groundspeed_vector();
bool get_velocity_NED(Vector3f &vel);
Expand Down

0 comments on commit b3f4fa0

Please sign in to comment.