Skip to content

Commit eed680c

Browse files
committed
[NAV] Add accelerometer weight scale to DEBUG_VIBE
1 parent 8b3ecad commit eed680c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/main/flight/imu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ void imuCheckVibrationLevels(void)
580580
DEBUG_SET(DEBUG_VIBE, 1, accVibeLevels.y * 100);
581581
DEBUG_SET(DEBUG_VIBE, 2, accVibeLevels.z * 100);
582582
DEBUG_SET(DEBUG_VIBE, 3, accClipCount);
583+
// DEBUG_VIBE values 4-7 are used by NAV estimator
583584
}
584585

585586
void FAST_CODE NOINLINE imuUpdateAttitude(timeUs_t currentTimeUs)

src/main/navigation/navigation_pos_estimator.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#if defined(USE_NAV)
2626

2727
#include "build/build_config.h"
28+
#include "build/debug.h"
2829

2930
#include "common/axis.h"
3031
#include "common/log.h"
@@ -367,12 +368,17 @@ static void updateIMUEstimationWeight(const float dt)
367368
const float relAlpha = dt / (dt + INAV_ACC_CLIPPING_RC_CONSTANT);
368369
posEstimator.imu.accWeightFactor = posEstimator.imu.accWeightFactor * (1.0f - relAlpha) + 1.0f * relAlpha;
369370
}
371+
372+
// DEBUG_VIBE[0-3] are used in IMU
373+
DEBUG_SET(DEBUG_VIBE, 4, posEstimator.imu.accWeightFactor * 1000);
370374
}
371375

372376
float navGetAccelerometerWeight(void)
373377
{
374-
// TODO(digitalentity): consider accelerometer health in weight calculation
375-
return posEstimator.imu.accWeightFactor * positionEstimationConfig()->w_xyz_acc_p;
378+
const float accWeightScaled = posEstimator.imu.accWeightFactor * positionEstimationConfig()->w_xyz_acc_p;
379+
DEBUG_SET(DEBUG_VIBE, 5, accWeightScaled * 1000);
380+
381+
return accWeightScaled;
376382
}
377383

378384
static void updateIMUTopic(timeUs_t currentTimeUs)

0 commit comments

Comments
 (0)