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

Enable support for global position setpoints with SET_POSITION_TARGET_GLOBAL_INT #12819

Merged
merged 8 commits into from
Sep 3, 2019

Conversation

Jaeyoung-Lim
Copy link
Member

Describe problem solved by the proposed pull request
Currently offboard position setpoints can only be passed in local coordinates with SET_POSITION_TARGET_LOCAL_NED. However, when running multiple vehicles at the same time, this is not scalable as setpoints need to be transformed to each vehicle's local frame.
Also, there has been a lot of workarounds for external applications to use global coordinates and converting it to local coordinates to just enable offboard mode.

Fixes #11625

Describe your preferred solution
Added a message handler in mavlinkreceiver for SET_POSITION_TARGET_GLOBAL_INT which converts the setpoint to local coordinates.

Test data / coverage
This log shows the vehicle position being set to altitude of 12m with the same lon / lat with the home position.
I have also tested with multiple vehicles flying in a circular pattern: https://youtu.be/tj3FcbmsVpw

Additional context
Tools such as mavros convert global position setpoints into local coordinates as a workaround. There has been confusion from mavros users of px4 not supporting this message(mavlink/mavros#1256, mavlink/mavros#903, mavlink/mavros#728 )

@Jaeyoung-Lim Jaeyoung-Lim requested a review from dagar August 27, 2019 22:26
@Jaeyoung-Lim Jaeyoung-Lim force-pushed the pr-global-position-setpoint branch from 276e52e to 07b79e4 Compare August 27, 2019 22:33
@Jaeyoung-Lim Jaeyoung-Lim requested a review from julianoes August 27, 2019 22:34
@hamishwillee
Copy link
Contributor

Just a reminder to update http://docs.px4.io/master/en/flight_modes/offboard.html when this goes in.

I assume this only really affects offboard mode?

@Jaeyoung-Lim
Copy link
Member Author

@hamishwillee Ofcourse! I will prepare a PR for the docs.

Yes it only affects offboard mode

@hamishwillee
Copy link
Contributor

Thanks @Jaeyoung-Lim . Not everyone "remembers" docs. I'm pleased you do.

LorenzMeier
LorenzMeier previously approved these changes Aug 28, 2019
Copy link
Member

@LorenzMeier LorenzMeier left a comment

Choose a reason for hiding this comment

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

Awesome! These small fixes are so critical to keep adopters happy.

@LorenzMeier
Copy link
Member

Please have a quick look at the CI failures

Copy link
Contributor

@julianoes julianoes left a comment

Choose a reason for hiding this comment

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

Thanks for this! I made some comments how I think this could be improved.

Also, it would be nice to add an integration test to MAVSDK to test it.

src/modules/mavlink/mavlink_receiver.cpp Outdated Show resolved Hide resolved
src/modules/mavlink/mavlink_receiver.cpp Show resolved Hide resolved
src/modules/mavlink/mavlink_receiver.cpp Outdated Show resolved Hide resolved
src/modules/mavlink/mavlink_receiver.cpp Outdated Show resolved Hide resolved
src/modules/mavlink/mavlink_receiver.cpp Outdated Show resolved Hide resolved
src/modules/mavlink/mavlink_receiver.cpp Outdated Show resolved Hide resolved
src/modules/mavlink/mavlink_receiver.cpp Outdated Show resolved Hide resolved
@Jaeyoung-Lim
Copy link
Member Author

@julianoes I would be interested in adding the unit tests to mavsdk. Could you provide any pointers?

@julianoes
Copy link
Contributor

@Jaeyoung-Lim that would be great.

Actually, MAVSDK doesn't support global position offboard yet, so it would have to be added there as well, like the implementation for local position:
https://github.com/mavlink/MAVSDK/blob/e84034a468d67be6666296fadcb95312d77cc20c/src/plugins/offboard/offboard_impl.cpp#L112-L137

And then a test would look like this:
https://github.com/mavlink/MAVSDK/blob/e84034a468d67be6666296fadcb95312d77cc20c/src/integration_tests/offboard_position.cpp#L43-L51

@Jaeyoung-Lim
Copy link
Member Author

@julianoes Thanks for the pointers!

@Jaeyoung-Lim
Copy link
Member Author

Jaeyoung-Lim commented Sep 2, 2019

@julianoes Could we merge this since the documentation has been updated already? I would prefer making the improvements regarding the indentation and logic together with the message handling of SET_POSITION_LOCAL_NED message, since the code is nearly identical.

@hamishwillee

@julianoes
Copy link
Contributor

@Jaeyoung-Lim absolutely!

@julianoes julianoes merged commit 09dab07 into PX4:master Sep 3, 2019
@Jaeyoung-Lim Jaeyoung-Lim deleted the pr-global-position-setpoint branch September 3, 2019 09:26
@TSC21
Copy link
Member

TSC21 commented Sep 3, 2019

@Jaeyoung-Lim are you open to add support for this on the MAVROS setpoint_position plugin? Currently we have the /setpoint_position/global topic that does the conversion from LLA to ENU and sends it as local position setpoints. We can keep that but for the current callback, the topic can be renamed to /setpoint_position/global_to_local and add a new callback that subscribes to /setpoint_position/global of type geographic_msgs/GeoPoint (or GeoPose if you set the orientation as well).

@Jaeyoung-Lim
Copy link
Member Author

Jaeyoung-Lim commented Sep 3, 2019

@TSC21 Thanks for the suggestions! I would be interested to add support on MAVROS. I was super confused with that plugin when I was trying to use global setpoints on mavros for that reason(hence, this PR).

Could you explain on why we would want to use geographic_msgs/GeoPoint compared to the mavros_msgs/GlobalPositionTarget? IMO it would make sense to replace the call back to simplify the plugin.

@Jaeyoung-Lim
Copy link
Member Author

@TSC21 Ah I misunderstood what you were saying. So I should replace the current callback to the set_position_target_global_int and move the current callback to a new topic. Makes sense.

@TSC21
Copy link
Member

TSC21 commented Sep 3, 2019

@Jaeyoung-Lim what I am saying is that inside the setpoint_position we are handling the data being published in /setpoint_position/global in a callback that transforms LLA to ENU local setpoints. We rather want to handle it in a callback that directly uses the LLA and publishes it as set_position_target_global_int.

@TSC21
Copy link
Member

TSC21 commented Sep 3, 2019

Also mavros_msgs/GlobalPositionTarget is used by the setpoint_raw plugin. On the setpoint_position plugin we want to use std ROS msgs, not mavros_msgs.

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.

sending global position in offboard mode
5 participants