-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
[WIP] L1 enhancements: handling small loiter radii and high winds #10219
Conversation
Cool stuff. We are happy to help flight test. |
Could you please rebase? Thanks! |
@tstastny This looks super cool! |
-l1: replace PD controller with adaptive period on original L1 logic for small loiter radii
- remove ground speed undershoot - add wind estimate subscription - use wind estimate in l1 guidance for handling case of wind speed > nominal airspeed reference - add minimum ground speed parameter (used in l1 adaptations) - revert to previous ground speed only formulation if wind estimate is invalid - update corresponding ecl submodule
fbb04ca
to
c270e5b
Compare
I could try the new algorithm (airspeed increment enabled and 5 m/s min ground speed) in SITL (with such a powerful wind (half the maximum allowed airpeed)) and I encoutered a problem when the wind estimate is not correct: |
Thanks for testing! Yes - the guidance of course needs somewhat decent wind estimates. There is a bool there now that disables using the wind estimate in the logic if the estimate is "invalid" - but you are right that this does not help in the case that the estimator believes things are ok. Another (independent) issue at the moment (and listed on the open questions bullet above) is that I took out the ground speed undershoot completely, so there is actually no handling of this when the wind estimate is invalid. First thing I'll add back in (as discussed on the other thread PX4/PX4-ECL#494 (review) with Paul), is (for the invalid wind estimate case) some form of ground speed undershoot utilizing the yaw angle and ground speed vector. This is not efficient, but the only failsafe possible when the wind estimates are not good. This will basically be what was there before, but I can at least get rid of the binary switch at the ground speed threshold to make the roll reference commands a bit smoother. The second part is a bit more open on how to handle it, @priseborough do you have any intuition on how best to interpret the EKF outputs in these cases to the decide when not to use the wind estimate The more I think about this though -- I'm worried that many px4 users do not spend the time to properly calibrate their airspeed sensors (I've seen lots of log files uploaded with clearly underestimated true airspeeds). This will obviously lead to erroneous wind estimates. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I wont have time to work on cleaning up this PR again until about a month from now (end of Feb). But I hope there is still interest. We have been using some version of this logic on our aircraft for the past 6 mo and it works quite well (is relaxing to see the aircraft behaving in a predictable manner in very high windy days). Sorry for the large delay.. just too many other priority projects in the last months. Anyway - I have an idea on how to hopefully satisfy all comments here once I get back into it. |
We are definitely interested in improved fixed wing performance assuming the concerns can be addressed. |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
@tstastny do you think it would be possible to split this up into separate parts to bring them in more easily? |
I think it depends on what is desired as default vs advanced functionality. I discussed with @dagar some time ago about whether or not having separate libraries for different controllers would be a better idea, and then just interfacing them in the standard fw_pos_ctrl_l1 etc files with conditional params. This way no one's running setup gives them any surprises, but anyone is still able to use the new features if they want. On the small loiter radii -- that could for sure be it's own PR. But again, depends on if it is desired as default or not. Regarding @CarlOlsson 's comment on increasing the maximum airspeed in cruise flight (even if it exceeds the maximum airspeed set to make TECS run properly), this one could also be it's own separate PR. I did something simple for my own implementation where I just made a new "max cruise" airspeed setting that is only used when needed to compensate high winds (but keeps the TECS tuning unchanged). I did *not do very much analysis of this though. Was mostly just trying to fly level.. so this would need it's own investigation and experimentation on how to properly implement. Windy augmentations could also be it's own PR. But would likely need some more considerations with the wind estimation. I.e. to make the windy controller run properly I needed to tune up the wind noise to something like 1m/s/s to capture/reject shorter term gusts. Also, depending again on whether or not we go for a separate library approach vs augmenting the current L1 (or both) .
|
@sfuhrer The PR as-is looks more or less manageable. Let's discuss if this needs rather a concerted effort by you and Roman to get things validated and merged. |
note that this part went in separately as an independent PR some time ago: #11381 |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
@tstastny |
Closing as stale. @sfuhrer @RomanBapst Please review what from this could be brought in still. |
@sfuhrer @RomanBapst -- maybe hit me up on slack and we can discuss how these things may still get contributed in a timely fashion, I have coincidentally been "midnighting" some stability analysis for an improved version of all this (according to further developments from my PhD thesis) in the past week or so (off work hours). TL;DR - allows users not to need to change their current L1 tuning.. and is better in every other way. ;) Would just want to coordinate with you two to appropriately plan where and how code goes from the start.
@moreba1, not sure that bigger periods for loitering will help tracking.. I would actually assume the opposite. Though, you need to be careful depending on your vehicle's roll delay, as this acts as a lower bound on the period you can select while keeping path following stability. The other posts about being careful with this PR were correct, that you need to know your system and be certain about the minimum period bound before adapting the period in flight. Something that would be quite easy to determine, however, is exactly this roll time constant, via simple stabilized roll steps and a first order ID. Then one can exactly determine the lowest period they are allowed to set. (via L2+ paper from Curry et. al. ACC, 2003 - this is just about identical logic to what is implemented in PX4). |
Corresponding ECL PR: PX4/PX4-ECL#494
This PR does the following:
Handling small loiter radii
Handling high winds
For more general information on the logic / background, additional information not specific to the PX4 implementation here can be found in https://arxiv.org/abs/1804.04209 and https://ieeexplore.ieee.org/document/7963609/ . I will update the prior link soon with the ground speed minimum formulation.
Replacing ground speed undershoot
The primary issue with ground speed undershoot as currently implemented is that it considers the wrong angle, the "air-to-ground" angle doesn't consider the orientation or magnitude of the wind, and thus results in very large airspeed increments when not necessary. See in the following figure that e.g. when the current airspeed is close to the minimum airspeed (could be the case for example during landings), the ground speed undershoot (which is added to the airspeed reference) approaches the minimum airspeed when flying in head wind. This means the airspeed reference effectively doubles, when really all that would be necessary is a few m/s increase to maintain some minimum forward ground speed.
This minimum forward ground speed can be achieved most efficiently utilizing the bearing feasibility function developed in the papers cited above (see a nice plot and description on the arXiv brief). This is just a geometric relationship (considering the wind triangle -- i.e. airspeed vector + wind speed vector = ground speed vector) which only increases the airspeed reference as much as necessary to maintain the given forward ground speed (where forward ground speed is defined as the projection of ground speed on the airspeed vector, so negative values mean the aircraft is flying backwards with respect to the ground). The plots below show the effect of this function and the resulting airspeed increments commanded for the case of various wind speeds, airspeed nominal reference = 12 m/s, and airspeed max = 16 m/s. The plots assume the aircraft is following the corresponding orientation commands from the wind robustified l1 controller. The forward ground speed is maintained up until such point that the airspeed maximum does not have any more reserve.
Simulations
All simulations were performed in MATLAB with a simple 2D coordinated turn model with representative first order roll and airspeed response dynamics (see https://arxiv.org/pdf/1804.04209.pdf for a more detailed description of the model). All guidance gains (e.g. operator defined period=25 and damping=0.707) were kept the same for each control formulation for a fair comparison. Nominal airspeed reference was defined to 10 m/s.
Tracking small radii with the adaptive period in the standard L1 formulation can be seen in the following simulation. A 20m radius is tracked. The PD control approach currently implemented does not achieve this.
Note the effective period automatically adapts (reduces) to track the circle.
Handling of high winds is compared in the next simulation. Here a 50m radius loiter is commanded, however, the wind speed (12 m/s here) is greater than the airspeed. The maximum allowed airspeed reference is set to 15 m/s. Four control formulations are displayed:
The current PX4 logic has large jumps in roll setpoint due to the hard switch based on the "air-ground" angle and arbitrarily defined 3 m/s ground speed threshold.
The new logic shows each of three modes, 1) run-away mitigation (attempt to reduce the run-away to a minimum), 2) run-away prevention (bring run-away to a halt and hold position), and 3) min ground speed maintenance -- note the forward ground speed does not go below the commanded minimum (if the maximum airspeed would be lower, then the logic would attempt to maintain as much of the minimum as possible, then default to each of the lesser solutions). Airspeed references and forward ground speeds are shown below along with the "bearing feasibility". (note the lagged airspeed response is not shown to de-clutter things, but has a time constant of 1s).
HITL logs (x-plane, hilstar)
Log for small loiter radii (first commit): https://review.px4.io/plot_app?log=07bac744-e5dd-4ca4-abc8-524125878682 . Verified general WP following still works (should not have changed), and both large and small circles are tracked properly with reformulated loiter logic -- the small circle used the automatic period adaptation now present in the controller.
Log for high winds (first+second commit): https://review.px4.io/plot_app?log=dba557a7-8abb-44ec-bd13-43698d6ddf2e . Testing in very high winds (approx. 14 m/s with nominal airspeed reference = 13 m/s). Note my laptop is not powerful enough to send data to x-plane as fast as the EKF always wants -- so when the winds were getting increased, sometimes the GPS position was reset do to the lag in messages -- but after the initial increase in wind speed, things were stable enough in the EKF to test the functionality. Log timeline:
Open questions on implementation:
answer: yes it is constrained in the mission block. navigator/mission_block.cpp#L508
Further work:
This is quite a big PR, so any help testing this for corner cases etc would be very much appreciated. Also happy to get feedback on anything I've missed / not considered while implementing. @dagar @Antiheavy @CarlOlsson @priseborough