mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 00:53:33 +08:00
land_detector: battery level status to adjust maximum altitude possible
This commit is contained in:
committed by
Lorenz Meier
parent
c8690fd072
commit
a1982e0392
@@ -41,6 +41,7 @@
|
||||
#include <px4_config.h>
|
||||
#include <px4_defines.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "LandDetector.h"
|
||||
|
||||
@@ -123,6 +124,9 @@ void LandDetector::_cycle()
|
||||
|
||||
_update_state();
|
||||
|
||||
float alt_max_prev = _altitude_max;
|
||||
_update_max_altitude();
|
||||
|
||||
bool freefallDetected = (_state == LandDetectionState::FREEFALL);
|
||||
bool landDetected = (_state == LandDetectionState::LANDED);
|
||||
bool ground_contactDetected = (_state == LandDetectionState::GROUND_CONTACT);
|
||||
@@ -132,7 +136,8 @@ void LandDetector::_cycle()
|
||||
if ((_landDetectedPub == nullptr) ||
|
||||
(_landDetected.freefall != freefallDetected) ||
|
||||
(_landDetected.landed != landDetected) ||
|
||||
(_landDetected.ground_contact != ground_contactDetected)) {
|
||||
(_landDetected.ground_contact != ground_contactDetected) ||
|
||||
(fabsf(_landDetected.alt_max - alt_max_prev) > FLT_EPSILON)) {
|
||||
|
||||
if (!landDetected && _landDetected.landed) {
|
||||
// We did take off
|
||||
@@ -152,6 +157,7 @@ void LandDetector::_cycle()
|
||||
_landDetected.freefall = (_state == LandDetectionState::FREEFALL);
|
||||
_landDetected.landed = (_state == LandDetectionState::LANDED);
|
||||
_landDetected.ground_contact = (_state == LandDetectionState::GROUND_CONTACT);
|
||||
_landDetected.alt_max = _altitude_max;
|
||||
|
||||
int instance;
|
||||
orb_publish_auto(ORB_ID(vehicle_land_detected), &_landDetectedPub, &_landDetected,
|
||||
@@ -168,7 +174,6 @@ void LandDetector::_cycle()
|
||||
_taskIsRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
void LandDetector::_check_params(const bool force)
|
||||
{
|
||||
bool updated;
|
||||
@@ -216,6 +221,12 @@ void LandDetector::_update_state()
|
||||
}
|
||||
}
|
||||
|
||||
void LandDetector::_update_max_altitude()
|
||||
{
|
||||
_altitude_max = _get_max_altitude();
|
||||
}
|
||||
|
||||
|
||||
bool LandDetector::_orb_update(const struct orb_metadata *meta, int handle, void *buffer)
|
||||
{
|
||||
bool newData = false;
|
||||
|
||||
Reference in New Issue
Block a user