135 Commits

Author SHA1 Message Date
Silvan Fuhrer
06bf60672b MC LandDetector: add constant (0.3) for vz threshold for in_descend flag
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-11-01 18:35:54 +01:00
Silvan Fuhrer
4e74473932 MC LandDetector: remove 2s phase after not maybe landed to still increase thresholds
I don't see where this is necessary. During takeoff, the maybe landed flag should
only get cleared once system is about to takeoff, and thus well after the spool up
is complete (for which the higher thresholds are meant in this case).

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-11-01 18:35:54 +01:00
Silvan Fuhrer
91adb4c9e0 MC LandDetector: widen thresholds for vz and rotational movment always in maybe landed and 2s after
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-11-01 18:35:54 +01:00
Silvan Fuhrer
27309a45cc MC LandDetector: remove dependency on MPC_LAND_SPEED and MPC_LAND_CRWL
Don't consider these params for vertical speed threshold,
and instead increase the default for LNDMC_Z_VEL_MAX and
use solely that one. Makes the land detector outcome more
predictable and its interal logic simpler, while the new
default tuning is resulting in about the same vz threshold
as before.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-11-01 18:35:54 +01:00
Silvan Fuhrer
bace45ba8d LandDetector: log rotational_movement
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-11-01 18:35:54 +01:00
Matthias Grob
75c63aee2a Fix confusion between trajectory_setpoint and vehicle_local_postion_setpoint 2022-10-17 16:18:00 -04:00
Matthias Grob
c1b9b8a1c0 MulticopterLandDetector: correct comment with outdated time constant reference 2022-03-23 10:49:38 +01:00
Matthias Grob
1df9d6fca6 MulticopterLandDetector: fix crawl speed parameter fetching 2022-02-04 21:56:20 -05:00
Thomas Debrunner
fb8b9b647a land-detector: switch to crawl speed for intent detection 2022-02-04 21:56:20 -05:00
Daniel Agar
f3e2a197ad
move vehicle at rest detection ekf2 -> land_detector
- move vehicle at reset detection ekf2 -> land_detector
 - ekf_unit: reduce init period
   - Fake fusion is when at rest is quite strong and makes the variance reduce rapidly. Reduce the amount of time we wait before checking if the variances are still large enough.
 - ekf_unit: reduce minimum vel/pos variance required after init
   - Fake pos fusion has a low observation noise, making the vel/pos variances reduce quickly.

Co-authored-by:: bresch <brescianimathieu@gmail.com>
2022-02-01 17:50:19 -05:00
Silvan Fuhrer
3cd1e0ce19 MCLandDetector: clean up logic for ground effect
Before: in_ground_effect was always true with the default settings (LNDMC_ALT_GND =-1)
 and when a distance sensor was present with valid data.
Now: default of LNDMC_ALT_GND is set to 2m by default, and if set to a negative value
then in_ground_effect is never set to true

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-01-12 18:41:16 +01:00
Matthias Grob
bbb04ab4b8 Remove relaying of maximum altitude through land detector 2022-01-05 14:54:59 +01:00
Matthias Grob
c28533677d MulticopterLandDetector: use setpoint generation to infer decend intent
For any normal use case where a downwards velocity setpoint is set
this works exactly the same as before.
E.g. autonomous landing, landing in Altitude or Position mode

The advantage is that the very common case where a vehicle tries
to hold a constant altitude but fails to do so e.g. during a hard brake
with too much lift the resulting downwards velocity was interpreted
as descend intent and since the vehicle already struggled to hold altitude
with low thrust and was not moving fast anymore because it was braking
this lead to a lot more false positives on certain vehicle types.

The disadvantage is that not setting a downwards velocity setpoint but
just moving the position setpoint into the ground does not result in
land detection anymore. We do not use this method of landing anymore for
quite a while. It's not recommended and I wonder if there's some rare use
case like offboard where this is done.

We could add an additional case for the specific case to land with a
position setpoint only.
2021-05-04 16:43:33 +02:00
Matthias Grob
2e292abfff MulticopterLandDetector: Make land detection time configurable
The tree stages used arbitrary 350, 250 300ms totally 900ms
So this changes it to each stage to a third of the parameter.
Default it is 1 second -> 333ms per stage.
2021-05-04 16:43:33 +02:00
RomanBapst
269ce07cb5 land detector: log more states in order to facilitate debugging ground contact state
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2021-05-04 16:43:33 +02:00
RomanBapst
171c26373b land_detector: robustify land detection by using distance to ground info
- if distance to the ground is available then hysteresis times will be increased
by a factor of 3 if vehicle is higher than 1m above ground

Signed-off-by: RomanBapst <bapstroman@gmail.com>
2021-04-27 08:19:19 +02:00
Matthias Grob
45ada2dd4c MulticopterLandDetector: remove unnecessary newline 2021-04-20 18:18:21 +02:00
Daniel Agar
68c171fd4f land_detector: continue respecting hover thrust throughout descent 2021-03-08 11:33:36 +01:00
Paul Riseborough
9d1de3118f land_detector: Rework ground effect calculation for MC 2021-02-03 17:44:12 +01:00
Daniel Agar
87471a988d land_detector: use hover thrust if it was valid recently
- the hover thrust estimate will often invalidate upon ground contact, but before the land detector ground_contact triggers
 - use same time throughout call to avoid subtle timing surprises
2020-09-15 10:17:25 -04:00
Daniel Agar
ba640acfcc
mc_hover_thrust_estimator: validity flag and other small improvements/fixes
- track and publish validity based on hover thrust variance, innovation test ratio, and hysteresis
 - only publish on actual updates or becoming inactive
 - fix dt (previous timestamp wasn't being saved)
 - use local position timestamp (corresponding) to accel data rather than current time to avoid unnecessary timing jitter
 - check local position validity before using
 - mc_hover_thrust_estimator: move from wq:lp_default -> wq:nav_and_controllers to ensure the hover thrust estimator runs after the position controller and uses the same vehicle_local_position data
 - land_detector: check hover thrust estimate validity and adjust low throttle thresholds if hover thrust is available
 - mc_pos_control: only use hover thrust estimate if valid
2020-08-03 10:30:52 -04:00
Daniel Agar
f5f2897486
land_detector: multicopter ground contact fixes, improvements, and cleanup
- if "landed" and "maybe_landed" states are false then both the "hit_ground" and the "low_thrust" condition need to be true in order to detect landing
 - ground contact MC NAN setpoint workaround
 - ground contact additionally check acceleration setpoint
 - schedule with vehicle_local_position updates (most updates require valid local position)
 - don't allow LNDMC_Z_VEL_MAX to exceed MPC_LAND_SPEED
 - ground contact horizontal movement checks default to failed if estimates aren't available
2020-08-02 13:37:23 -04:00
Matthias Grob
c36c8d161c MulticopterLandDetector: remove arbitrary maximum altitude based on battery percentage 2020-06-08 10:41:19 +02:00
bresch
d29344cb9c MCLandDetector: fix low thrust detection in stabilized mode
HTE runs based on the position controller so, even if we whish to use
the estimate, it is only available in altitude and position modes.
Therefore, we need to always initialize the hoverThrottle using the hover
thrust parameter in case we fly in stabilized
2020-04-22 11:07:04 -04:00
Daniel Agar
f9794e99f8
move hover_thrust_estimator to new module (mc_hover_thrust_estimator)
* MC_HTE: unitialize with hover_thrust parameter
* MC_HTE: constrain hover thrust setter between 0.1 and 0.9
* MC_HTE: integrate with land detector and velocity controller
* MCHoverThrustEstimator: Always publish an estimate even when not fusing measurements. This is required as the land detector and the position controller need to receive a hover thrust value.

* MC_HTE: use altitude agl threshold to start the estimator
local_position.z is relative to the origin of the EKF while dist_bottom
is above ground

Co-authored-by: bresch <brescianimathieu@gmail.com>
2020-03-11 21:20:54 -04:00
Daniel Agar
635ceccfdb
land_detector: relax data timeouts uniformly
* if we're hitting these timeouts there are much larger problems in the system
2020-01-20 17:14:00 -05:00
Daniel Agar
a8ea55d9b6
remove all <cmath> usage
* the NuttX c++ library is incomplete, let's avoid including it until we have a real standard library in place
2019-11-25 10:04:04 -05:00
Daniel Agar
967446af4c clang-tidy: enable readability-simplify-boolean-expr and fix 2019-10-27 19:19:07 -04:00
Mark Sauder
e9c9fb8239 fix multicopter land detector: do not update parameters every cycle (#13212)
And add updateParams() call in LandDetector::_update_params().
2019-10-18 09:25:41 +02:00
mcsauder
fb12ddb69a Cherry pick the directory and voted_sensors_update.h from PR #9756.
Consolidate _update_params() methods for improved inheritance from the LandDetector base class.
Move common uORB::Subscriptions to the base class for inheritance.
Deprecate redundant override methods.
2019-10-14 21:25:57 +02:00
mcsauder
f9a5c91f8c Deprecate vehicle_attitude_sub from MulticopterLandDetector as it is no longer utilized. 2019-10-09 09:48:17 +02:00
Mark Sauder
508ffa1b39 land_detector: Remove recently added vehicle_attitude.timestamp check from MulticopterLandDetector::_get_maybe_landed_state(). (#13072)
PR #12681 added a check to the MulticopterLandDetector::_get_maybe_landed_state() method for a valid vehicle_attitude.timstamp value to finish work in PR #9756. It was discovered that the addition of that check leaves it possible to fly in acro mode without a valid attitude and auto-disarm can engage, allowing the multicopter to fall out of the sky.
2019-10-02 16:31:06 -04:00
Mark Sauder
60e5e0821a land_detector: Add and max_altitude and timestamp validity checks to MulticopterLandDetector class. (#12681)
* Rename local camelCase vars to snake_case and control_mode -> vehicle_control_mode to match typdef with established class convention.
2019-09-02 00:30:46 -04:00
Mark Sauder
056c8000a1 MultiCopterLandDetector: Implement ModuleParams inheritance (#12356) 2019-08-09 07:57:42 +02:00
Daniel Agar
a917f22b65
sensors: create vehicle_acceleration module (#12597) 2019-08-07 05:05:48 -04:00
Daniel Agar
2ad12d7977
sensors: create vehicle_angular_velocity module (#12596)
* split out filtered sensor_gyro aggregation from mc_att_control and move to wq:rate_ctrl
2019-08-06 12:55:25 -04:00
Mark Sauder
1466d11acc land_detector: cleanup actuator_armed and battery_status naming
* Rename _arming -> _actuator_armed
 * Rename _battery -> _battery_status in the MulticopterLandDetector class.
2019-06-27 12:02:14 -04:00
mcsauder
6e9f706b12 Standardize remaining class member variable naming convention in the MulticopterLandDetector class. 2019-06-26 14:06:56 -04:00
mcsauder
6b6d82447e Standardize class member variable naming convention in the MulticopterLandDetector class. 2019-06-26 14:06:56 -04:00
Daniel Agar
53aa4130a8 land_detector move orb subscriptions to uORB::Subscription 2019-06-04 18:10:21 -04:00
Roman
6c1399b328 multicopter land detector: make threshold for _has_low_thrust
configurable

Signed-off-by: Roman <bapstroman@gmail.com>
2019-04-03 08:49:46 +02:00
Matthias Grob
aa36fa2dfd replace camel case by snake case.
Co-Authored-By: EliaTarasov <elias.tarasov@gmail.com>
2019-03-21 10:07:12 +01:00
Roman
ecc8a696d0 added ground effect reporting to land detector
Signed-off-by: Roman <bapstroman@gmail.com>
2019-03-21 10:07:12 +01:00
Matthias Grob
f9ec0cd5ea LandDetector: use vertical velocity estimate for threshold
instead of the derivative of the vertical position which is
not the same value when using the ekf2 estimation.

Using the position derivative resulted in delayed landing because
the value for some reason often bumped over the theshold before
slowly converging towards zero while the velocity was within expected
accuary in all these cases.
2019-01-26 14:53:15 +01:00
Dennis Mannhart
5887a2393c PositionControl: skip controller only if adjusted thrust setpoint are not finite
PositionControl: update comment about the order of thrust and position

mc_pos_control: reset setpoints to NAN if required

MulticopterLandDetector: consider to be landed if vehicle is not armed

mc_pos_control: initialize landing struct with landed

mc-pos-ctrl: adjust thrust-setpoint and yaw during ground-contact/maybe-landed without capturing
that information within vehicle-local-position-setpoint topic because that information
does not belong to user intention

PositionControl: set local position/velocity setpoint to NAN if not used in the control pipeline

mc-pos-ctrl: Fill vehicle_local_position_setpoint_s structure as follow:
The message contains setpoints where each type of setpoint is either the input to the PositionController
or was generated by the PositionController and therefore corresponds to the PositioControl internal states (states that were generated by P-PID).
Example:
If the desired setpoint is position-setpoint, _local_pos_sp will contain
position-, velocity- and thrust-setpoint where the velocity- and thrust-setpoint were generated by the PositionControlller.
If the desired setpoint has a velocity-setpoint only, then _local_pos_sp will contain valid velocity- and thrust-setpoint, but the position-setpoint
will remain NAN. Given that the PositionController cannot generate a position-setpoint, this type of setpoint is always equal to the input to the
PositionController.

mc_pos_control: switch to designated initializer for landed

It's less error prone because it produces an error on every discrepancy.
2019-01-08 15:36:30 +01:00
Beat Küng
a9def8be93 MC land detector: remove LNDMC_THR_RANGE param
- no airframe changes the default
- it does not make much sense to be able to configure the 0.1 threshold
  but the 0.3 threshold for ground contact detection cannot be configured.
2018-10-09 12:09:07 +02:00
Beat Küng
465d399e8f land_detector: move _parameterSub to the right place 2018-09-28 16:04:40 +02:00
Dennis Mannhart
f30bf215db MulticopterLanddetector: adjust minimum throttle if climb-reate is not enabled 2018-07-20 09:26:18 +02:00
Beat Küng
123f11fcdd land_detector: use user-defined literals for time constants 2018-04-14 13:45:57 +02:00
Daniel Agar
354584acfc MulticopterLandDetector initialize all class members 2018-03-05 15:46:24 -05:00