Skip to content

Commit 56be63d

Browse files
Merge pull request #5880 from iNavFlight/de_gps_alt_always
Allow using GPS altitude instead of barometer
2 parents 72c6c68 + 764f2b6 commit 56be63d

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/main/fc/fc_msp_box.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void initActiveBoxIds(void)
189189
activeBoxIds[activeBoxIdCount++] = BOXCAMSTAB;
190190

191191
#ifdef USE_GPS
192-
if (STATE(ALTITUDE_CONTROL) && (sensors(SENSOR_BARO) || (STATE(AIRPLANE) && feature(FEATURE_GPS)))) {
192+
if (STATE(ALTITUDE_CONTROL) && (sensors(SENSOR_BARO) || (feature(FEATURE_GPS) && (STATE(AIRPLANE) || positionEstimationConfig()->use_gps_no_baro)))) {
193193
activeBoxIds[activeBoxIdCount++] = BOXNAVALTHOLD;
194194
activeBoxIds[activeBoxIdCount++] = BOXSURFACE;
195195
}

src/main/fc/settings.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,9 @@ groups:
18581858
default_value: "ON"
18591859
field: use_gps_velned
18601860
type: bool
1861+
- name: inav_use_gps_no_baro
1862+
field: use_gps_no_baro
1863+
type: bool
18611864
- name: inav_allow_dead_reckoning
18621865
description: "Defines if inav will dead-reckon over short GPS outages. May also be useful for indoors OPFLOW navigation"
18631866
default_value: "OFF"

src/main/navigation/navigation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ typedef struct positionEstimationConfig_s {
136136

137137
float max_eph_epv; // Max estimated position error acceptable for estimation (cm)
138138
float baro_epv; // Baro position error
139+
140+
uint8_t use_gps_no_baro;
139141
} positionEstimationConfig_t;
140142

141143
PG_DECLARE(positionEstimationConfig_t, positionEstimationConfig);

src/main/navigation/navigation_pos_estimator.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@
5454

5555
navigationPosEstimator_t posEstimator;
5656

57-
PG_REGISTER_WITH_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, PG_POSITION_ESTIMATION_CONFIG, 4);
57+
PG_REGISTER_WITH_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, PG_POSITION_ESTIMATION_CONFIG, 5);
5858

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

6869
.max_surface_altitude = 200,
@@ -581,7 +582,7 @@ static bool estimationCalculateCorrection_Z(estimationContext_t * ctx)
581582

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

0 commit comments

Comments
 (0)