Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FW LandDetector: disregard horizontal velocity if local_position.v_xy_valid is false #24133

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mahimayoga
Copy link
Contributor

@mahimayoga mahimayoga commented Dec 19, 2024

Solved Problem

Horizontal velocity considered in land detector for fixed wings even when invalid.

Solution

  • Add condition to disregard horizontal velocity when vehicle_local_position.v_xy_valid is false.
  • Add additional rotational velocity condition for landed state.

Changelog Entry

For release notes:

Feature/Bugfix: Add condition to disregard horizontal velocity when vehicle_local_position.v_xy_valid is false in land detector for fixed wings. Add extra land condition based on rotational velocity. 

Test coverage

  • Simulation/hardware testing logs: to be tested


if (!_vehicle_local_position.v_xy_valid) {
// set _velocity_xy_filtered to 0 if data is invalid
val = 0.0f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to add some logic that makes the acceleration threshold tighter if we don't have ground speed and airspeed. Similar to what we already do for the ground speed check if there is no airspeed.
Otherwise it gets dangerous to fly planes without GPS and without airspeed sensor, as then they could detect "landing" in-air if flies very smoothly.

Copy link

github-actions bot commented Dec 20, 2024

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 248 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +248  +0.0%    +248    .text
   +15%    +152   +15%    +152    ../../src/modules/land_detector/FixedwingLandDetector.cpp
  +0.2%     +40  +0.2%     +40    ../../src/lib/parameters/parameters.cpp
  +0.0%     +29  +0.0%     +29    ROMFS/nsh_romfsimg.c
  +0.0%     +24  +0.0%     +24    [section .text]
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.cpp
+0.0%    +106  [ = ]       0    .debug_abbrev
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
  +1.8%     +50  [ = ]       0    ../../src/modules/land_detector/FixedwingLandDetector.cpp
-0.0%      -8  [ = ]       0    .debug_aranges
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
+0.0%     +20  [ = ]       0    .debug_frame
+0.0% +5.32Ki  [ = ]       0    .debug_info
  +0.0%      +8  [ = ]       0    ../../src/drivers/batt_smbus/batt_smbus.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/cdcacm_autostart/cdcacm_autostart.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/distance_sensor/lightware_laser_i2c/lightware_laser_i2c.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/dshot/DShot.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/heater/heater.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/lights/rgbled/rgbled.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/lights/rgbled_is31fl3195/rgbled_is31fl3195.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/lights/rgbled_lp5562/rgbled_lp5562.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/lights/rgbled_ncp5623c/rgbled_ncp5623c.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/osd/msp_osd/msp_osd.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina226/ina226.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina226/ina226_main.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina228/ina228.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina228/ina228_main.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina238/ina238.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina238/ina238_main.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/pm_selector_auterion/PowerMonitorSelectorAuterion.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/pwm_out/PWMOut.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/px4io/px4io.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/rc/crsf_rc/CrsfRc.cpp
 -100.0% +5.16Ki  [ = ]       0    [171 Others]
+0.0%    +320  [ = ]       0    .debug_line
  +0.2%     +37  [ = ]       0    ../../src/lib/parameters/parameters.cpp
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +7.3%    +311  [ = ]       0    ../../src/modules/land_detector/FixedwingLandDetector.cpp
  -0.3%      -3  [ = ]       0    task/task_cancelpt.c
+0.0%    +819  [ = ]       0    .debug_loc
  -0.1%     -15  [ = ]       0    ../../src/drivers/px4io/px4io.cpp
  +0.0%     +30  [ = ]       0    ../../src/drivers/uavcan/uavcan_main.cpp
  -0.0%     -13  [ = ]       0    ../../src/drivers/uavcan/uavcan_servers.cpp
  +0.1%     +15  [ = ]       0    ../../src/lib/avoidance/ObstacleAvoidance.cpp
  -0.1%     -15  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  +0.1%     +16  [ = ]       0    ../../src/lib/mixer_module/mixer_module.cpp
  -0.0%      -2  [ = ]       0    ../../src/lib/parameters/parameters.cpp
  -0.2%     -15  [ = ]       0    ../../src/lib/rtl/rtl_time_estimator.cpp
  +0.0%     +15  [ = ]       0    ../../src/modules/commander/Commander.cpp
  +0.1%     +13  [ = ]       0    ../../src/modules/commander/failure_detector/FailureDetector.cpp
  -0.6%     -48  [ = ]       0    ../../src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.cpp
  -0.3%     -15  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/FlightTask/FlightTask.cpp
  +0.1%     +15  [ = ]       0    ../../src/modules/gyro_calibration/GyroCalibration.cpp
   +21%    +896  [ = ]       0    ../../src/modules/land_detector/FixedwingLandDetector.cpp
  -0.1%     -16  [ = ]       0    ../../src/modules/navigator/navigator_main.cpp
  -0.5%     -15  [ = ]       0    ../../src/modules/navigator/rtl_mission_fast.cpp
  -0.4%     -15  [ = ]       0    ../../src/modules/navigator/rtl_mission_fast_reverse.cpp
  +0.0%      +3  [ = ]       0    ../../src/modules/sensors/vehicle_imu/VehicleIMU.cpp
  -0.1%     -15  [ = ]       0    ../../src/modules/sensors/vehicle_magnetometer/VehicleMagnetometer.cpp
  -0.1%     -15  [ = ]       0    ../../src/modules/sensors/vehicle_optical_flow/VehicleOpticalFlow.cpp
 -100.0%     +15  [ = ]       0    [5 Others]
+0.0%    +177  [ = ]       0    .debug_ranges
  +0.4%     +56  [ = ]       0    ../../src/lib/parameters/parameters.cpp
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
   +12%    +128  [ = ]       0    ../../src/modules/land_detector/FixedwingLandDetector.cpp
  +1.6%      +1  [ = ]       0    task/task_cancelpt.c
+0.0%    +996  [ = ]       0    .debug_str
  +0.0%     +14  [ = ]       0    ../../src/drivers/batt_smbus/batt_smbus.cpp
  +0.0%     +11  [ = ]       0    ../../src/modules/flight_mode_manager/FlightModeManager.cpp
   +13%    +129  [ = ]       0    ../../src/modules/land_detector/FixedwingLandDetector.cpp
  +5.4%    +841  [ = ]       0    ../../src/modules/land_detector/land_detector_main.cpp
  +0.0%      +1  [ = ]       0    src/modules/flight_mode_manager/FlightTasks_generated.cpp
-1.5%    -248  [ = ]       0    [Unmapped]
+0.0% +7.69Ki  +0.0%    +248    TOTAL

px4_fmu-v6x [Total VM Diff: 208 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +208  +0.0%    +208    .text
   +15%    +152   +15%    +152    ../../src/modules/land_detector/FixedwingLandDetector.cpp
  +0.0%     +28  +0.0%     +28    [section .text]
  +0.0%     +17  +0.0%     +17    ROMFS/nsh_romfsimg.c
  +0.0%      +8  +0.0%      +8    ../../src/lib/parameters/parameters.cpp
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.cpp
+0.0%    +106  [ = ]       0    .debug_abbrev
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
  +1.8%     +50  [ = ]       0    ../../src/modules/land_detector/FixedwingLandDetector.cpp
-0.0%      -8  [ = ]       0    .debug_aranges
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
+0.0%      +8  [ = ]       0    .debug_frame
+0.0% +5.24Ki  [ = ]       0    .debug_info
  +0.0%      +8  [ = ]       0    ../../src/drivers/cdcacm_autostart/cdcacm_autostart.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/distance_sensor/lightware_laser_i2c/lightware_laser_i2c.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/dshot/DShot.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/heater/heater.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/lights/rgbled/rgbled.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/lights/rgbled_is31fl3195/rgbled_is31fl3195.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/lights/rgbled_lp5562/rgbled_lp5562.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/lights/rgbled_ncp5623c/rgbled_ncp5623c.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/osd/msp_osd/msp_osd.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina226/ina226.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina226/ina226_main.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina228/ina228.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina228/ina228_main.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina238/ina238.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/ina238/ina238_main.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/power_monitor/pm_selector_auterion/PowerMonitorSelectorAuterion.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/pwm_out/PWMOut.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/px4io/px4io.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/rc_input/RCInput.cpp
  +0.0%      +8  [ = ]       0    ../../src/drivers/uavcan/actuators/esc.cpp
 -100.0% +5.08Ki  [ = ]       0    [160 Others]
+0.0%    +284  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +7.3%    +311  [ = ]       0    ../../src/modules/land_detector/FixedwingLandDetector.cpp
  -0.2%      -2  [ = ]       0    task/task_cancelpt.c
+0.0%    +959  [ = ]       0    .debug_loc
  +0.1%     +15  [ = ]       0    ../../src/drivers/uavcan/remoteid.cpp
  +0.0%     +14  [ = ]       0    ../../src/drivers/uavcan/uavcan_servers.cpp
  +0.0%      +2  [ = ]       0    ../../src/modules/commander/failure_detector/FailureDetector.cpp
  +0.6%     +48  [ = ]       0    ../../src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.cpp
  -0.1%     -15  [ = ]       0    ../../src/modules/fw_att_control/FixedwingAttitudeControl.cpp
   +21%    +911  [ = ]       0    ../../src/modules/land_detector/FixedwingLandDetector.cpp
  -0.0%     -15  [ = ]       0    ../../src/modules/mc_pos_control/MulticopterPositionControl.cpp
  +0.1%     +16  [ = ]       0    ../../src/modules/navigator/navigator_main.cpp
  -0.1%     -15  [ = ]       0    ../../src/modules/navigator/rtl.cpp
  -0.2%     -15  [ = ]       0    ../../src/modules/navigator/rtl_direct_mission_land.cpp
  -0.1%     -15  [ = ]       0    ../../src/modules/sensors/sensors.cpp
  +0.2%     +30  [ = ]       0    ../../src/modules/sensors/voted_sensors_update.cpp
  -0.3%     -15  [ = ]       0    ../../src/modules/temperature_compensation/TemperatureCompensationModule.cpp
  +0.0%     +28  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -0.0%     -15  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
+0.0%    +121  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
   +12%    +128  [ = ]       0    ../../src/modules/land_detector/FixedwingLandDetector.cpp
  +1.5%      +1  [ = ]       0    task/task_cancelpt.c
+0.0%    +984  [ = ]       0    .debug_str
  +0.0%     +14  [ = ]       0    ../../src/drivers/cdcacm_autostart/cdcacm_autostart.cpp
   +13%    +129  [ = ]       0    ../../src/modules/land_detector/FixedwingLandDetector.cpp
  +5.3%    +841  [ = ]       0    ../../src/modules/land_detector/land_detector_main.cpp
-0.3%    -208  [ = ]       0    [Unmapped]
+0.0% +7.63Ki  +0.0%    +208    TOTAL

Updated: 2025-01-06T14:13:12

* @decimal 1
* @group Land Detector
*/
PARAM_DEFINE_FLOAT(LNDFW_ROT_MAX, 0.06f);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Threshold determined based on SITL data and works when all other checks are turned off. Needs to be checked against real flight data.

@@ -105,15 +114,28 @@ bool FixedwingLandDetector::_get_landed_state()
const float acc_hor = matrix::Vector2f(_acceleration).norm();
_xy_accel_filtered = _xy_accel_filtered * 0.8f + acc_hor * 0.18f;

// Check for angular velocity (disregard yaw)
const float rot_vel_hor = _angular_velocity.xy().norm();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering only rotations around x & y to be consistent with MC landing condition, but can be extended to all three axes if it makes sense in FW context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants