Browse Source

Add rangefinder operands

master
Pawel Spychalski (DzikuVx) 3 years ago
parent
commit
2557dc0f40
  1. 3
      src/main/navigation/navigation.h
  2. 8
      src/main/navigation/navigation_pos_estimator.c
  3. 13
      src/main/programming/logic_condition.c
  4. 4
      src/main/programming/logic_condition.h

3
src/main/navigation/navigation.h

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

8
src/main/navigation/navigation_pos_estimator.c

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

13
src/main/programming/logic_condition.c

@ -42,6 +42,7 @@
#include "navigation/navigation.h"
#include "sensors/battery.h"
#include "sensors/pitotmeter.h"
#include "sensors/rangefinder.h"
#include "flight/imu.h"
#include "flight/pid.h"
#include "drivers/io_port_expander.h"
@ -612,6 +613,18 @@ static int logicConditionGetFlightOperandValue(int operand) {
case LOGIC_CONDITION_OPERAND_FLIGHT_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:
return 0;
break;

4
src/main/programming/logic_condition.h

@ -129,7 +129,9 @@ typedef enum {
LOGIC_CONDITION_OPERAND_FLIGHT_LOITER_RADIUS, // 35
LOGIC_CONDITION_OPERAND_FLIGHT_ACTIVE_PROFILE, //int // 36
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;
typedef enum {

Loading…
Cancel
Save