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

Acceleration based control/feed-forward #14212

Merged
merged 9 commits into from
Mar 30, 2020
Merged

Acceleration based control/feed-forward #14212

merged 9 commits into from
Mar 30, 2020

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Feb 22, 2020

Describe problem solved by this pull request
More or less last step to finish splitting up and QAing #12072. It's based on #245 and introduces processing acceleration setpoints. This enables acceleration feed-forward which the jerk optimized flight tasks by @bresch immediately make use of. It also heavily reduces dependence between collective thrust and vehicle tilt making the demanded tilt less jerky when the altitude control output is changing.

Describe your solution
I make the velocity control output acceleration in m/s² which in theory would make the controller tuning more independent of the vehicle's thrust to weight ratio (~hover thrust) but for the initial introduction I introduce a scaling factor using the hover thrust to make the existing gains compatible. To separate the high-frequency altitude control changes from the collective thrust from the demanded tilt I'm switching control strategy to apply horizontal acceleration setpoints assuming hover/gravitational acceleration in the vertical direction effectively directly mapping it to the vehicle's tilt. The vertical acceleration gets projected onto the planned tilt and then executed by setting the collective thrust accordingly. Only in the limit case of more than the maximum thrust tilt gets coupled by being limited using vertical acceleration demand to ensure prioritizing altitude control over horizontal navigation.

Test data / coverage
For the basic limit cases, input combinations, failsafe and zero thrust inputs there are unit tests now. I did a lot of SITL testing and multiple outdoor tests with a 250 size, one test on a big multicopter.

Additional context
Refactorings that made this change possible: #13247, #13248, #13262, #13347, #13701, #14017

  • I still need to change the jerk limits for manual and auto since the tracking is tighter now.
  • I discussed with @Jaeyoung-Lim to expose the acceleration on the offboard interface to allow more dynamic flights and a different kind of input that doesn't rely on vehicle internal velocity estimate.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Feb 25, 2020

I rebased on master and removed the draft since the configuration default changes are also there.
It's maybe not ready for final testing because of flash problems?

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Feb 26, 2020

@MaEtUgR I tried offboard acceleration feedforward with this PR, but couldn't enter offboard mode. Am I missing something?

I was sending on POSITION_TARGET_TYPEMASK=0 on POSITION_TARGET_LOCAL_NED.

WARN  [mc_pos_control] Altitude-Ctrl activation failed with error: Activation Failed

Same offboard setpoint works on master, but enabling acceleration setpoints introduces hunge tracking errors.

To benchmark the performance I am sending POSITION_TARGET_LOCAL_NED and sending position, velocity, accleleration to follow a circular trajectory. Here are the logs in SITL.:
Acceleration enabled in Offboard
Acceleration ignored in Offboard

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Feb 26, 2020

@Jaeyoung-Lim Thanks for testing offboard!!
The provided logs show that instead of actually setting acceleration the normalized collective thrust vector is set to the value you probably want to give in m/s^2
image
I presumably fixed that with this pr: https://github.com/PX4/Firmware/pull/14212/files#diff-f58f83b125f08a9604e2b91bb9f94b1bL231-L233

I don't know why you can't enter offboard mode, maybe we can have a quick look together to get a clue?

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Feb 26, 2020

@MaEtUgR Ah, sorry for not being clear. That was the logs from master since I couldn't make it go in offboard mode with this PR. Would be great if we can dig in!

@Jaeyoung-Lim
Copy link
Member

@MaEtUgR Disarming shortly after arming in offboard mode : Log

@dannyfpv
Copy link

tested on pixhawk4 v5 f-450
Modes Tested*

Position Mode: Good.
Altitude Mode: Good.
Stabilized Mode: Good.
Mission Plan Mode (Automated): Good.
go to: Good.
RTL: Good.

  • Procedure
    Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode proceed to switch to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoin activate RTL

Notes:
No issues noted, good flight in general.

Log:
https://review.px4.io/plot_app?log=d2109f81-1651-4b5d-91de-92147ee43378

@Junkim3DR
Copy link

Junkim3DR commented Feb 29, 2020

Tested on NXP FMUK66 v3

Modes Tested

  • Mission Plan Mode (Automated):
  • Good.Go To Mode (Automated): Good.
  • RTL (Return To Land): Good.

Procedure
Note: Vehicle was sent to a "Go To" point then RTL was triggered
Arm and Take off in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once all waypoints are completed make sure vehicle triggers RTL.

Notes
Good flight in general.

Logs
https://review.px4.io/plot_app?log=b3dfd093-4eb9-457b-9723-ddbe76de9ccf

Tested on Pixhawk 3 v4Pro

Modes Tested

  • Mission Plan Mode (Automated):
  • Good.Go To Mode (Automated): Good.
  • RTL (Return To Land): Good.

Procedure
Note: Vehicle was sent to a "Go To" point then RTL was triggered
Arm and Take off in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once all waypoints are completed make sure vehicle triggers RTL.

Notes
Good flight in general.

Logs
https://review.px4.io/plot_app?log=c8254650-1392-4e7a-94fc-de6d030a939f

@jorge789
Copy link

Tested on PixRacer V4

Tested Modes

Position Mode
Mission plan mode (automated):
Good. Go to (Automated) mode: Good.
RTL (Back to Earth): Good.
Process
Note: the vehicle was sent to a "Go to" point in the middle of mission and then RTL was activated
Assemble and take off in Position mode after flying one minute, switch to mission plan, then make sure the vehicle follows all the waypoints as shown in QGC, once all waypoints are completed, make sure of the vehicle activating RTL.

Notes
Good flight overall.

Logs
https://review.px4.io/plot_app?log=7286d189-3cdf-4a76-aa01-2edfe1a6633d

https://review.px4.io/plot_app?log=6aa51b7b-f999-4aea-bcdd-1a4cb0bde0ac

Tested on CUAV nano V5

Tested Modes

Position Mode
Mission plan mode (automated):
Good. Go to (Automated) mode: Good.
RTL (Back to Earth): Good.
Process
Note: the vehicle was sent to a "Go to" point in the middle of mission and then RTL was activated
Assemble and take off in Position mode after flying one minute, switch to mission plan, then make sure the vehicle follows all the waypoints as shown in QGC, once all waypoints are completed, make sure of the vehicle activating RTL.

Notes
Good flight overall.

Logs
https://review.px4.io/plot_app?log=ac76803a-1689-420b-9516-fb67c423614c

https://review.px4.io/plot_app?log=d12827ac-cfd1-48d1-babe-b85b10c54264

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Mar 1, 2020

@dagar As we discussed I rebased (without conflict) and removed the in my eyes deprecated FlightTaskSport to make it fit in the flash of the omnibus. Here's the commit message explaining:

This mode was just kept as an example after
its usage in a single case. It's basically untested
and doesn't make much sense anymore since it's
incompatible with the jerk limited trajectory
implementations. The implementation only switched
the configuration parameter of the velocity resulting
from maximum stick deflection to be
MPC_XY_VEL_MAX instead of MPC_VEL_MANUAL.
This is according to todays understanding undesired
because when hitting that limit the position
controller has no room for corrections anymore.

Also it saves some flash space on omnibus to remove
the task at this point and makes romm for the
acceleration feed-forward.

EDIT: I think now CI is showing the offboard problem that @Jaeyoung-Lim saw before.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Mar 4, 2020

I rebased on master and tried to reproduce the offboard issues by using the MAVSDK offboard integration tests:
./build/src/integration_tests/integration_tests_runner --gtest_filter="SitlTest.Offboard*"
But they all pass and seem to be doing what is expected looking at the simulation UI.

What do the two different errors I had come from, could they be glitches?
before rebasing: http://ci.px4.io:8080/blue/organizations/jenkins/PX4_misc%2FFirmware-SITL_tests/detail/PR-14212/6/pipeline
after rebasing: http://ci.px4.io:8080/blue/organizations/jenkins/PX4_misc%2FFirmware-SITL_tests/detail/PR-14212/7/pipeline

Now also jenkins seems to cancel my build NuttX builds only one shows in the UI and whole test fails even though the GitHub workflow builds succeed and "dronecode-macmini" cannot be contacted for the Mac build.

@hamishwillee
Copy link
Contributor

@MaEtUgR Any docs impact to all this?

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Mar 5, 2020

@hamishwillee Good point. Sport mode was never documented since it wasn't too different. But the control diagram https://dev.px4.io/master/en/flight_stack/controller_diagrams.html#multicopter-position-controller needs to be adjusted a little bit. Time to look into how these diagrams 😬

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Mar 6, 2020

I was able to reproduce what CI is flying and it found a real issue that I'm currently looking into.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Mar 28, 2020

@bresch Here's the plot of the same scenario including velocity tracking. Note that it's not tracking anymore because it's hitting the maximum tilt limit and the integrator is still not winding up:
image
Log: https://logs.px4.io/plot_app?log=40bbbfcc-7db9-4667-ac18-b735745235e0


Rebased on master and lowered the maximum jerk in the VTOL defaults based on @fury1895's valuable VTOL testing feedback 🎉 . That concludes testing and fixes from my side and I consider it ready to merge 👍

Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

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

Awesome!

@MaEtUgR MaEtUgR merged commit bda0725 into master Mar 30, 2020
@MaEtUgR MaEtUgR deleted the acceleration-control branch March 30, 2020 07:58
MaEtUgR added a commit that referenced this pull request Apr 27, 2020
Before #14212 the velocity control gains used in the multicopter
position controller were defined as a scale between velocity error in
one axis (or it's integral and derivative respectively) and the unit
thrust vector. The problem with this is that the normalization of the
unit thrust vector changes per vehicle or even vehicle configuration
as 0 and 100% thrust get a different physical response. That's why
the gains are now defined as scale between velocity error
(integral/derivative) and the output acceleration in m/s².
MaEtUgR added a commit that referenced this pull request May 4, 2020
Before #14212 the velocity control gains used in the multicopter
position controller were defined as a scale between velocity error in
one axis (or it's integral and derivative respectively) and the unit
thrust vector. The problem with this is that the normalization of the
unit thrust vector changes per vehicle or even vehicle configuration
as 0 and 100% thrust get a different physical response. That's why
the gains are now defined as scale between velocity error
(integral/derivative) and the output acceleration in m/s².
MaEtUgR added a commit that referenced this pull request May 6, 2020
Before #14212 the velocity control gains used in the multicopter
position controller were defined as a scale between velocity error in
one axis (or it's integral and derivative respectively) and the unit
thrust vector. The problem with this is that the normalization of the
unit thrust vector changes per vehicle or even vehicle configuration
as 0 and 100% thrust get a different physical response. That's why
the gains are now defined as scale between velocity error
(integral/derivative) and the output acceleration in m/s².
MaEtUgR added a commit that referenced this pull request May 11, 2020
Before #14212 the velocity control gains used in the multicopter
position controller were defined as a scale between velocity error in
one axis (or it's integral and derivative respectively) and the unit
thrust vector. The problem with this is that the normalization of the
unit thrust vector changes per vehicle or even vehicle configuration
as 0 and 100% thrust get a different physical response. That's why
the gains are now defined as scale between velocity error
(integral/derivative) and the output acceleration in m/s².
@Jaeyoung-Lim
Copy link
Member

@MaEtUgR Maybe this is too late, but I have tried this with offboard control, but this doesn't seem to work with offboard control.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented May 18, 2020

@Jaeyoung-Lim It's never too late. Is there an easy way to reproduce such that we can find the issue?

@Jaeyoung-Lim
Copy link
Member

@MaEtUgR You can use the ROS node I created, but if this is too much overhead I can also create a simple mavsdk app for testing

@MaEtUgR
Copy link
Member Author

MaEtUgR commented May 18, 2020

I can also create a simple mavsdk app for testing

I think that would be useful not just for me but also to put in CI to make sure it does not break again.

MaEtUgR added a commit that referenced this pull request May 19, 2020
Before #14212 the velocity control gains used in the multicopter
position controller were defined as a scale between velocity error in
one axis (or it's integral and derivative respectively) and the unit
thrust vector. The problem with this is that the normalization of the
unit thrust vector changes per vehicle or even vehicle configuration
as 0 and 100% thrust get a different physical response. That's why
the gains are now defined as scale between velocity error
(integral/derivative) and the output acceleration in m/s².
MaEtUgR added a commit that referenced this pull request May 25, 2020
Before #14212 the velocity control gains used in the multicopter
position controller were defined as a scale between velocity error in
one axis (or it's integral and derivative respectively) and the unit
thrust vector. The problem with this is that the normalization of the
unit thrust vector changes per vehicle or even vehicle configuration
as 0 and 100% thrust get a different physical response. That's why
the gains are now defined as scale between velocity error
(integral/derivative) and the output acceleration in m/s².
MaEtUgR added a commit that referenced this pull request May 26, 2020
Before #14212 the velocity control gains used in the multicopter
position controller were defined as a scale between velocity error in
one axis (or it's integral and derivative respectively) and the unit
thrust vector. The problem with this is that the normalization of the
unit thrust vector changes per vehicle or even vehicle configuration
as 0 and 100% thrust get a different physical response. That's why
the gains are now defined as scale between velocity error
(integral/derivative) and the output acceleration in m/s².
MaEtUgR added a commit that referenced this pull request Jul 13, 2020
The acceleration setpoint gets implicitly inherited from the altitude
flight task since #14212. This feed-forward adds an unwanted
acceleration when the right stick is deflected. Instead I'm using it
to command the expected centripetal acceleration when flying
in a circle for better orbit tracking.
bresch pushed a commit that referenced this pull request Jul 14, 2020
The acceleration setpoint gets implicitly inherited from the altitude
flight task since #14212. This feed-forward adds an unwanted
acceleration when the right stick is deflected. Instead I'm using it
to command the expected centripetal acceleration when flying
in a circle for better orbit tracking.
DanielePettenuzzo pushed a commit that referenced this pull request Jul 28, 2020
Before #14212 the velocity control gains used in the multicopter
position controller were defined as a scale between velocity error in
one axis (or it's integral and derivative respectively) and the unit
thrust vector. The problem with this is that the normalization of the
unit thrust vector changes per vehicle or even vehicle configuration
as 0 and 100% thrust get a different physical response. That's why
the gains are now defined as scale between velocity error
(integral/derivative) and the output acceleration in m/s².
baumanta pushed a commit to baumanta/Firmware that referenced this pull request Aug 18, 2020
The acceleration setpoint gets implicitly inherited from the altitude
flight task since PX4#14212. This feed-forward adds an unwanted
acceleration when the right stick is deflected. Instead I'm using it
to command the expected centripetal acceleration when flying
in a circle for better orbit tracking.
baumanta pushed a commit to baumanta/Firmware that referenced this pull request Sep 15, 2020
The acceleration setpoint gets implicitly inherited from the altitude
flight task since PX4#14212. This feed-forward adds an unwanted
acceleration when the right stick is deflected. Instead I'm using it
to command the expected centripetal acceleration when flying
in a circle for better orbit tracking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants