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

local position acceleration: use mean value between two publications #24105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NicolasM0
Copy link
Contributor

Solved Problem

On our onboard computer, we use the vehicle local position message for estimation and control purpose.
We use the acceleration fields to have a higher order than just velocity and position.

We have observed aliasing on tests with vibrations. The NED acceleration integral become very different from the velocity.

Solution

To avoid aliasing on the NED acceleration, add an accumulation of acceleration to improve the down sampling.

This implementation looks like a hack... Of course, I'm open to any suggestions for a better implementation.

Test coverage

  • Tested on an older branch (v1.14). It fixed our issue.
  • Quickly tested on this commit in SITL, acceleration seems correct.

To avoid aliasing on the ned acceleration, add an accumulation of
acceleration to improve the downsampling
@bresch
Copy link
Member

bresch commented Dec 13, 2024

For navigation you could also rather use sensor_combined and for control you could get vehicle_acceleration

Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your changes makes sense as it's better to avoid aliasing anyways

lpos.ax = vel_deriv(0);
lpos.ay = vel_deriv(1);
lpos.az = vel_deriv(2);
if (vel_integ_duration_ > 0.001f) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (vel_integ_duration_ > 0.001f) {
if (vel_integ_duration_ > FLT_EPSILON) {

@@ -280,6 +280,9 @@ class EKF2 final : public ModuleParams, public px4::ScheduledWorkItem
perf_counter_t _ekf_update_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": EKF update")};
perf_counter_t _msg_missed_imu_perf{perf_alloc(PC_COUNT, MODULE_NAME": IMU message missed")};

Vector3f delta_vel_{0.f, 0.f, 0.f};
float vel_integ_duration_{0};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
float vel_integ_duration_{0};
float _delta_vel_dt{0};

@@ -280,6 +280,9 @@ class EKF2 final : public ModuleParams, public px4::ScheduledWorkItem
perf_counter_t _ekf_update_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": EKF update")};
perf_counter_t _msg_missed_imu_perf{perf_alloc(PC_COUNT, MODULE_NAME": IMU message missed")};

Vector3f delta_vel_{0.f, 0.f, 0.f};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Vector3f delta_vel_{0.f, 0.f, 0.f};
Vector3f _delta_vel{0.f, 0.f, 0.f};

@@ -731,6 +731,10 @@ void EKF2::Run()
_ekf.setIMUData(imu_sample_new);
PublishAttitude(now); // publish attitude immediately (uses quaternion from output predictor)

// accumulate delta velocity to compute mean acceleration
delta_vel_ += _ekf.getVelocityDerivative() * imu_sample_new.delta_vel_dt;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do this directly in the output predictor so that getVelocityDerivative() returns the average.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants