1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 16:25:26 +03:00

Add rangefinder operands

This commit is contained in:
Pawel Spychalski (DzikuVx) 2022-04-22 12:06:10 +02:00
parent b4d23ea68c
commit 2557dc0f40
4 changed files with 27 additions and 1 deletions

View file

@ -584,6 +584,9 @@ int32_t getCruiseHeadingAdjustment(void);
bool isAdjustingPosition(void); bool isAdjustingPosition(void);
bool isAdjustingHeading(void); bool isAdjustingHeading(void);
float getEstimatedAglPosition(void);
bool isEstimatedAglTrusted(void);
/* Returns the heading recorded when home position was acquired. /* Returns the heading recorded when home position was acquired.
* Note that the navigation system uses deg*100 as unit and angles * Note that the navigation system uses deg*100 as unit and angles
* are in the [0, 360 * 100) interval. * are in the [0, 360 * 100) interval.

View file

@ -809,6 +809,14 @@ bool isGPSGlitchDetected(void)
} }
#endif #endif
float getEstimatedAglPosition(void) {
return posEstimator.est.aglAlt;
}
bool isEstimatedAglTrusted(void) {
return (posEstimator.est.aglQual == SURFACE_QUAL_HIGH) ? true : false;
}
/** /**
* Initialize position estimator * Initialize position estimator
* Should be called once before any update occurs * Should be called once before any update occurs

View file

@ -42,6 +42,7 @@
#include "navigation/navigation.h" #include "navigation/navigation.h"
#include "sensors/battery.h" #include "sensors/battery.h"
#include "sensors/pitotmeter.h" #include "sensors/pitotmeter.h"
#include "sensors/rangefinder.h"
#include "flight/imu.h" #include "flight/imu.h"
#include "flight/pid.h" #include "flight/pid.h"
#include "drivers/io_port_expander.h" #include "drivers/io_port_expander.h"
@ -612,6 +613,18 @@ static int logicConditionGetFlightOperandValue(int operand) {
case LOGIC_CONDITION_OPERAND_FLIGHT_LOITER_RADIUS: case LOGIC_CONDITION_OPERAND_FLIGHT_LOITER_RADIUS:
return getLoiterRadius(navConfig()->fw.loiter_radius); return getLoiterRadius(navConfig()->fw.loiter_radius);
case LOGIC_CONDITION_OPERAND_FLIGHT_AGL_STATUS:
return isEstimatedAglTrusted();
break;
case LOGIC_CONDITION_OPERAND_FLIGHT_AGL:
return getEstimatedAglPosition();
break;
case LOGIC_CONDITION_OPERAND_FLIGHT_RANGEFINDER_RAW:
return rangefinderGetLatestRawAltitude();
break;
default: default:
return 0; return 0;
break; break;

View file

@ -129,7 +129,9 @@ typedef enum {
LOGIC_CONDITION_OPERAND_FLIGHT_LOITER_RADIUS, // 35 LOGIC_CONDITION_OPERAND_FLIGHT_LOITER_RADIUS, // 35
LOGIC_CONDITION_OPERAND_FLIGHT_ACTIVE_PROFILE, //int // 36 LOGIC_CONDITION_OPERAND_FLIGHT_ACTIVE_PROFILE, //int // 36
LOGIC_CONDITION_OPERAND_FLIGHT_BATT_CELLS, // 37 LOGIC_CONDITION_OPERAND_FLIGHT_BATT_CELLS, // 37
LOGIC_CONDITION_OPERAND_FLIGHT_AGL_STATUS, //0,1,2 // 38
LOGIC_CONDITION_OPERAND_FLIGHT_AGL, //0,1,2 // 39
LOGIC_CONDITION_OPERAND_FLIGHT_RANGEFINDER_RAW, //int // 40
} logicFlightOperands_e; } logicFlightOperands_e;
typedef enum { typedef enum {