Browse Source

AP_InertialSensor: inform maximum gyro average difference

While at it, define GYRO_INIT_MAX_DIFF_DPS.
master
Gustavo Jose de Sousa 9 years ago committed by Lucas De Marchi
parent
commit
e85ac8b2c5
  1. 10
      libraries/AP_InertialSensor/AP_InertialSensor.cpp

10
libraries/AP_InertialSensor/AP_InertialSensor.cpp

@ -53,6 +53,8 @@ extern const AP_HAL::HAL& hal;
#define SAMPLE_UNIT 1 #define SAMPLE_UNIT 1
#define GYRO_INIT_MAX_DIFF_DPS 0.1f
// Class level parameters // Class level parameters
const AP_Param::GroupInfo AP_InertialSensor::var_info[] = { const AP_Param::GroupInfo AP_InertialSensor::var_info[] = {
// @Param: PRODUCT_ID // @Param: PRODUCT_ID
@ -862,7 +864,7 @@ AP_InertialSensor::_init_gyro()
if (best_diff[k] < 0) { if (best_diff[k] < 0) {
best_diff[k] = diff_norm[k]; best_diff[k] = diff_norm[k];
best_avg[k] = gyro_avg[k]; best_avg[k] = gyro_avg[k];
} else if (gyro_diff[k].length() < ToRad(0.1f)) { } else if (gyro_diff[k].length() < ToRad(GYRO_INIT_MAX_DIFF_DPS)) {
// we want the average to be within 0.1 bit, which is 0.04 degrees/s // we want the average to be within 0.1 bit, which is 0.04 degrees/s
last_average[k] = (gyro_avg[k] * 0.5f) + (last_average[k] * 0.5f); last_average[k] = (gyro_avg[k] * 0.5f) + (last_average[k] * 0.5f);
if (!converged[k] || last_average[k].length() < new_gyro_offset[k].length()) { if (!converged[k] || last_average[k].length() < new_gyro_offset[k].length()) {
@ -885,8 +887,10 @@ AP_InertialSensor::_init_gyro()
hal.console->println(); hal.console->println();
for (uint8_t k=0; k<num_gyros; k++) { for (uint8_t k=0; k<num_gyros; k++) {
if (!converged[k]) { if (!converged[k]) {
hal.console->printf("gyro[%u] did not converge: diff=%f dps\n", hal.console->printf("gyro[%u] did not converge: diff=%f dps (expected < %f)\n",
(unsigned)k, (double)ToDeg(best_diff[k])); (unsigned)k,
(double)ToDeg(best_diff[k]),
(double)GYRO_INIT_MAX_DIFF_DPS);
_gyro_offset[k] = best_avg[k]; _gyro_offset[k] = best_avg[k];
// flag calibration as failed for this gyro // flag calibration as failed for this gyro
_gyro_cal_ok[k] = false; _gyro_cal_ok[k] = false;

Loading…
Cancel
Save