-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
NicolasM0
wants to merge
1
commit into
PX4:main
Choose a base branch
from
NicolasM0:vehicle_local_acceleration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+20
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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; | ||||||
vel_integ_duration_ += imu_sample_new.delta_vel_dt; | ||||||
|
||||||
// integrate time to monitor time slippage | ||||||
if (_start_time_us > 0) { | ||||||
_integrated_time_us += imu_dt; | ||||||
|
@@ -1555,10 +1559,19 @@ void EKF2::PublishLocalPosition(const hrt_abstime ×tamp) | |||||
lpos.z_deriv = _ekf.getVerticalPositionDerivative(); | ||||||
|
||||||
// Acceleration of body origin in local frame | ||||||
const Vector3f vel_deriv{_ekf.getVelocityDerivative()}; | ||||||
lpos.ax = vel_deriv(0); | ||||||
lpos.ay = vel_deriv(1); | ||||||
lpos.az = vel_deriv(2); | ||||||
if (vel_integ_duration_ > 0.001f) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
lpos.ax = delta_vel_(0) / vel_integ_duration_; | ||||||
lpos.ay = delta_vel_(1) / vel_integ_duration_; | ||||||
lpos.az = delta_vel_(2) / vel_integ_duration_; | ||||||
|
||||||
} else { | ||||||
lpos.ax = 0.f; | ||||||
lpos.ay = 0.f; | ||||||
lpos.az = 0.f; | ||||||
} | ||||||
|
||||||
delta_vel_.setZero(); | ||||||
vel_integ_duration_ = 0.f; | ||||||
|
||||||
lpos.xy_valid = _ekf.isLocalHorizontalPositionValid(); | ||||||
lpos.v_xy_valid = _ekf.isLocalHorizontalPositionValid(); | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
float vel_integ_duration_{0}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
InFlightCalibration _accel_cal{}; | ||||||
InFlightCalibration _gyro_cal{}; | ||||||
|
||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.