-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Hover thrust estimator #13981
Hover thrust estimator #13981
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome.
An idea, how about we already use the value of the estimated hover thrust if the parameter is set to 0? Then existing users won't be affected, but with a single parameter change can get the new behavior. We can set the default to 0 once we are happy with the performance.
Also, I'm very interested to see how the convergence speed is on initialization, compared to noise rejection over longer periods. There might be value in using vertical velocity estimate plus a drag model to improve accuracy - but I'm not sure if that will be necessary, since this is already a huge improvement over a single hardcoded value.
@@ -603,6 +607,11 @@ MulticopterPositionControl::Run() | |||
_control.resetIntegral(); | |||
// reactivate the task which will reset the setpoint to current state | |||
_flight_tasks.reActivate(); | |||
_hover_thrust_estimator.reset(); | |||
|
|||
} else if (_takeoff.getTakeoffState() >= TakeoffState::flight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to handle landing as well to make sure it doesn't get corrupted? Or will this work for the landing case too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, i would need to check that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the else case? Would you want to run it if PX4_ISFINITE(setpoint.thrust[2])
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bresch did you check this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhkabir Yes, due to the high inconsistency at touchdown, the measurements are rejected until the recovery kicks-in and we should be able to detect landing in the mean time (using that inconsistency as a ground contact check).
About the "Why is this in the else case? Would you want to run it if PX4_ISFINITE(setpoint.thrust[2])?", I placed it in that else because it gets reset when on ground in the if
above, so we don't need to do a double check. It might not be ideal but I can still change that when I use the output of the filter for feedforward and land detection.
/** | ||
* Hover thrust process noise | ||
* | ||
* Bla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bresch Bla? :-D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that clear enough? xD
@bresch Btw, I really like to use these lecture note as reference. I think it provides a really good summary in case you don't always want to read 1000 pages in the Kalman filter book. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Work, I like the separation of the HoverThrustEstimator and ZeroOrderHoverThrustEstimator.
Are the local_pos_sp.thrust
and _states.acceleration
in local/world coordinates?
If you rebase there's a big chunk of flash available on fmu-v2 now. |
e37ce88
to
5394248
Compare
@PX4/testflights Can you give that PR a quick try please? This is just for logging, don't expect anything different. |
Tested on NXP FMUK66 v3Modes Tested Procedure Notes Log |
Tested on PixRacer V4Modes Tested Procedure Notes Log Tested on CUAV nano V5Modes Tested Procedure Notes Log |
Tested on Pixhawk 4 V5 f-450 Procedure Notes Log |
Thanks @Junkim3DR @dannyfpv and @jorge789 ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice architecture with the interface class!
@@ -603,6 +607,11 @@ MulticopterPositionControl::Run() | |||
_control.resetIntegral(); | |||
// reactivate the task which will reset the setpoint to current state | |||
_flight_tasks.reActivate(); | |||
_hover_thrust_estimator.reset(); | |||
|
|||
} else if (_takeoff.getTakeoffState() >= TakeoffState::flight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the else case? Would you want to run it if PX4_ISFINITE(setpoint.thrust[2])
?
@PX4/testflights could you make a few more flights please? |
Codecov Report
@@ Coverage Diff @@
## master #13981 +/- ##
==========================================
- Coverage 42.32% 36.19% -6.14%
==========================================
Files 608 552 -56
Lines 51322 47108 -4214
==========================================
- Hits 21723 17051 -4672
- Misses 29599 30057 +458
|
Tested on NXP FMUK66 v3Modes Tested
Procedure Notes Log |
msg/tools/uorb_rtps_message_ids.yaml
Outdated
@@ -352,4 +352,7 @@ rtps: | |||
- msg: estimator_innovation_test_ratios | |||
id: 171 | |||
alias: estimator_innovations | |||
- msg: hover_thrust_estimator | |||
id: 172 | |||
alias: hover_thrust_estimator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be moved to the earlier section (128).
msg/CMakeLists.txt
Outdated
@@ -68,6 +68,7 @@ set(msg_files | |||
gps_dump.msg | |||
gps_inject_data.msg | |||
home_position.msg | |||
hover_thrust_estimator.msg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if this was hover_thrust_estimate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense
TODO:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tests all passing
with measurement noise auto-tuning The purpose of this estimator is to improve land detection and vertical velocity feedforward Recovery strategy: This is required when the setpoint suddenly changes in air or that the EKF is diverging. A lowpassed test ratio is used as a trigger for the recovery logic Also, a lowpassed residual is used to estimate the steady-state value and remove it when estimating the accel noise to avoid increasing the accel noise when the redisual is caused by an offset.
With noisy accel and thrust in hover, climb and descent conditions.
This is done to test the recovery function of the estimator in case of divergence or sudden extreme hover thrust change. Also specify seed of random generator
@@ -47,32 +47,37 @@ using namespace matrix; | |||
class ZeroOrderHoverThrustEkfTest : public ::testing::Test | |||
{ | |||
public: | |||
ZeroOrderHoverThrustEkfTest() | |||
{ | |||
_random_generator.seed(42); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI (and lessons learned from previous hair-pulling), these still won't be the same across platforms or std libraries... 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jkflying hmm, okay, should I run once the Gaussian noise generator and save the output in a file to be sure that we always use the same data?
Finally merged, thanks everyone for the help! :) |
What would happen in a VTOL in hover with wind? The hover thurst can be really low. |
@VTOLDavid If it's a constant wind and the hover thrust is constantly lower, the estimator will converge to this new value. If it's just wind gusts, the estimator will reject that and keep the same value. |
Thank you for the explanation. |
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: https://discuss.px4.io/t/multicopter-with-1kg-payload-px4/39275/3 |
Describe problem solved by this pull request
The hover thrust is an important parameter of the vehicle that is used during flight for altitude control and to detect landing. It needs to be set manually by the user (MPC_THR_HOVER), and can trigger a crash if wrongly set.
Furthermore, this parameter is constant, but In reality, the real hover thrust is not:
Finally, some vehicles with many possible payloads can have a different hover thrust at almost every takeoff.
Describe your solution
Given the current thrust and the measured vertical acceleration, it is possible to observe the hover thrust. This is done in this PR using a simple single-state EKF.
The model is described and simulated here.
Describe possible alternatives
Some logic that tries to detect a hover to set the hover thrust as the current thrust.
A higher order model
Test data / coverage
Current state: SITL tests, the estimator converges to the correct value. When changing the mass during hover, the estimate follows quickly.
Additional context
Auterion/Flight_Control_Prototyping_Scripts#3
TODO:
add thrust to acceleration dynamic model (first order filter should be enough)edit: not required, the performance is good enoughfixes #12439