1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 04:15:44 +03:00

GPS Rescue: Add GPS LOST to Sanity Checks

This commit is contained in:
Tony Cabello 2018-11-16 15:01:24 +01:00
parent f57b3f3dc7
commit 888c0e48f6
3 changed files with 14 additions and 0 deletions

View file

@ -71,6 +71,7 @@ typedef enum {
typedef enum {
RESCUE_HEALTHY,
RESCUE_FLYAWAY,
RESCUE_GPSLOST,
RESCUE_LOWSATS,
RESCUE_CRASH_FLIP_DETECTED,
RESCUE_STALLED,
@ -97,6 +98,7 @@ typedef struct {
float zVelocityAvg; // Up/down average in cm/s
float accMagnitude;
float accMagnitudeAvg;
bool healthy;
} rescueSensorData_s;
typedef struct {
@ -337,6 +339,11 @@ static void performSanityChecks()
rescueState.failure = RESCUE_CRASH_FLIP_DETECTED;
}
// Check if GPS comms are healthy
if (!rescueState.sensor.healthy) {
rescueState.failure = RESCUE_GPSLOST;
}
// Things that should run at a low refresh rate (such as flyaway detection, etc)
// This runs at ~1hz
@ -372,6 +379,7 @@ static void performSanityChecks()
static void sensorUpdate()
{
rescueState.sensor.currentAltitudeCm = getEstimatedAltitudeCm();
rescueState.sensor.healthy = gpsIsHealthy();
// Calculate altitude velocity
static uint32_t previousTimeUs;

View file

@ -591,6 +591,11 @@ bool gpsNewFrame(uint8_t c)
return false;
}
// Check for healthy communications
bool gpsIsHealthy()
{
return (gpsData.state == GPS_RECEIVING_DATA);
}
/* This is a light implementation of a GPS frame decoding
This should work with most of modern GPS devices configured to output 5 frames.

View file

@ -162,6 +162,7 @@ extern uint8_t GPS_svinfo_cno[16]; // Carrier to Noise Ratio (Signal Str
void gpsInit(void);
void gpsUpdate(timeUs_t currentTimeUs);
bool gpsNewFrame(uint8_t c);
bool gpsIsHealthy(void); // Check for healthy communications
struct serialPort_s;
void gpsEnablePassthrough(struct serialPort_s *gpsPassthroughPort);
void onGpsNewData(void);