Skip to content

Commit

Permalink
attitude_q : verbose failure reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkabir committed Nov 14, 2015
1 parent 0d7cd22 commit 5a1f7ca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/lib/ecl/validation/data_validator_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ DataValidatorGroup::failover_index()
unsigned i = 0;

while (next != nullptr) {
if (next->used() && (next->state() != DataValidator::ERROR_FLAG_NO_ERROR) && (i == _prev_best)) {
if (next->used() && (next->state() != DataValidator::ERROR_FLAG_NO_ERROR) && (i == (unsigned)_prev_best)) {
return i;
}
next = next->sibling();
Expand All @@ -256,7 +256,7 @@ DataValidatorGroup::failover_state()
unsigned i = 0;

while (next != nullptr) {
if (next->used() && (next->state() != DataValidator::ERROR_FLAG_NO_ERROR) && (i == _prev_best)) {
if (next->used() && (next->state() != DataValidator::ERROR_FLAG_NO_ERROR) && (i == (unsigned)_prev_best)) {
return next->state();
}
next = next->sibling();
Expand Down
35 changes: 30 additions & 5 deletions src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,17 @@ void AttitudeEstimatorQ::task_main()

_voter_gyro.put(i, sensors.gyro_timestamp[i], &gyro[0], sensors.gyro_errcount[i], sensors.gyro_priority[i]);
}

/* ignore empty fields */
if (sensors.accelerometer_timestamp[i] > 0) {
_voter_accel.put(i, sensors.accelerometer_timestamp[i], &sensors.accelerometer_m_s2[i * 3],
sensors.accelerometer_errcount[i], sensors.accelerometer_priority[i]);
sensors.accelerometer_errcount[i], sensors.accelerometer_priority[i]);
}

/* ignore empty fields */
if (sensors.magnetometer_timestamp[i] > 0) {
_voter_mag.put(i, sensors.magnetometer_timestamp[i], &sensors.magnetometer_ga[i * 3],
sensors.magnetometer_errcount[i], sensors.magnetometer_priority[i]);
sensors.magnetometer_errcount[i], sensors.magnetometer_priority[i]);
}
}

Expand All @@ -375,19 +377,42 @@ void AttitudeEstimatorQ::task_main()
_data_good = true;

if (!_failsafe) {
uint32_t flags = DataValidator::ERROR_FLAG_NO_ERROR;

if (_voter_gyro.failover_count() > 0) {
_failsafe = true;
mavlink_and_console_log_emergency(_mavlink_fd, "Gyro failure!");
flags = _voter_gyro.failover_state();
mavlink_and_console_log_emergency(_mavlink_fd, "Gyro #%i failure :%s%s%s%s%s!",
_voter_gyro.failover_index(),
((flags & DataValidator::ERROR_FLAG_NO_DATA) ? " No data" : ""),
((flags & DataValidator::ERROR_FLAG_STALE_DATA) ? " Stale data" : ""),
((flags & DataValidator::ERROR_FLAG_TIMEOUT) ? " Data timeout" : ""),
((flags & DataValidator::ERROR_FLAG_HIGH_ERRCOUNT) ? " High error count" : ""),
((flags & DataValidator::ERROR_FLAG_HIGH_ERRDENSITY) ? " High error density" : ""));
}

if (_voter_accel.failover_count() > 0) {
_failsafe = true;
mavlink_and_console_log_emergency(_mavlink_fd, "Accel failure!");
flags = _voter_accel.failover_state();
mavlink_and_console_log_emergency(_mavlink_fd, "Accel #%i failure :%s%s%s%s%s!",
_voter_accel.failover_index(),
((flags & DataValidator::ERROR_FLAG_NO_DATA) ? " No data" : ""),
((flags & DataValidator::ERROR_FLAG_STALE_DATA) ? " Stale data" : ""),
((flags & DataValidator::ERROR_FLAG_TIMEOUT) ? " Data timeout" : ""),
((flags & DataValidator::ERROR_FLAG_HIGH_ERRCOUNT) ? " High error count" : ""),
((flags & DataValidator::ERROR_FLAG_HIGH_ERRDENSITY) ? " High error density" : ""));
}

if (_voter_mag.failover_count() > 0) {
_failsafe = true;
mavlink_and_console_log_emergency(_mavlink_fd, "Mag failure!");
flags = _voter_mag.failover_state();
mavlink_and_console_log_emergency(_mavlink_fd, "Mag #%i failure :%s%s%s%s%s!",
_voter_mag.failover_index(),
((flags & DataValidator::ERROR_FLAG_NO_DATA) ? " No data" : ""),
((flags & DataValidator::ERROR_FLAG_STALE_DATA) ? " Stale data" : ""),
((flags & DataValidator::ERROR_FLAG_TIMEOUT) ? " Data timeout" : ""),
((flags & DataValidator::ERROR_FLAG_HIGH_ERRCOUNT) ? " High error count" : ""),
((flags & DataValidator::ERROR_FLAG_HIGH_ERRDENSITY) ? " High error density" : ""));
}

if (_failsafe) {
Expand Down

0 comments on commit 5a1f7ca

Please # to comment.