Configuring ArduPilot for ROS2 foxy

I am setting Ardupilot in ROS2 foxy following ROS 2 — Dev documentation which is for humble.

wget https://raw.githubusercontent.com/ArduPilot/ardupilot/master/Tools/ros2/ros2.repos 
vcs import --recursive < ros2.repos

and

sudo apt update rosdep update

It just skipped foxy and I cannot go on
Screenshot from 2023-11-11 17-27-59

Ardupilot requires Humble. Just update.

Thanks for your reply.

But I found one guy succeeded in using ros2 foxy and ArduCopter at Precision landing ROS2 Foxy + Apriltags

That was probably a while ago, with an older version. You are using ArduPilot master, and ArduPilot master requires Humble.

Yes, I found the branches Copter 4.3 and 4.4 do not have the folder Tools/ros2. Does that mean these two versions do not support ros2?

Yes, those two versions do not support ROS2.

You need to use a 4.5.0-DEV version (master branch) for ros2 support.

For Foxy you will need to find a particular commit on the master branch where it works, or you update to humble.

Thank @amilcarlucas .

I just found mavros2 for ros2 foxy. Now I am trying to enable communication between mavros2 and ArduCopter 4.3.

But it is very strange to me that mavros2 cannot find my ArduCopter. Could you please help me find the reason?

Here is what I did:

  1. start ArduCopter and get
SIM_VEHICLE: Start
SIM_VEHICLE: Killing tasks
SIM_VEHICLE: Starting up at SITL location
SIM_VEHICLE: WAF build
SIM_VEHICLE: Configure waf
SIM_VEHICLE: "/home/robot/RobotFirmware/ardupilot/modules/waf/waf-light" "configure" "--board" "sitl"
Setting top to                           : /home/robot/RobotFirmware/ardupilot 
Setting out to                           : /home/robot/RobotFirmware/ardupilot/build 
Autoconfiguration                        : enabled 
Setting board to                         : sitl 
Using toolchain                          : native 
Checking for 'g++' (C++ compiler)        : /usr/lib/ccache/g++ 
Checking for 'gcc' (C compiler)          : /usr/lib/ccache/gcc 
Checking for c flags '-MMD'              : yes 
Checking for cxx flags '-MMD'            : yes 
CXX Compiler                             : g++ 9.4.0 
Checking for need to link with librt     : not necessary 
Checking for feenableexcept              : yes 
Enabled OpenDroneID                      : no 
Enabled firmware ID checking             : no 
GPS Debug Logging                        : no 
Enabled custom controller                : yes 
Checking for HAVE_CMATH_ISFINITE         : yes 
Checking for HAVE_CMATH_ISINF            : yes 
Checking for HAVE_CMATH_ISNAN            : yes 
Checking for NEED_CMATH_ISFINITE_STD_NAMESPACE : yes 
Checking for NEED_CMATH_ISINF_STD_NAMESPACE    : yes 
Checking for NEED_CMATH_ISNAN_STD_NAMESPACE    : yes 
Checking for header endian.h                   : yes 
Checking for header byteswap.h                 : yes 
Checking for HAVE_MEMRCHR                      : yes 
Configured VSCode Intellisense:                : no 
Checking for program 'python'                  : /usr/bin/python 
Checking for python version >= 2.7.0           : 3.8.10 
Checking for program 'python'                  : /usr/bin/python 
Checking for python version >= 2.7.0           : 3.8.10 
Source is git repository                       : yes 
Update submodules                              : yes 
Checking for program 'git'                     : /usr/bin/git 
Checking for program 'size'                    : /usr/bin/size 
Benchmarks                                     : disabled 
Unit tests                                     : enabled 
Scripting                                      : enabled 
Scripting runtime checks                       : enabled 
Debug build                                    : disabled 
Coverage build                                 : disabled 
SITL 32-bit build                              : disabled 
Checking for program 'rsync'                   : /usr/bin/rsync 
'configure' finished successfully (0.612s)
{'waf_target': 'bin/arducopter', 'default_params_filename': ['default_params/copter.parm', 'default_params/gazebo-iris.parm'], 'external': True, 'model': 'JSON', 'sitl-port': True}
SIM_VEHICLE: Building
SIM_VEHICLE: "/home/robot/RobotFirmware/ardupilot/modules/waf/waf-light" "build" "--target" "bin/arducopter"
Waf: Entering directory `/home/robot/RobotFirmware/ardupilot/build/sitl'
Embedding file locations.txt:Tools/autotest/locations.txt
Embedding file models/Callisto.json:Tools/autotest/models/Callisto.json
Waf: Leaving directory `/home/robot/RobotFirmware/ardupilot/build/sitl'

BUILD SUMMARY
Build directory: /home/robot/RobotFirmware/ardupilot/build/sitl
Target          Text (B)  Data (B)  BSS (B)  Total Flash Used (B)  Free Flash (B)
---------------------------------------------------------------------------------
bin/arducopter   3853743    180909   203976               4034652  Not Applicable

Build commands will be stored in build/sitl/compile_commands.json
'build' finished successfully (1.721s)
SIM_VEHICLE: Using defaults from (../Tools/autotest/default_params/copter.parm,../Tools/autotest/default_params/gazebo-iris.parm)
SIM_VEHICLE: Run ArduCopter
SIM_VEHICLE: "/home/robot/RobotFirmware/ardupilot/Tools/autotest/run_in_terminal_window.sh" "ArduCopter" "/home/robot/RobotFirmware/ardupilot/build/sitl/bin/arducopter" "-S" "--model" "JSON" "--speedup" "1" "--slave" "0" "--defaults" "../Tools/autotest/default_params/copter.parm,../Tools/autotest/default_params/gazebo-iris.parm" "-I0"
SIM_VEHICLE: Run MavProxy
SIM_VEHICLE: "mavproxy.py" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--map" "--console"
RiTW: Starting ArduCopter : /home/robot/RobotFirmware/ardupilot/build/sitl/bin/arducopter -S --model JSON --speedup 1 --slave 0 --defaults ../Tools/autotest/default_params/copter.parm,../Tools/autotest/default_params/gazebo-iris.parm -I0
Connect tcp:127.0.0.1:5760 source_system=255
Loaded module console
Loaded module map
Log Directory: 
Telemetry log: mav.tlog
Waiting for heartbeat from tcp:127.0.0.1:5760
  1. run mavros2 by ros2 run mavros mavros_node --ros-args --param fcu_url:=udp://@127.0.0.1:14550 and get the error
[INFO] [1699719183.551447817] [mavros_node]: Starting mavros_node container
[INFO] [1699719183.551523312] [mavros_node]: FCU URL: udp://@127.0.0.1:14550
[INFO] [1699719183.551532483] [mavros_node]: GCS URL: 
[INFO] [1699719183.551538291] [mavros_node]: UAS Prefix: /uas1
[INFO] [1699719183.551543470] [mavros_node]: Starting mavros router node
[INFO] [1699719183.553953585] [mavros_router]: Built-in SIMD instructions: SSE, SSE2
[INFO] [1699719183.553974381] [mavros_router]: Built-in MAVLink package version: 2022.12.30
[INFO] [1699719183.553984487] [mavros_router]: Known MAVLink dialects: common ardupilotmega ASLUAV AVSSUAS all cubepilot development icarous matrixpilot paparazzi standard storm32 uAvionix ualberta
[INFO] [1699719183.553994535] [mavros_router]: MAVROS Router started
[INFO] [1699719183.554020950] [mavros_router]: Requested to add endpoint: type: 0, url: udp://@127.0.0.1:14550
[INFO] [1699719183.554063142] [mavros_router]: Endpoint link[1000] created
[INFO] [1699719183.554383758] [mavros_router]: link[1000] opened successfully
[INFO] [1699719183.554413058] [mavros_router]: Requested to add endpoint: type: 2, url: /uas1
[INFO] [1699719183.554428194] [mavros_router]: Endpoint link[1001] created
[INFO] [1699719183.554732801] [mavros_router]: link[1001] opened successfully
[INFO] [1699719183.554753120] [mavros_node]: Starting mavros uas node
[INFO] [1699719183.582262291] [mavros]: UAS Executor started, threads: 12
[INFO] [1699719183.593292206] [mavros]: Plugin actuator_control created
[INFO] [1699719183.593354812] [mavros]: Plugin actuator_control initialized
[INFO] [1699719183.595266886] [mavros]: Plugin altitude created
[INFO] [1699719183.595295746] [mavros]: Plugin altitude initialized
[INFO] [1699719183.598761136] [mavros]: Plugin command created
[INFO] [1699719183.598795290] [mavros]: Plugin command initialized
[INFO] [1699719183.603091073] [mavros]: Plugin ftp created
[INFO] [1699719183.603118255] [mavros]: Plugin ftp initialized
[INFO] [1699719183.605986155] [mavros]: Plugin geofence created
[INFO] [1699719183.606033628] [mavros]: Plugin geofence initialized
[INFO] [1699719183.610299371] [mavros]: Plugin global_position created
[INFO] [1699719183.610350859] [mavros]: Plugin global_position initialized
[INFO] [1699719183.613457916] [mavros]: Plugin home_position created
[INFO] [1699719183.613502547] [mavros]: Plugin home_position initialized
[INFO] [1699719183.616805761] [mavros]: Plugin imu created
[INFO] [1699719183.616840690] [mavros]: Plugin imu initialized
[INFO] [1699719183.620645323] [mavros]: Plugin local_position created
[INFO] [1699719183.620678742] [mavros]: Plugin local_position initialized
[INFO] [1699719183.623489048] [mavros]: Plugin manual_control created
[INFO] [1699719183.623515516] [mavros]: Plugin manual_control initialized
[INFO] [1699719183.626270401] [mavros]: Plugin nav_controller_output created
[INFO] [1699719183.626300642] [mavros]: Plugin nav_controller_output initialized
[INFO] [1699719183.629775223] [mavros]: Plugin param created
[INFO] [1699719183.629804005] [mavros]: Plugin param initialized
[INFO] [1699719183.633347685] [mavros]: Plugin rallypoint created
[INFO] [1699719183.633390631] [mavros]: Plugin rallypoint initialized
[INFO] [1699719183.636741072] [mavros]: Plugin rc_io created
[INFO] [1699719183.636775631] [mavros]: Plugin rc_io initialized
[INFO] [1699719183.639955607] [mavros]: Plugin setpoint_accel created
[INFO] [1699719183.639981308] [mavros]: Plugin setpoint_accel initialized
[INFO] [1699719183.644067724] [mavros]: Plugin setpoint_attitude created
[INFO] [1699719183.644110525] [mavros]: Plugin setpoint_attitude initialized
[INFO] [1699719183.648467075] [mavros]: Plugin setpoint_position created
[INFO] [1699719183.648494958] [mavros]: Plugin setpoint_position initialized
[INFO] [1699719183.652805077] [mavros]: Plugin setpoint_raw created
[INFO] [1699719183.652842134] [mavros]: Plugin setpoint_raw initialized
[INFO] [1699719183.657018041] [mavros]: Plugin setpoint_trajectory created
[INFO] [1699719183.657046153] [mavros]: Plugin setpoint_trajectory initialized
[INFO] [1699719183.660817449] [mavros]: Plugin setpoint_velocity created
[INFO] [1699719183.660866353] [mavros]: Plugin setpoint_velocity initialized
[INFO] [1699719183.667261739] [mavros]: Plugin sys_status created
[INFO] [1699719183.667314227] [mavros]: Plugin sys_status initialized
[INFO] [1699719183.670955879] [mavros.time]: TM: Timesync mode: MAVLINK
[INFO] [1699719183.672291210] [mavros]: Plugin sys_time created
[INFO] [1699719183.672336457] [mavros]: Plugin sys_time initialized
[INFO] [1699719183.678952309] [mavros]: Plugin waypoint created
[INFO] [1699719183.679009525] [mavros]: Plugin waypoint initialized
[INFO] [1699719183.682895035] [mavros]: Plugin wind_estimation created
[INFO] [1699719183.682923160] [mavros]: Plugin wind_estimation initialized
[INFO] [1699719183.683462651] [mavros]: Built-in SIMD instructions: SSE, SSE2
[INFO] [1699719183.683476914] [mavros]: Built-in MAVLink package version: 2022.12.30
[INFO] [1699719183.683483627] [mavros]: Known MAVLink dialects: common ardupilotmega ASLUAV AVSSUAS all cubepilot development icarous matrixpilot paparazzi standard storm32 uAvionix ualberta
[INFO] [1699719183.683490260] [mavros]: MAVROS UAS via /uas1 started. MY ID 1.191, TARGET ID 1.1
[INFO] [1699719184.665421488] [mavros_router]: link[1001] detected remote address 1.191
[WARN] [1699719185.669057549] [mavros.sys]: VER: broadcast request timeout, retries left 4
[WARN] [1699719186.668983733] [mavros.sys]: VER: broadcast request timeout, retries left 3
[WARN] [1699719187.668863295] [mavros.sys]: VER: unicast request timeout, retries left 2
^C[INFO] [1699719188.026245582] [rclcpp]: signal_handler(signal_value=2)
[WARN] [1699719188.028211844] [mavros]: UAS Executor terminated

For anyone following - the wiki is updated to be clearer. The tutorial you linked is for using the DDS interface of ArduPilot, which only is tested on ROS 2 humble (it’s all we can support right now with the dev team size). Messages were changed since humble like GeoPoseStampedWithCovariance, so it definitely won’t work in foxy or galactic.

What command did you start Ardupilot with? Seems like it’s not actually running.

Hi @rfriedman , thanks so much for your wiki updates and reply.

I start ArduCopter as the following

cd ardupilot/ArduCopter
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --map --console

But from the output Configuring ArduPilot for ROS2 foxy - #7 by RobinD, I cannot see any problem.

I believe it is a mavros2 problem.

After starting ArduCopter, I can see drone information using QGroundControl.

1 Like

Is there anyone having this issue and finding a solution?