Skip to content

Commit

Permalink
Move check for valid GPS heading to a function
Browse files Browse the repository at this point in the history
Allows calling it from both the IMU and the wind estimator
  • Loading branch information
fiam committed May 27, 2018
1 parent c52f687 commit 78e62d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/flight/imu.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ static void imuCalculateEstimatedAttitude(float dT)

#if defined(USE_GPS)
if (STATE(FIXED_WING)) {
bool canUseCOG = sensors(SENSOR_GPS) && STATE(GPS_FIX) && gpsSol.numSat >= 6 && gpsSol.groundSpeed >= 300;
bool canUseCOG = isGPSHeadingValid();

if (canUseCOG) {
if (gpsHeadingInitialized) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/io/gps.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,4 +546,10 @@ bool isGPSHealthy(void)
{
return true;
}

bool isGPSHeadingValid(void)
{
return sensors(SENSOR_GPS) && STATE(GPS_FIX) && gpsSol.numSat >= 6 && gpsSol.groundSpeed >= 300;
}

#endif
1 change: 1 addition & 0 deletions src/main/io/gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,6 @@ void gpsInit(void);
void gpsThread(void);
void updateGpsIndicator(timeUs_t currentTimeUs);
bool isGPSHealthy(void);
bool isGPSHeadingValid(void);
struct serialPort_s;
void gpsEnablePassthrough(struct serialPort_s *gpsPassthroughPort);

0 comments on commit 78e62d3

Please sign in to comment.