ROS2 support state

Hi everybody!
I’m doing some work in ROS2 and Gazebo, and I wanted to use Ardupilot as main pilot of the copters I’ll be simulating.
I’m not sure I get the current status of the ROS2 support though. I only see old blog posts from 2021!
EDIT: oh, and these relevant docs, but they only talk about ROS(1)…
Is Ardupilot currently available for projects in ROS2 and Gazebo?
Thanks in advance!

yes, some support is there, but not on an officially released version.
You need to use the GitHub - ArduPilot/ardupilot: ArduPlane, ArduCopter, ArduRover, ArduSub source master branch to get it

Oh, okay! I didn’t get that at all!
So I can also expect not to find much documentation about that, right?

The documentation is the pull requests, and code.

oh, okay, thanks.
I’ll check that out!
just one more question, out of curiosity: do we know if the official release (code and related docs) is already planned?

Hello, I am the maintainer of DDS. We support ROS 2, please follow the README linked above.

This will be released in 4.5. For now, it’s just on master. Feel free to try it out and provide feedback.

For gazebo, take a look here: GitHub - ArduPilot/ardupilot_gz: Tools for ArduPilot ROS2 integration and testing

I’ll take a look at that too, thanks!

Pursuant to this topic of using ardupilot with ROS 2 and Gazebo (eg, Garden), I note the following is also provided:

https://github.com/ArduPilot/ardupilot_gazebo

https://ardupilot.org/dev/docs/sitl-with-gazebo.html

Also, looking at the first link, it appears there is a missing statement after “make -j4” :

sudo make install

I don’t have any idea how to pass this info along so here it is.

The reason for this export is to use the local version, rather than have user install this in their root directory. Sure, feel free to install it as sudo, it just means you have to know how to clean out the install later if things change.

I see. Also, regarding the link https://github.com/ArduPilot/ardupilot_gz cited above, does install step 4 conflict with this gazebo.sim note:

"#### ROS Users

When building Gazebo, we recommend you do not have your /opt/ros//setup.sh* file sourced, as it has been seen to add the wrong libraries to the Gazebo build."

I am still trying to sort out the way to build ROS2/Humble, Gazebo Garden and Arudpilot_Gazebo. I have gazebo garden working but it doesn’t mimic the SITL when I run it.

I tried following the instructions from that link and got the error "Command ‘vcs’ not found’ at

cd ~/ros2_ws/src
wget https://raw.githubusercontent.com/srmainwaring/ardupilot_gz/main/ros2_gz.repos
vcs import --recursive < ros2_gz.repos

I’m not sure it’s working…
I’ve followed the README but can’t get to use ROS2 CLI: it seems the connection via UDP (used since I have to run simulations) is not being established, and so ROS2 is not showing nodes

Did you try the serial method?
Did you set DDS_ENABLE=1 parameter and restart the simulator?
What do the logs show? DDS Client Initialization waiting, or something else?

Sorry to hear that. We can set something up a troubleshooting session. I’m out of town the next few days. Let’s try next Tuesday?

Try installing it?

I believe it comes with ros-dev-tools package, so feel free to install ros-dev-tools with apt first.

I’ve tried both, once more. It does seem “better”, in a way (as in “it logs more info”), but cannot see ros2 nodes or topics as mentioned in the README.
I should have done everything needed, DDS_ENABLE+restart included.
Since logs for both methods are a lot to read in a post, I’ll just add attachments.
serial_attempt.zip (4.5 KB)
udp_attempt.zip (3.7 KB)

It’s very kind of you to suggest a debug session! It’s not a problem for me to wait, in case I can’t resolve this in the meanwhile. Thanks!

Update: it seems I can now get DDS Client: Iniziatization waiting... when trying the Serial method, but can’t get further than that…

I’ve tried re-doing everything from scratch:

  • No improvements in the UDP method
  • In the Serial method I managed to get
AP: DDS Client: Initialization waiting...
AP: DDS Client: Init Complete
AP: XRCE Client: Topic/Pub/Writer session pass for index 'TOOO'
AP: DDS Client: Initialization passed

Still, I cannot see any ros2 nodes and I get the “deserialization error” in the micro_ros_agent terminal.
I’m still trying to get it to work, but any help is appreciated @rfriedman

1 Like

The fact it’s passing the initialization process is great! I think it’s best to set up a debug session in discord. I dm’d you for info.

Hello All I am having a similar problem like @slim71 and thought its better to write here instead of making a new thread - i am new to the ardupilot community i am more of a ROS developer
so first let me say thank you for the warm community and help.

I am having the same issue i did everything according to the instructions in AP_DDS README
https://github.com/ArduPilot/ardupilot/blob/a0f73d84eb706498ce1528cbdb0d4379828ce585/libraries/AP_DDS/README.md

I am desperately trying to set up the communication between my ardupilot drone and ROS2 humble

i am new to ardu but seems the issue is here with parameters maybe

INITIALISING> MANUAL> paramftp: bad count 1377 should be 1375
Received 1377 parameters (ftp)
Saved 1377 parameters to mav.parm

it looks like when i run SITL the DDS agent is crashing:

[1686478274.876855] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 4
[1686478282.482108] info     | Root.cpp           | create_client            | create                 | client_key: 0xAAAABBBB, session_id: 0x81
[1686478282.482191] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0xAAAABBBB, address: 0
terminate called after throwing an instance of 'std::bad_array_new_length'
  what():  std::bad_array_new_length

DDS_ENABLE was set to 1.0
any way i am attaching my logs maybe any of you guys had the same

ardupilot_ros2_logs.zip (2.6 KB)

if you have other suggestions or thread i should look let me know
Thanks in advance