mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-25 17:25:18 +03:00
Debug vibration
This commit is contained in:
parent
ce3abc0ad3
commit
c74905cbfd
5 changed files with 26 additions and 4 deletions
|
@ -61,6 +61,7 @@ typedef enum {
|
||||||
DEBUG_STAGE2,
|
DEBUG_STAGE2,
|
||||||
DEBUG_WIND_ESTIMATOR,
|
DEBUG_WIND_ESTIMATOR,
|
||||||
DEBUG_SAG_COMP_VOLTAGE,
|
DEBUG_SAG_COMP_VOLTAGE,
|
||||||
|
DEBUG_VIBE,
|
||||||
DEBUG_COUNT
|
DEBUG_COUNT
|
||||||
} debugType_e;
|
} debugType_e;
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ tables:
|
||||||
- name: i2c_speed
|
- name: i2c_speed
|
||||||
values: ["400KHZ", "800KHZ", "100KHZ", "200KHZ"]
|
values: ["400KHZ", "800KHZ", "100KHZ", "200KHZ"]
|
||||||
- name: debug_modes
|
- name: debug_modes
|
||||||
values: ["NONE", "GYRO", "NOTCH", "NAV_LANDING", "FW_ALTITUDE", "AGL", "FLOW_RAW", "FLOW", "SBUS", "FPORT", "ALWAYS", "STAGE2", "WIND_ESTIMATOR", "SAG_COMP_VOLTAGE"]
|
values: ["NONE", "GYRO", "NOTCH", "NAV_LANDING", "FW_ALTITUDE", "AGL", "FLOW_RAW", "FLOW", "SBUS", "FPORT", "ALWAYS", "STAGE2", "WIND_ESTIMATOR", "SAG_COMP_VOLTAGE", "VIBE"]
|
||||||
- name: async_mode
|
- name: async_mode
|
||||||
values: ["NONE", "GYRO", "ALL"]
|
values: ["NONE", "GYRO", "ALL"]
|
||||||
- name: aux_operator
|
- name: aux_operator
|
||||||
|
|
|
@ -548,6 +548,19 @@ void imuUpdateAccelerometer(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void imuCheckVibrationLevels(void)
|
||||||
|
{
|
||||||
|
fpVector3_t accVibeLevels;
|
||||||
|
|
||||||
|
accGetVibrationLevels(&accVibeLevels);
|
||||||
|
const uint32_t accClipCount = accGetClipCount();
|
||||||
|
|
||||||
|
DEBUG_SET(DEBUG_VIBE, 0, accVibeLevels.x * 100);
|
||||||
|
DEBUG_SET(DEBUG_VIBE, 1, accVibeLevels.y * 100);
|
||||||
|
DEBUG_SET(DEBUG_VIBE, 2, accVibeLevels.z * 100);
|
||||||
|
DEBUG_SET(DEBUG_VIBE, 3, accClipCount);
|
||||||
|
}
|
||||||
|
|
||||||
void imuUpdateAttitude(timeUs_t currentTimeUs)
|
void imuUpdateAttitude(timeUs_t currentTimeUs)
|
||||||
{
|
{
|
||||||
/* Calculate dT */
|
/* Calculate dT */
|
||||||
|
@ -560,6 +573,7 @@ void imuUpdateAttitude(timeUs_t currentTimeUs)
|
||||||
if (!hilActive) {
|
if (!hilActive) {
|
||||||
gyroGetMeasuredRotationRate(&imuMeasuredRotationBF); // Calculate gyro rate in body frame in rad/s
|
gyroGetMeasuredRotationRate(&imuMeasuredRotationBF); // Calculate gyro rate in body frame in rad/s
|
||||||
accGetMeasuredAcceleration(&imuMeasuredAccelBF); // Calculate accel in body frame in cm/s/s
|
accGetMeasuredAcceleration(&imuMeasuredAccelBF); // Calculate accel in body frame in cm/s/s
|
||||||
|
imuCheckVibrationLevels();
|
||||||
imuCalculateEstimatedAttitude(dT); // Update attitude estimate
|
imuCalculateEstimatedAttitude(dT); // Update attitude estimate
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -569,6 +583,7 @@ void imuUpdateAttitude(timeUs_t currentTimeUs)
|
||||||
#else
|
#else
|
||||||
gyroGetMeasuredRotationRate(&imuMeasuredRotationBF); // Calculate gyro rate in body frame in rad/s
|
gyroGetMeasuredRotationRate(&imuMeasuredRotationBF); // Calculate gyro rate in body frame in rad/s
|
||||||
accGetMeasuredAcceleration(&imuMeasuredAccelBF); // Calculate accel in body frame in cm/s/s
|
accGetMeasuredAcceleration(&imuMeasuredAccelBF); // Calculate accel in body frame in cm/s/s
|
||||||
|
imuCheckVibrationLevels();
|
||||||
imuCalculateEstimatedAttitude(dT); // Update attitude estimate
|
imuCalculateEstimatedAttitude(dT); // Update attitude estimate
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -314,6 +314,7 @@ bool accInit(uint32_t targetLooptime)
|
||||||
acc.dev.acc_1G = 256; // set default
|
acc.dev.acc_1G = 256; // set default
|
||||||
acc.dev.initFn(&acc.dev);
|
acc.dev.initFn(&acc.dev);
|
||||||
acc.accTargetLooptime = targetLooptime;
|
acc.accTargetLooptime = targetLooptime;
|
||||||
|
acc.accClipCount = 0;
|
||||||
accInitFilters();
|
accInitFilters();
|
||||||
|
|
||||||
if (accelerometerConfig()->acc_align != ALIGN_DEFAULT) {
|
if (accelerometerConfig()->acc_align != ALIGN_DEFAULT) {
|
||||||
|
@ -541,7 +542,7 @@ void accUpdate(void)
|
||||||
|
|
||||||
// Before filtering check for clipping and vibration levels
|
// Before filtering check for clipping and vibration levels
|
||||||
if (ABS(acc.accADCf[X]) > ACC_CLIPPING_THRESHOLD_G || ABS(acc.accADCf[Y]) > ACC_CLIPPING_THRESHOLD_G || ABS(acc.accADCf[Z]) > ACC_CLIPPING_THRESHOLD_G) {
|
if (ABS(acc.accADCf[X]) > ACC_CLIPPING_THRESHOLD_G || ABS(acc.accADCf[Y]) > ACC_CLIPPING_THRESHOLD_G || ABS(acc.accADCf[Z]) > ACC_CLIPPING_THRESHOLD_G) {
|
||||||
debug[3]++;
|
acc.accClipCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate vibration levels
|
// Calculate vibration levels
|
||||||
|
@ -552,8 +553,6 @@ void accUpdate(void)
|
||||||
// calc difference from this sample and 5hz filtered value, square and filter at 2hz
|
// calc difference from this sample and 5hz filtered value, square and filter at 2hz
|
||||||
const float accDiff = acc.accADCf[axis] - accFloorFilt;
|
const float accDiff = acc.accADCf[axis] - accFloorFilt;
|
||||||
acc.accVibeSq[axis] = pt1FilterApply(&accVibeFilter[axis], accDiff * accDiff);
|
acc.accVibeSq[axis] = pt1FilterApply(&accVibeFilter[axis], accDiff * accDiff);
|
||||||
|
|
||||||
debug[axis] = acc.accVibeSq[axis] * 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter acceleration
|
// Filter acceleration
|
||||||
|
@ -588,6 +587,11 @@ float accGetVibrationLevel(void)
|
||||||
return sqrtf(acc.accVibeSq[X] + acc.accVibeSq[Y] + acc.accVibeSq[Z]);
|
return sqrtf(acc.accVibeSq[X] + acc.accVibeSq[Y] + acc.accVibeSq[Z]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t accGetClipCount(void)
|
||||||
|
{
|
||||||
|
return acc.accClipCount;
|
||||||
|
}
|
||||||
|
|
||||||
void accSetCalibrationValues(void)
|
void accSetCalibrationValues(void)
|
||||||
{
|
{
|
||||||
if ((accelerometerConfig()->accZero.raw[X] == 0) && (accelerometerConfig()->accZero.raw[Y] == 0) && (accelerometerConfig()->accZero.raw[Z] == 0) &&
|
if ((accelerometerConfig()->accZero.raw[X] == 0) && (accelerometerConfig()->accZero.raw[Y] == 0) && (accelerometerConfig()->accZero.raw[Z] == 0) &&
|
||||||
|
|
|
@ -53,6 +53,7 @@ typedef struct acc_s {
|
||||||
uint32_t accTargetLooptime;
|
uint32_t accTargetLooptime;
|
||||||
float accADCf[XYZ_AXIS_COUNT]; // acceleration in g
|
float accADCf[XYZ_AXIS_COUNT]; // acceleration in g
|
||||||
float accVibeSq[XYZ_AXIS_COUNT];
|
float accVibeSq[XYZ_AXIS_COUNT];
|
||||||
|
uint32_t accClipCount;
|
||||||
} acc_t;
|
} acc_t;
|
||||||
|
|
||||||
extern acc_t acc;
|
extern acc_t acc;
|
||||||
|
@ -75,6 +76,7 @@ void accSetCalibrationCycles(uint16_t calibrationCyclesRequired);
|
||||||
void accGetMeasuredAcceleration(fpVector3_t *measuredAcc);
|
void accGetMeasuredAcceleration(fpVector3_t *measuredAcc);
|
||||||
void accGetVibrationLevels(fpVector3_t *accVibeLevels);
|
void accGetVibrationLevels(fpVector3_t *accVibeLevels);
|
||||||
float accGetVibrationLevel(void);
|
float accGetVibrationLevel(void);
|
||||||
|
uint32_t accGetClipCount(void);
|
||||||
void accUpdate(void);
|
void accUpdate(void);
|
||||||
void accSetCalibrationValues(void);
|
void accSetCalibrationValues(void);
|
||||||
void accInitFilters(void);
|
void accInitFilters(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue