Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using GPS altitude instead of barometer #5880

Merged
merged 2 commits into from Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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