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

Enabled sending waypoints to ardupilot for copter and rover #26362

Merged
merged 3 commits into from
May 2, 2024

Conversation

haarshitgarg
Copy link
Contributor

@haarshitgarg haarshitgarg commented Feb 29, 2024

Way point support for Copter

This is to fix the issue #25381

Implemented set_global_location for Rover and Copter ( taking inspiration from ArduPlane)

Demo

Taking everything from this pull request

In ArduPilot repo:

./sim_vehicle.py -v ArduCopter --map --console --enable-dds

Running MicroROS agent:

cd ~/ros2_ws
. /opt/ros/humble/setup.bash
colcon build --packages-up-to ardupilot_sitl
. install/setup.bash
cd src/ardupilot/libraries/AP_DDS
ros2 run micro_ros_agent micro_ros_agent udp4 -p 2019 -r dds_xrce_profile.xml

Taking off the copter

mode guided
arm throttle
takeoff 50

Now publish a message for drone to go to greyhound track.

cd ~/ros2_ws
. /opt/ros/humble/setup.bash
colcon build --packages-up-to ardupilot_msgs
. install/setup.bash
ros2 topic pub /ap/cmd_gps_pose  ardupilot_msgs/msg/GlobalPosition "{header: {frame_id: map}, latitude: -35.345996, longitude: 149.159017, altitude: 40, coordinate_frame: 6}" --once
Screenshot 2024-03-03 at 7 32 13 PM Screenshot 2024-03-03 at 7 35 34 PM

Way point support for copter Rover

Follow all the steps as for copter above

Demo Rover

Same as copter (plus altitude is ignored in ros message)
Result Screenshot (Rover going to the same location as copter)
Screenshot 2024-03-03 at 8 05 29 PM

@amilcarlucas
Copy link
Contributor

Can most of this be moved to AP_Vehicle instead?

@haarshitgarg
Copy link
Contributor Author

Can most of this be moved to AP_Vehicle instead?

Hello @amilcarlucas I am not really sure about that. I am just following the structure already being followed for ArduPlane.

@haarshitgarg haarshitgarg marked this pull request as draft March 3, 2024 15:24
@haarshitgarg haarshitgarg marked this pull request as ready for review March 3, 2024 16:36
@Ryanf55 Ryanf55 self-requested a review March 3, 2024 19:57
@Ryanf55
Copy link
Collaborator

Ryanf55 commented Mar 3, 2024

Can most of this be moved to AP_Vehicle instead?

Which parts do you think should be moved? Collapse AP_ExternalControl in AP_Vehicle, or something else?

@Ryanf55 Ryanf55 added the ROS label Mar 3, 2024
@amilcarlucas
Copy link
Contributor

Anything that is common and can be reuse is a good candidate.

That way sub and blimp will also get (at least parts) of this feature.

Copy link
Collaborator

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

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

Overall, this is looking great. Sorry for the delay on the review. I forgot to hit submit.
I'll run testing on it shortly. Have you tried using the python script I wrote to send a goal, and try it against copter?

ArduCopter/Copter.cpp Show resolved Hide resolved
@rmackay9
Copy link
Contributor

rmackay9 commented Mar 14, 2024

This is looking pretty good I think, it would be good to squash some of the commits together and add the regular subsystem prefixes to them. E.g. commits affecting rover should start with "Rover: ", commits affecting Copter should start with "Copter: ". Also we should have any merge commits. Thanks!

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Apr 16, 2024

This is looking pretty good I think, it would be good to squash some of the commits together and add the regular subsystem prefixes to them. E.g. commits affecting rover should start with "Rover: ", commits affecting Copter should start with "Copter: ". Also we should have any merge commits. Thanks!

Hi @haarshitgarg , Do you mind fixing up the commits? This is looking nice and I'd like to get this in. We had another asking for copter waypoints on the discord thread.

@maximecapelle
Copy link

Is there a way to takeoff throught the ros2 topics aswell? I have used the additions you suggested and the waypoint navigation works when it is in the air but not to takeoff. It would be nice if we can set the drone to mode guided, arm and takeoff all through the ros2 topics! :)

@rmackay9
Copy link
Contributor

@maximecapelle,

I'm not really familiar with this area but maybe this PR is what you're looking for? #26911

@maximecapelle
Copy link

@maximecapelle,

I'm not really familiar with this area but maybe this PR is what you're looking for? #26911

Thank you! I’ll check it out :)

@maximecapelle
Copy link

Also, is there a way to use waypoints in the local coordinate frame? (x, y, z) Using the "/ap/pose/filtered" topic msgs you have your position in the local map coordinates. Could someone help me implement that? Sorry I have little knowledge on Ardupilot source code haha.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented May 1, 2024

Also, is there a way to use waypoints in the local coordinate frame? (x, y, z) Using the "/ap/pose/filtered" topic msgs you have your position in the local map coordinates. Could someone help me implement that? Sorry I have little knowledge on Ardupilot source code haha.

No, that's not part of REP-147. ArduPilot's waypoints are in WGS-84 (global) coordinates. If you want to do planning on local coordinates that's fine, but transform to global before sending to the autopilot.

@Ryanf55 Ryanf55 self-assigned this May 1, 2024
@Ryanf55 Ryanf55 self-requested a review May 1, 2024 17:56
@Ryanf55 Ryanf55 added this to the DDS 4.6 milestone May 1, 2024
Copy link
Collaborator

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

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

Aside from the style changes, the functionality is spot-on. Well done!

I just force pushed the style fixes, enforced it in run_astyle.py and finally fixed the commit messages.

image

…dupilot for copter and rover

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
…ot for copter and rover

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
…ot for copter and rover

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
@Ryanf55
Copy link
Collaborator

Ryanf55 commented May 1, 2024

@haarshitgarg Would you be interested in a doing a follow-up PR allowing users to set a yaw angle at the waypoint? This would be good for inspection use cases with a fixed camera where you point the drone at a cliff/wall at each waypoint.

Copy link
Contributor

@rmackay9 rmackay9 left a comment

Choose a reason for hiding this comment

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

Sorry to be nitpicky about naming but could we change this to clarify that we're setting a target location? we normally use the word "position" to indicate an offset from the EKF origin and "location" for lat, lon, alt. Not specifying that this is a target (e.g. controller target) rather than an [ekf] estimate is important as well I think.

@rmackay9 rmackay9 merged commit 4c95a3b into ArduPilot:master May 2, 2024
76 checks passed
@Ryanf55
Copy link
Collaborator

Ryanf55 commented May 2, 2024

Sorry to be nitpicky about naming but could we change this to clarify that we're setting a target location? we normally use the word "position" to indicate an offset from the EKF origin and "location" for lat, lon, alt. Not specifying that this is a target (e.g. controller target) rather than an [ekf] estimate is important as well I think.

Do you want the functions renamed in Plane and Copter, or just External control?

@rmackay9
Copy link
Contributor

rmackay9 commented May 2, 2024

Hi @Ryanf55,

I think set_global_position() should be renamed to set_target_location(). That will lead to identically named methods in the Copter and Rover vehicle class and in AP_ExternalControl but I think that's OK... maybe other devs will disagree but we can clear that up on the dev call if not before.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented May 2, 2024

Ok. It's currently named based on REP-147: https://ros.org/reps/rep-0147.html#goal-interface

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants