mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 20:23:34 +08:00
Expand auto-format coverage and tiny style changes
This commit is contained in:
committed by
Mathieu Bresciani
parent
fbdd75da2e
commit
f20726d47f
@@ -1,24 +1,18 @@
|
||||
#include "imu_down_sampler.hpp"
|
||||
|
||||
ImuDownSampler::ImuDownSampler(float target_dt_sec):
|
||||
_target_dt{target_dt_sec},
|
||||
_imu_collection_time_adj{0.0f}
|
||||
{
|
||||
ImuDownSampler::ImuDownSampler(float target_dt_sec) : _target_dt{target_dt_sec}, _imu_collection_time_adj{0.0f} {
|
||||
reset();
|
||||
_imu_down_sampled.time_us = 0.0f;
|
||||
}
|
||||
|
||||
ImuDownSampler::~ImuDownSampler()
|
||||
{
|
||||
}
|
||||
ImuDownSampler::~ImuDownSampler() {}
|
||||
|
||||
// integrate imu samples until target dt reached
|
||||
// assumes that dt of the gyroscope is close to the dt of the accelerometer
|
||||
// returns true if target dt is reached
|
||||
bool ImuDownSampler::update(imuSample imu_sample_new)
|
||||
{
|
||||
if(_do_reset)
|
||||
{
|
||||
bool ImuDownSampler::update(imuSample imu_sample_new) {
|
||||
|
||||
if (_do_reset) {
|
||||
reset();
|
||||
}
|
||||
// accumulate time deltas
|
||||
@@ -42,11 +36,11 @@ bool ImuDownSampler::update(imuSample imu_sample_new)
|
||||
|
||||
// check if the target time delta between filter prediction steps has been exceeded
|
||||
if (_imu_down_sampled.delta_ang_dt >= _target_dt - _imu_collection_time_adj) {
|
||||
|
||||
// accumulate the amount of time to advance the IMU collection time so that we meet the
|
||||
// average EKF update rate requirement
|
||||
_imu_collection_time_adj += 0.01f * (_imu_down_sampled.delta_ang_dt - _target_dt);
|
||||
_imu_collection_time_adj = math::constrain(_imu_collection_time_adj, -0.5f * _target_dt, 0.5f * _target_dt);
|
||||
_imu_collection_time_adj = math::constrain(_imu_collection_time_adj, -0.5f * _target_dt,
|
||||
0.5f * _target_dt);
|
||||
|
||||
_imu_down_sampled.delta_ang = _delta_angle_accumulated.to_axis_angle();
|
||||
|
||||
@@ -57,14 +51,12 @@ bool ImuDownSampler::update(imuSample imu_sample_new)
|
||||
}
|
||||
}
|
||||
|
||||
imuSample ImuDownSampler::getDownSampledImuAndTriggerReset()
|
||||
{
|
||||
imuSample ImuDownSampler::getDownSampledImuAndTriggerReset() {
|
||||
_do_reset = true;
|
||||
return _imu_down_sampled;
|
||||
}
|
||||
|
||||
void ImuDownSampler::reset()
|
||||
{
|
||||
void ImuDownSampler::reset() {
|
||||
_imu_down_sampled.delta_ang.setZero();
|
||||
_imu_down_sampled.delta_vel.setZero();
|
||||
_imu_down_sampled.delta_ang_dt = 0.0f;
|
||||
|
||||
Reference in New Issue
Block a user