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:
parent
f57b3f3dc7
commit
888c0e48f6
3 changed files with 14 additions and 0 deletions
|
@ -71,6 +71,7 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RESCUE_HEALTHY,
|
RESCUE_HEALTHY,
|
||||||
RESCUE_FLYAWAY,
|
RESCUE_FLYAWAY,
|
||||||
|
RESCUE_GPSLOST,
|
||||||
RESCUE_LOWSATS,
|
RESCUE_LOWSATS,
|
||||||
RESCUE_CRASH_FLIP_DETECTED,
|
RESCUE_CRASH_FLIP_DETECTED,
|
||||||
RESCUE_STALLED,
|
RESCUE_STALLED,
|
||||||
|
@ -97,6 +98,7 @@ typedef struct {
|
||||||
float zVelocityAvg; // Up/down average in cm/s
|
float zVelocityAvg; // Up/down average in cm/s
|
||||||
float accMagnitude;
|
float accMagnitude;
|
||||||
float accMagnitudeAvg;
|
float accMagnitudeAvg;
|
||||||
|
bool healthy;
|
||||||
} rescueSensorData_s;
|
} rescueSensorData_s;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -337,6 +339,11 @@ static void performSanityChecks()
|
||||||
rescueState.failure = RESCUE_CRASH_FLIP_DETECTED;
|
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)
|
// Things that should run at a low refresh rate (such as flyaway detection, etc)
|
||||||
// This runs at ~1hz
|
// This runs at ~1hz
|
||||||
|
|
||||||
|
@ -372,6 +379,7 @@ static void performSanityChecks()
|
||||||
static void sensorUpdate()
|
static void sensorUpdate()
|
||||||
{
|
{
|
||||||
rescueState.sensor.currentAltitudeCm = getEstimatedAltitudeCm();
|
rescueState.sensor.currentAltitudeCm = getEstimatedAltitudeCm();
|
||||||
|
rescueState.sensor.healthy = gpsIsHealthy();
|
||||||
|
|
||||||
// Calculate altitude velocity
|
// Calculate altitude velocity
|
||||||
static uint32_t previousTimeUs;
|
static uint32_t previousTimeUs;
|
||||||
|
|
|
@ -591,6 +591,11 @@ bool gpsNewFrame(uint8_t c)
|
||||||
return false;
|
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 is a light implementation of a GPS frame decoding
|
||||||
This should work with most of modern GPS devices configured to output 5 frames.
|
This should work with most of modern GPS devices configured to output 5 frames.
|
||||||
|
|
|
@ -162,6 +162,7 @@ extern uint8_t GPS_svinfo_cno[16]; // Carrier to Noise Ratio (Signal Str
|
||||||
void gpsInit(void);
|
void gpsInit(void);
|
||||||
void gpsUpdate(timeUs_t currentTimeUs);
|
void gpsUpdate(timeUs_t currentTimeUs);
|
||||||
bool gpsNewFrame(uint8_t c);
|
bool gpsNewFrame(uint8_t c);
|
||||||
|
bool gpsIsHealthy(void); // Check for healthy communications
|
||||||
struct serialPort_s;
|
struct serialPort_s;
|
||||||
void gpsEnablePassthrough(struct serialPort_s *gpsPassthroughPort);
|
void gpsEnablePassthrough(struct serialPort_s *gpsPassthroughPort);
|
||||||
void onGpsNewData(void);
|
void onGpsNewData(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue