AccelCal: Continously report success/failure to the GCS that requested the calibration

This commit is contained in:
Michael du Breuil 2017-05-29 14:03:36 -07:00 committed by Francisco Ferreira
parent c62e79b5c0
commit 6830a8b86c
2 changed files with 26 additions and 2 deletions

View File

@ -156,6 +156,23 @@ void AP_AccelCal::update()
fail();
return;
}
} else if (_last_result != ACCEL_CAL_NOT_STARTED) {
// only continuously report if we have ever completed a calibration
uint32_t now = AP_HAL::millis();
if (now - _last_position_request_ms > AP_ACCELCAL_POSITION_REQUEST_INTERVAL_MS) {
_last_position_request_ms = now;
switch (_last_result) {
case ACCEL_CAL_SUCCESS:
_gcs->send_accelcal_vehicle_position(ACCELCAL_VEHICLE_POS_SUCCESS);
break;
case ACCEL_CAL_FAILED:
_gcs->send_accelcal_vehicle_position(ACCELCAL_VEHICLE_POS_FAILED);
break;
default:
// should never hit this state
break;
}
}
}
}
@ -181,6 +198,8 @@ void AP_AccelCal::start(GCS_MAVLINK *gcs)
_last_position_request_ms = 0;
_step = 0;
_last_result = ACCEL_CAL_NOT_STARTED;
update_status();
}
@ -192,6 +211,8 @@ void AP_AccelCal::success()
_clients[i]->_acal_event_success();
}
_last_result = ACCEL_CAL_SUCCESS;
clear();
}
@ -203,6 +224,8 @@ void AP_AccelCal::cancel()
_clients[i]->_acal_event_cancellation();
}
_last_result = ACCEL_CAL_NOT_STARTED;
clear();
}
@ -214,6 +237,8 @@ void AP_AccelCal::fail()
_clients[i]->_acal_event_failure();
}
_last_result = ACCEL_CAL_FAILED;
clear();
}
@ -228,8 +253,6 @@ void AP_AccelCal::clear()
cal->clear();
}
_gcs = nullptr;
_step = 0;
_started = false;
_saving = false;

View File

@ -39,6 +39,7 @@ private:
uint32_t _last_position_request_ms;
uint8_t _step;
accel_cal_status_t _status;
accel_cal_status_t _last_result;
static uint8_t _num_clients;
static AP_AccelCal_Client* _clients[AP_ACCELCAL_MAX_NUM_CLIENTS];