|
|
|
@ -67,38 +67,26 @@ bool AP_InertialSensor_HIL::wait_for_sample(uint16_t timeout_ms)
@@ -67,38 +67,26 @@ bool AP_InertialSensor_HIL::wait_for_sample(uint16_t timeout_ms)
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AP_InertialSensor_HIL::set_accel(const Vector3f &accel) |
|
|
|
|
void AP_InertialSensor_HIL::set_accel(uint8_t instance, const Vector3f &accel) |
|
|
|
|
{ |
|
|
|
|
_previous_accel[0] = _accel[0]; |
|
|
|
|
_accel[0] = accel; |
|
|
|
|
_last_accel_usec = hal.scheduler->micros(); |
|
|
|
|
_previous_accel[instance] = _accel[instance]; |
|
|
|
|
_accel[instance] = accel; |
|
|
|
|
_last_accel_usec[instance] = hal.scheduler->micros(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AP_InertialSensor_HIL::set_gyro(const Vector3f &gyro) |
|
|
|
|
void AP_InertialSensor_HIL::set_gyro(uint8_t instance, const Vector3f &gyro) |
|
|
|
|
{ |
|
|
|
|
_gyro[0] = gyro; |
|
|
|
|
_last_gyro_usec = hal.scheduler->micros(); |
|
|
|
|
_gyro[instance] = gyro; |
|
|
|
|
_last_gyro_usec[instance] = hal.scheduler->micros(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
try to detect bad accel/gyro sensors |
|
|
|
|
*/ |
|
|
|
|
bool AP_InertialSensor_HIL::healthy(void) const |
|
|
|
|
bool AP_InertialSensor_HIL::get_gyro_health(uint8_t instance) const |
|
|
|
|
{ |
|
|
|
|
uint32_t tnow = hal.scheduler->micros(); |
|
|
|
|
if ((tnow - _last_accel_usec) > 40000) { |
|
|
|
|
// accels have not updated
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if ((tnow - _last_gyro_usec) > 40000) { |
|
|
|
|
// gyros have not updated
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (fabs(_accel[0].x) > 30 && fabs(_accel[0].y) > 30 && fabs(_accel[0].z) > 30 && |
|
|
|
|
(_previous_accel[0] - _accel[0]).length() < 0.01f) { |
|
|
|
|
// unchanging accel, large in all 3 axes. This is a likely
|
|
|
|
|
// accelerometer failure
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
return (hal.scheduler->micros() - _last_gyro_usec[instance]) < 40000; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool AP_InertialSensor_HIL::get_accel_health(uint8_t instance) const |
|
|
|
|
{ |
|
|
|
|
return (hal.scheduler->micros() - _last_accel_usec[instance]) < 40000; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|