Skip to content

Commit

Permalink
ekf2: do not inline getPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
bresch committed Nov 22, 2024
1 parent a224d38 commit 93c690f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
20 changes: 20 additions & 0 deletions src/modules/ekf2/EKF/estimator_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,26 @@ bool EstimatorInterface::initialise_interface(uint64_t timestamp)
return true;
}

Vector3f EstimatorInterface::getPosition() const
{
LatLonAlt lla = _output_predictor.getLatLonAlt();
float x;
float y;

if (_local_origin_lat_lon.isInitialized()) {
_local_origin_lat_lon.project(lla.latitude_deg(), lla.longitude_deg(), x, y);

} else {
MapProjection zero_ref;
zero_ref.initReference(0.0, 0.0);
zero_ref.project(lla.latitude_deg(), lla.longitude_deg(), x, y);
}

const float z = -(lla.altitude() - getEkfGlobalOriginAltitude());

return Vector3f(x, y, z);
}

bool EstimatorInterface::isOnlyActiveSourceOfHorizontalAiding(const bool aiding_flag) const
{
return aiding_flag && !isOtherSourceOfHorizontalAidingThan(aiding_flag);
Expand Down
20 changes: 1 addition & 19 deletions src/modules/ekf2/EKF/estimator_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,25 +242,7 @@ class EstimatorInterface
Vector3f getVelocity() const { return _output_predictor.getVelocity(); }
const Vector3f &getVelocityDerivative() const { return _output_predictor.getVelocityDerivative(); }
float getVerticalPositionDerivative() const { return _output_predictor.getVerticalPositionDerivative(); }
Vector3f getPosition() const
{
LatLonAlt lla = _output_predictor.getLatLonAlt();
float x;
float y;

if (_local_origin_lat_lon.isInitialized()) {
_local_origin_lat_lon.project(lla.latitude_deg(), lla.longitude_deg(), x, y);

} else {
MapProjection zero_ref;
zero_ref.initReference(0.0, 0.0);
zero_ref.project(lla.latitude_deg(), lla.longitude_deg(), x, y);
}

const float z = -(lla.altitude() - getEkfGlobalOriginAltitude());

return Vector3f(x, y, z);
}
Vector3f getPosition() const;
LatLonAlt getLatLonAlt() const { return _output_predictor.getLatLonAlt(); }
const Vector3f &getOutputTrackingError() const { return _output_predictor.getOutputTrackingError(); }

Expand Down

0 comments on commit 93c690f

Please sign in to comment.