PX4-Autopilot icon indicating copy to clipboard operation
PX4-Autopilot copied to clipboard

Fix max-hagl restriction to position/altitude control

Open haumarco opened this issue 5 months ago • 0 comments

Currently, when flying with only optical flow in position mode, you can easily surpass the max HAGL by continuously pushing the throttle up. The vehicle decelerates until it eventually exceeds the limit. At that point, we immediately lose optical flow measurements (when above the max height), and consequently, the HAGL max parameter is no longer set. I modified the controller to limit the altitude to 1 meter (or 10%) below the actual max height limit. This ensures that even after approaching the limit, optical flow remains active, and the controller tries to correct the altitude.

Previously, the HAGL max also influenced the controller in altitude mode, which was undesirable when using a range sensor or barometer. To resolve this, I split the HAGL max field of the local position message into hagl_max_z (for vertical control) and hagl_max_xy (for horizontal position control).

When flying at max_hgt_xy, the platform descends if the terrain elevation decreases, in order to maintain a valid local position estimate. Additionally, when flying near the hagl_max_xy limit, I adjust the maximum horizontal velocity to reduce the risk of losing optical flow due to rapid elevation changes.

To avoid adding new subscribers, the hagl_max controller setting is still handled in the estimator. In the FlightTaskManAcc, I now set the max_dist_to_ground of the FlightTaskManAlt because it depends on whether ManAcc is running. Since ManAlt cannot directly check if ManAcc is running (as it's a cascaded controller), this adjustment was necessary in order to keep it simple.


Please also give some feedback if this behavior fits what a typical user would expect.

haumarco avatar Sep 11 '24 08:09 haumarco