-
Notifications
You must be signed in to change notification settings - Fork 17.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
AC_AttitudeControl: Fix dt update order #28040
Conversation
Just to make sure I have understood this correctly: Currently we do the integration of By moving the integration to the start of the loop were also using the angular velocity's from the last loop. The result is that the angular velocity's and the |
There is a change in behavior in the |
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.
I suspect this makes the same problem worse on plane. The problem is that copter sets all the dt's in the run_rate_controller
call which is the first thing that happens in the loop. On plane we also update the dt's in the rate_controller_run
call. However we do that at the end of the loop. So when the attitude controller uses dt it will be the loop before last not the last loop.
I think the fix for plane is to move the setting of the dt's away from the run_rate_controller
call and do them at the start of the loop the same as copter. I think we could probably do that without too much testing, however moving the actual run_rate_controller
so we completely match copter would be a big job.
Anyway, I don't think we need to worry too much about plane in this PR.
This function sets:
So the attitude target does not change.
I agree. These timing issues become less and less important as aircraft get bigger and the filter frequencies get lower. It would be good for plane to optimise the loop structure but I doubt any of these changes will impact the performance of plane. |
6891399
to
12ea95c
Compare
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.
I think the changes look good. The only question is that this now updates the attitude target in every case not just if _rate_bf_ff_enabled
is true?
Yes that is correct. When |
Line 501 can be improved by factoring dt. |
12ea95c
to
bf502f7
Compare
Tested on my 5" - looks good. |
This PR moves the movement of target position to the first step of the attitude controller where it knows the dt.
Currently we assume the next dt will be the same as the last dt. This causes noise in the rate controllers when dt changes and high rates are being requested.
Limitations in ATT logging has made this difficult to observe previously.
Before:
After: