aboutsummaryrefslogtreecommitdiff
path: root/src/modules/land_detector
diff options
context:
space:
mode:
authorJohan Jansen <jnsn.johan@gmail.com>2015-01-14 17:47:17 +0100
committerJohan Jansen <jnsn.johan@gmail.com>2015-01-15 14:37:51 +0100
commitf1587da4c46e92474687f37ad49fbd003b7c91db (patch)
tree5629dbb524fce690b3dc8b1e6cd87258956e7944 /src/modules/land_detector
parent1356c44f0e27e9ab4d1c2df4cccbe4ac6fb2f1c4 (diff)
downloadpx4-firmware-f1587da4c46e92474687f37ad49fbd003b7c91db.tar.gz
px4-firmware-f1587da4c46e92474687f37ad49fbd003b7c91db.tar.bz2
px4-firmware-f1587da4c46e92474687f37ad49fbd003b7c91db.zip
MulticopterLandDetector: Detect land even if autopilot is not landing
Diffstat (limited to 'src/modules/land_detector')
-rw-r--r--src/modules/land_detector/FixedwingLandDetector.cpp2
-rw-r--r--src/modules/land_detector/MulticopterLandDetector.cpp44
-rw-r--r--src/modules/land_detector/land_detector_main.cpp2
3 files changed, 23 insertions, 25 deletions
diff --git a/src/modules/land_detector/FixedwingLandDetector.cpp b/src/modules/land_detector/FixedwingLandDetector.cpp
index 7df89257f..38f6c00a9 100644
--- a/src/modules/land_detector/FixedwingLandDetector.cpp
+++ b/src/modules/land_detector/FixedwingLandDetector.cpp
@@ -43,7 +43,7 @@
#include <cmath>
#include <drivers/drv_hrt.h>
-FixedwingLandDetector::FixedwingLandDetector() :
+FixedwingLandDetector::FixedwingLandDetector() : LandDetector(),
_vehicleLocalPositionSub(-1),
_vehicleLocalPosition({}),
_airspeedSub(-1),
diff --git a/src/modules/land_detector/MulticopterLandDetector.cpp b/src/modules/land_detector/MulticopterLandDetector.cpp
index 36d92fd79..81af029fb 100644
--- a/src/modules/land_detector/MulticopterLandDetector.cpp
+++ b/src/modules/land_detector/MulticopterLandDetector.cpp
@@ -44,7 +44,7 @@
#include <cmath>
#include <drivers/drv_hrt.h>
-MulticopterLandDetector::MulticopterLandDetector() :
+MulticopterLandDetector::MulticopterLandDetector() : LandDetector(),
_vehicleGlobalPositionSub(-1),
_sensorsCombinedSub(-1),
_waypointSub(-1),
@@ -86,34 +86,32 @@ bool MulticopterLandDetector::update()
//First poll for new data from our subscriptions
updateSubscriptions();
- const uint64_t now = hrt_absolute_time();
-
- //only detect landing if the autopilot is actively trying to land
- if (!_waypoint.current.valid || _waypoint.current.type != SETPOINT_TYPE_LAND) {
- _landTimer = now;
-
- } else {
+ //Only trigger flight conditions if we are armed
+ if(!_arming.armed) {
+ return true;
+ }
- //Check if we are moving vertically
- bool verticalMovement = fabsf(_vehicleGlobalPosition.vel_d) > MC_LAND_DETECTOR_CLIMBRATE_MAX;
+ const uint64_t now = hrt_absolute_time();
- //Check if we are moving horizontally
- bool horizontalMovement = sqrtf(_vehicleGlobalPosition.vel_n * _vehicleGlobalPosition.vel_n
- + _vehicleGlobalPosition.vel_e * _vehicleGlobalPosition.vel_e) > MC_LAND_DETECTOR_VELOCITY_MAX;
+ //Check if we are moving vertically
+ bool verticalMovement = fabsf(_vehicleGlobalPosition.vel_d) > MC_LAND_DETECTOR_CLIMBRATE_MAX;
- //Next look if all rotation angles are not moving
- bool rotating = sqrtf(_sensors.gyro_rad_s[0] * _sensors.gyro_rad_s[0] +
- _sensors.gyro_rad_s[1] * _sensors.gyro_rad_s[1] +
- _sensors.gyro_rad_s[2] * _sensors.gyro_rad_s[2]) > MC_LAND_DETECTOR_ROTATION_MAX;
+ //Check if we are moving horizontally
+ bool horizontalMovement = sqrtf(_vehicleGlobalPosition.vel_n * _vehicleGlobalPosition.vel_n
+ + _vehicleGlobalPosition.vel_e * _vehicleGlobalPosition.vel_e) > MC_LAND_DETECTOR_VELOCITY_MAX;
- //Check if thrust output is minimal (about half of default)
- bool minimalThrust = _arming.armed && _actuators.control[3] <= MC_LAND_DETECTOR_THRUST_MAX;
+ //Next look if all rotation angles are not moving
+ bool rotating = sqrtf(_sensors.gyro_rad_s[0] * _sensors.gyro_rad_s[0] +
+ _sensors.gyro_rad_s[1] * _sensors.gyro_rad_s[1] +
+ _sensors.gyro_rad_s[2] * _sensors.gyro_rad_s[2]) > MC_LAND_DETECTOR_ROTATION_MAX;
- if (verticalMovement || rotating || !minimalThrust || horizontalMovement) {
- //Sensed movement, so reset the land detector
- _landTimer = now;
- }
+ //Check if thrust output is minimal (about half of default)
+ bool minimalThrust = _actuators.control[3] <= MC_LAND_DETECTOR_THRUST_MAX;
+ if (verticalMovement || rotating || !minimalThrust || horizontalMovement) {
+ //Sensed movement, so reset the land detector
+ _landTimer = now;
+ return false;
}
return now - _landTimer > MC_LAND_DETECTOR_TRIGGER_TIME;
diff --git a/src/modules/land_detector/land_detector_main.cpp b/src/modules/land_detector/land_detector_main.cpp
index 7c0ffb82a..9e135b5f1 100644
--- a/src/modules/land_detector/land_detector_main.cpp
+++ b/src/modules/land_detector/land_detector_main.cpp
@@ -104,7 +104,7 @@ static void land_detector_stop()
delete land_detector_task;
land_detector_task = nullptr;
_landDetectorTaskID = -1;
- warn("land_detector has been stopped");
+ errx(0, "land_detector has been stopped");
}
/**