mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-25 17:25:18 +03:00
allow HITL to run with HW baro failure
This commit is contained in:
parent
f31f6fc483
commit
32c4dcd436
3 changed files with 28 additions and 10 deletions
|
@ -3478,7 +3478,9 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu
|
||||||
DISABLE_ARMING_FLAG(SIMULATOR_MODE_HITL);
|
DISABLE_ARMING_FLAG(SIMULATOR_MODE_HITL);
|
||||||
|
|
||||||
#ifdef USE_BARO
|
#ifdef USE_BARO
|
||||||
|
if ( requestedSensors[SENSOR_INDEX_BARO] != BARO_NONE ) {
|
||||||
baroStartCalibration();
|
baroStartCalibration();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_MAG
|
#ifdef USE_MAG
|
||||||
DISABLE_STATE(COMPASS_CALIBRATED);
|
DISABLE_STATE(COMPASS_CALIBRATED);
|
||||||
|
@ -3489,10 +3491,15 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu
|
||||||
|
|
||||||
disarm(DISARM_SWITCH); // Disarm to prevent motor output!!!
|
disarm(DISARM_SWITCH); // Disarm to prevent motor output!!!
|
||||||
}
|
}
|
||||||
} else if (!areSensorsCalibrating()) {
|
} else {
|
||||||
if (!ARMING_FLAG(SIMULATOR_MODE_HITL)) { // Just once
|
if (!ARMING_FLAG(SIMULATOR_MODE_HITL)) { // Just once
|
||||||
#ifdef USE_BARO
|
#ifdef USE_BARO
|
||||||
baroStartCalibration();
|
if ( requestedSensors[SENSOR_INDEX_BARO] != BARO_NONE ) {
|
||||||
|
sensorsSet(SENSOR_BARO);
|
||||||
|
setTaskEnabled(TASK_BARO, true);
|
||||||
|
DISABLE_ARMING_FLAG(ARMING_DISABLED_HARDWARE_FAILURE);
|
||||||
|
baroStartCalibration();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_MAG
|
#ifdef USE_MAG
|
||||||
|
|
|
@ -254,6 +254,12 @@ uint32_t baroUpdate(void)
|
||||||
{
|
{
|
||||||
static barometerState_e state = BAROMETER_NEEDS_SAMPLES;
|
static barometerState_e state = BAROMETER_NEEDS_SAMPLES;
|
||||||
|
|
||||||
|
#ifdef USE_SIMULATOR
|
||||||
|
if (ARMING_FLAG(SIMULATOR_MODE_HITL)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
default:
|
default:
|
||||||
case BAROMETER_NEEDS_SAMPLES:
|
case BAROMETER_NEEDS_SAMPLES:
|
||||||
|
@ -269,19 +275,13 @@ uint32_t baroUpdate(void)
|
||||||
|
|
||||||
case BAROMETER_NEEDS_CALCULATION:
|
case BAROMETER_NEEDS_CALCULATION:
|
||||||
if (baro.dev.get_up) {
|
if (baro.dev.get_up) {
|
||||||
baro.dev.get_up(&baro.dev);
|
baro.dev.get_up(&baro.dev);
|
||||||
}
|
}
|
||||||
if (baro.dev.start_ut) {
|
if (baro.dev.start_ut) {
|
||||||
baro.dev.start_ut(&baro.dev);
|
baro.dev.start_ut(&baro.dev);
|
||||||
}
|
}
|
||||||
#ifdef USE_SIMULATOR
|
//output: baro.baroPressure, baro.baroTemperature
|
||||||
if (!ARMING_FLAG(SIMULATOR_MODE_HITL)) {
|
|
||||||
//output: baro.baroPressure, baro.baroTemperature
|
|
||||||
baro.dev.calculate(&baro.dev, &baro.baroPressure, &baro.baroTemperature);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
baro.dev.calculate(&baro.dev, &baro.baroPressure, &baro.baroTemperature);
|
baro.dev.calculate(&baro.dev, &baro.baroPressure, &baro.baroTemperature);
|
||||||
#endif
|
|
||||||
state = BAROMETER_NEEDS_SAMPLES;
|
state = BAROMETER_NEEDS_SAMPLES;
|
||||||
return baro.dev.ut_delay;
|
return baro.dev.ut_delay;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -94,6 +94,17 @@ hardwareSensorStatus_e getHwCompassStatus(void)
|
||||||
hardwareSensorStatus_e getHwBarometerStatus(void)
|
hardwareSensorStatus_e getHwBarometerStatus(void)
|
||||||
{
|
{
|
||||||
#if defined(USE_BARO)
|
#if defined(USE_BARO)
|
||||||
|
#ifdef USE_SIMULATOR
|
||||||
|
if (ARMING_FLAG(SIMULATOR_MODE_HITL) || ARMING_FLAG(SIMULATOR_MODE_SITL)) {
|
||||||
|
if (requestedSensors[SENSOR_INDEX_BARO] == BARO_NONE) {
|
||||||
|
return HW_SENSOR_NONE;
|
||||||
|
} else if (baroIsHealthy()) {
|
||||||
|
return HW_SENSOR_OK;
|
||||||
|
} else {
|
||||||
|
return HW_SENSOR_UNHEALTHY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (detectedSensors[SENSOR_INDEX_BARO] != BARO_NONE) {
|
if (detectedSensors[SENSOR_INDEX_BARO] != BARO_NONE) {
|
||||||
if (baroIsHealthy()) {
|
if (baroIsHealthy()) {
|
||||||
return HW_SENSOR_OK;
|
return HW_SENSOR_OK;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue