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

Bezier trajectory avoidance interface #14279

Merged
merged 7 commits into from
Mar 9, 2020
Merged

Conversation

jkflying
Copy link
Contributor

@jkflying jkflying commented Mar 2, 2020

Describe problem solved by this pull request
Currently the avoidance interface only allows specifying single position setpoints. This PR enables sending time-parameterized Bezier messages, allowing smooth flight control from the companion computer while in auto modes.

Describe your solution
Several parts:

  1. A simple 5-line function to calculate a position given an N-order bezier curve and the current T value, templated on the type of number that is used
  2. Use of Dual numbers to calculate the velocity (and even acceleration), from the above simple function, without needing complex formulae for each curve size.
  3. Parsing of the bezier mavlink message, and translation into uORB
  4. Subscribe to the uORB, and if the newly introduced bezier message has a valid duration, use that to determine the current position and velocity indicated by the bezier curve
  5. Pass these values on using the existing avoidance setpoint injection

Additionally, in order to save FMUv2 flash space, this PR moves the avoidance to a separate library and excludes it from CONSTRAINED_FLASH builds, replacing it with a dummy implementation. Thanks to @julianoes for the pointer with CONSTRAINED_FLASH - I think this is sufficient for now, but longer term I'd like to be able to do something like this via the board configuration similar to modules. @dagar any ideas on a good way to make this easy for the future, since I don't think this way scales? I'm sure there are other libraries that we'd like to replace with dummies for constrained flash builds, which can't be easily hoisted out into modules.

Describe possible alternatives
It might be better for this to not go through the smooth velocity interface, if it is shown that the companion can provide smooth enough curves, and rather send the data directly to the position controller.

Test data / coverage
Extensively unit tested. However there isn't yet a planner which can send the bezier messages, so this hasn't been flight or SITL tested.

FYI @Stifael , since you did some earlier Bezier work.

@jkflying jkflying requested review from MaEtUgR and mrivi March 2, 2020 16:13
@jkflying jkflying force-pushed the pr-bezier-trajectory-interface branch from 857904c to 2eb347d Compare March 2, 2020 17:12
@hamishwillee
Copy link
Contributor

@jkflying Can you update https://docs.px4.io/master/en/computer_vision/path_planning_interface.html to reflect this addition?

Specifically we might need to rename https://docs.px4.io/master/en/computer_vision/path_planning_interface.html#trajectory-interface to "Trajectory Waypoint Interface" and put a peer heading "Trajectory Bezier Interface".

First question that pops into my mind is what happens if PX4 receives streams of both types. Also when should you use one or the other etc.

@jkflying
Copy link
Contributor Author

jkflying commented Mar 4, 2020

@hamishwillee will do once this is closer to merging.

At the moment, if there is a point from the 'old' interface, it uses that instead of the bezier curve data. Bezier curve is if you have some kind of motion planner which is aware of vehicle dynamics, then it allows you to get smoother flight performance, with simultaneously less bandwidth on the serial link. The 'old' interface is slightly easier to understand/use, and already has support of Avoidance/MAVROS. However it was never fully implemented to allow following multiple setpoints, which effectively the new bezier curve implementation does.

@jkflying jkflying force-pushed the pr-bezier-trajectory-interface branch from 2eb347d to 921b842 Compare March 4, 2020 12:15
@hamishwillee
Copy link
Contributor

@jkflying Thanks very much. Let me know if you need help when you're ready to doc.

FWIW So what I think you're saying that you use either the waypoint OR the bezier interface (ie if you send a waypoint message it would supersede the last bezier message (and visa versa)).

I understand the bezier provides you smoother paths with less data, possibly covering multiple waypoints, and that the waypoint interface only covers one waypoint at a time currently.

@jkflying
Copy link
Contributor Author

jkflying commented Mar 5, 2020

The other way I thought of for excluding the library doesn't work, so it will have to be something like this for now.

Details: I thought about putting all the calls to the library inside of an if which had a static false in the builds I wanted to exclude. But there are still other dependencies, eg parameter updates and uOrb subscriptions inside, so the linker doesn't exclude it. Using a dummy class seems to be the way forward, even if not ideal.

@jkflying jkflying force-pushed the pr-bezier-trajectory-interface branch from 921b842 to 53e42bc Compare March 5, 2020 16:01
@jkflying jkflying force-pushed the pr-bezier-trajectory-interface branch from 53e42bc to e62404a Compare March 6, 2020 12:58
@jkflying jkflying merged commit eab8829 into master Mar 9, 2020
@jkflying jkflying deleted the pr-bezier-trajectory-interface branch March 9, 2020 08:51
hamishwillee added a commit to PX4/PX4-user_guide that referenced this pull request Mar 9, 2020
@hamishwillee
Copy link
Contributor

@jkflying
Copy link
Contributor Author

PR on the user guide added: PX4/PX4-user_guide#680 . It's a bit rough - sorry, I'm in a rush here 😅 I don't think there's much more that can be added without a working planner on the other side capable of sending the Bezier curves as well.

@mrpollo mrpollo mentioned this pull request Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants