Skip to content

Commit

Permalink
Merge pull request #5880 from iNavFlight/de_gps_alt_always
Browse files Browse the repository at this point in the history
Allow using GPS altitude instead of barometer
  • Loading branch information
digitalentity committed Jul 27, 2020
2 parents 72c6c68 + 764f2b6 commit 56be63d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/fc/fc_msp_box.c
Expand Up @@ -189,7 +189,7 @@ void initActiveBoxIds(void)
activeBoxIds[activeBoxIdCount++] = BOXCAMSTAB;

#ifdef USE_GPS
if (STATE(ALTITUDE_CONTROL) && (sensors(SENSOR_BARO) || (STATE(AIRPLANE) && feature(FEATURE_GPS)))) {
if (STATE(ALTITUDE_CONTROL) && (sensors(SENSOR_BARO) || (feature(FEATURE_GPS) && (STATE(AIRPLANE) || positionEstimationConfig()->use_gps_no_baro)))) {
activeBoxIds[activeBoxIdCount++] = BOXNAVALTHOLD;
activeBoxIds[activeBoxIdCount++] = BOXSURFACE;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/fc/settings.yaml
Expand Up @@ -1858,6 +1858,9 @@ groups:
default_value: "ON"
field: use_gps_velned
type: bool
- name: inav_use_gps_no_baro
field: use_gps_no_baro
type: bool
- name: inav_allow_dead_reckoning
description: "Defines if inav will dead-reckon over short GPS outages. May also be useful for indoors OPFLOW navigation"
default_value: "OFF"
Expand Down
2 changes: 2 additions & 0 deletions src/main/navigation/navigation.h
Expand Up @@ -136,6 +136,8 @@ typedef struct positionEstimationConfig_s {

float max_eph_epv; // Max estimated position error acceptable for estimation (cm)
float baro_epv; // Baro position error

uint8_t use_gps_no_baro;
} positionEstimationConfig_t;

PG_DECLARE(positionEstimationConfig_t, positionEstimationConfig);
Expand Down
7 changes: 4 additions & 3 deletions src/main/navigation/navigation_pos_estimator.c
Expand Up @@ -54,15 +54,16 @@

navigationPosEstimator_t posEstimator;

PG_REGISTER_WITH_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, PG_POSITION_ESTIMATION_CONFIG, 4);
PG_REGISTER_WITH_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, PG_POSITION_ESTIMATION_CONFIG, 5);

PG_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig,
// Inertial position estimator parameters
.automatic_mag_declination = 1,
.reset_altitude_type = NAV_RESET_ON_FIRST_ARM,
.reset_home_type = NAV_RESET_ON_FIRST_ARM,
.gravity_calibration_tolerance = 5, // 5 cm/s/s calibration error accepted (0.5% of gravity)
.use_gps_velned = 1, // "Disabled" is mandatory with gps_dyn_model = Pedestrian
.use_gps_velned = 1, // "Disabled" is mandatory with gps_dyn_model = Pedestrian
.use_gps_no_baro = 0, // Use GPS altitude if no baro is available on all aircrafts
.allow_dead_reckoning = 0,

.max_surface_altitude = 200,
Expand Down Expand Up @@ -581,7 +582,7 @@ static bool estimationCalculateCorrection_Z(estimationContext_t * ctx)

return true;
}
else if (STATE(FIXED_WING_LEGACY) && (ctx->newFlags & EST_GPS_Z_VALID)) {
else if ((STATE(FIXED_WING_LEGACY) || positionEstimationConfig()->use_gps_no_baro) && (ctx->newFlags & EST_GPS_Z_VALID)) {
// If baro is not available - use GPS Z for correction on a plane
// Reset current estimate to GPS altitude if estimate not valid
if (!(ctx->newFlags & EST_Z_VALID)) {
Expand Down

0 comments on commit 56be63d

Please sign in to comment.