Skip to content

Commit

Permalink
[NAV] Add accelerometer weight scale to DEBUG_VIBE
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalentity committed May 6, 2019
1 parent 7598f22 commit 0428b70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/flight/imu.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ void imuCheckVibrationLevels(void)
DEBUG_SET(DEBUG_VIBE, 1, accVibeLevels.y * 100);
DEBUG_SET(DEBUG_VIBE, 2, accVibeLevels.z * 100);
DEBUG_SET(DEBUG_VIBE, 3, accClipCount);
// DEBUG_VIBE values 4-7 are used by NAV estimator
}

void FAST_CODE NOINLINE imuUpdateAttitude(timeUs_t currentTimeUs)
Expand Down
10 changes: 8 additions & 2 deletions src/main/navigation/navigation_pos_estimator.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#if defined(USE_NAV)

#include "build/build_config.h"
#include "build/debug.h"

#include "common/axis.h"
#include "common/log.h"
Expand Down Expand Up @@ -367,12 +368,17 @@ static void updateIMUEstimationWeight(const float dt)
const float relAlpha = dt / (dt + INAV_ACC_CLIPPING_RC_CONSTANT);
posEstimator.imu.accWeightFactor = posEstimator.imu.accWeightFactor * (1.0f - relAlpha) + 1.0f * relAlpha;
}

// DEBUG_VIBE[0-3] are used in IMU
DEBUG_SET(DEBUG_VIBE, 4, posEstimator.imu.accWeightFactor * 1000);
}

float navGetAccelerometerWeight(void)
{
// TODO(digitalentity): consider accelerometer health in weight calculation
return posEstimator.imu.accWeightFactor * positionEstimationConfig()->w_xyz_acc_p;
const float accWeightScaled = posEstimator.imu.accWeightFactor * positionEstimationConfig()->w_xyz_acc_p;
DEBUG_SET(DEBUG_VIBE, 5, accWeightScaled * 1000);

return accWeightScaled;
}

static void updateIMUTopic(timeUs_t currentTimeUs)
Expand Down

0 comments on commit 0428b70

Please sign in to comment.