Gazebo SITL with ROS2 not working

I am working on trying to get Ardupilot SITL to work with ROS2 in Gazebo by following the instructions on this page (ROS 2 with Gazebo — Dev documentation). However, I am running in issues of some rosdep packages could not be located. I got the following errors:

ros_gz_image: Cannot locate rosdep definition for [gz-transport12]
ros_gz_bridge: Cannot locate rosdep definition for [gz-transport12]
ardupilot_gz_gazebo: Cannot locate rosdep definition for [gz-sim7]
ros_gz_sim: Cannot locate rosdep definition for [gz-math7]
ardupilot_gazebo: Cannot locate rosdep definition for [gz-sim7]
sdformat_urdf: Cannot locate rosdep definition for [sdformat13]

I assume this contributes to my errors while trying to colcon build the ardupilot_gazebo package. Has anyone run into this error? Or does anyone has a suggestion on a possible solution?

Which OS and Gazebo versions do you have installed?

gz sim --version

or if you are using Fortress:

ign gazebo --version

ArduPilot requires ROS 2 Humble and Gazebo Garden or Harminic. You may have Fortress installed.

Thank you for the information.

I am using the following:
gz sim: Gazebo Garden v 7.6.0

with ROS 2 Humble on Ubuntu 22.04

These versions should be good for the build. I suspect the issue is that the officially supported Gazebo version for Ubuntu 22.04 is Fortress, and the rosdep definitions are not configured for Garden. If you add the -r flag (continue on error) to the rosdep command and then carry on with the build. Gazebo Garden can be installed manually with sudo apt install gz-garden.

Hello, I am still having the same error. Is it solved? @w-sribunma

hi is there any solution i am also facing same issue after installing it several time
abcom@abcom-HP-EliteBook-840-G3:~/ros2_ws$ source ~/ros2_ws/install/setup.bash

ros2 node list

ros2 node info /ardupilot_dds

ros2 topic echo /ap/geopose/filtered
Unable to find node ‘/ardupilot_dds’
WARNING: topic [/ap/geopose/filtered] does not appear to be published yet
Could not determine the type for the passed topic

discused on discord Discord

Seems like the resolution was the documented ROS_DOMAIN_ID thing?
https://ardupilot.org/dev/docs/ros2-sitl.html#ros-2-cli

domain id is same and tryed it changing also but still issues are same

rosdep install --from-paths src --ignore-src -r
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
sdformat_urdf: Cannot locate rosdep definition for [sdformat14]
ros_gz_bridge: Cannot locate rosdep definition for [gz-transport13]
ardupilot_gz_gazebo: Cannot locate rosdep definition for [gz-sim8]
ros_gz_sim: Cannot locate rosdep definition for [gz-transport13]
ros_gz_image: Cannot locate rosdep definition for [gz-transport13]
ardupilot_gazebo: Cannot locate rosdep definition for [gz-sim8]
Continuing to install resolvable dependencies…
#All required rosdeps installed successfully

i tried with -r but the issue didn’t resolve the previous steps in the documentation are running correctly

gz sim --version
Gazebo Sim, version 8.6.0
Copyright (C) 2018 Open Source Robotics Foundation.
Released under the Apache 2.0 License.

gazebo is also alright i installed both gazebo harmonic and classic but in bashrc i put line for Harmonic
export GZ_VERSION=harmonic

In the ros2 with Sitl doc.
everything is running
ros2 node list
/ardupilot_dds

ros2 topic list
/ap/battery/battery0
/ap/clock
/ap/cmd_gps_pose
/ap/cmd_vel
/ap/geopose/filtered
/ap/gps_global_origin/filtered
/ap/imu/experimental/data
/ap/joy
/ap/navsat/navsat0
/ap/pose/filtered
/ap/tf
/ap/tf_static
/ap/time
/ap/twist/filtered
/parameter_events
/rosout

but right now gazebo is distrubing can anyone try to solve this issue

This is advised against, as both use gz as a command and having both installed may cause conflicts. Gazebo Classic is EOL in Jan 2025 (Gazebo Classic End-of-Life - General - Gazebo Community). The ArduPilot Gazebo support is for Gazebo Garden and Harmonic (with the latter preferred).

i’ll try uninstalling all gazebo then install gazebo harmonic

I some how run the colcon build successfully but after launching the simulatuon the lines given on the documentation
cd ~/ardu_ws
colcon build --packages-up-to ardupilot_gz_bringup
source install/setup.bash
ros2 launch ardupilot_gz_bringup iris_runway.launch.py

after running this i am getting error like simulation is not running and giving

ros2 launch ardupilot_gz_bringup iris_runway.launch.py
[INFO] [launch]: All log files can be found below /home/usmannoor/.ros/log/2024-10-02-03-16-31-188115-usmannoor-HP-ZBook-15u-G5-50862
[INFO] [launch]: Default logging verbosity is set to INFO
namespace:
transport: udp4
middleware: dds
verbose: 4
discovery: 7400
port: 2019
command: arducopter
model: json
speedup: 1
slave: 0
sim_address: 127.0.0.1
instance: 0
defaults: /home/usmannoor/ardu_ws/install/ardupilot_gazebo/share/ardupilot_gazebo/config/gazebo-iris-gimbal.parm,/home/usmannoor/ardu_ws/install/ardupilot_sitl/share/ardupilot_sitl/config/default_params/dds_udp.parm
synthetic_clock: True
command: mavproxy.py
master: tcp:127.0.0.1:5760
sitl: 127.0.0.1:5501
out: 127.0.0.1:14550
console: False
map: False
[INFO] [ruby $(which gz) sim-1]: process started with pid [50863]
[INFO] [ruby $(which gz) sim-2]: process started with pid [50865]
[INFO] [micro_ros_agent-3]: process started with pid [50868]
[INFO] [dds_udp.parm --synthetic-clock -4]: process started with pid [50871]
[INFO] [mavproxy.py -5]: process started with pid [50875]
[INFO] [robot_state_publisher-6]: process started with pid [50879]
[INFO] [parameter_bridge-7]: process started with pid [50881]
[INFO] [rviz2-8]: process started with pid [50883]
[dds_udp.parm --synthetic-clock -4] Setting SIM_SPEEDUP=1.000000
[dds_udp.parm --synthetic-clock -4] Starting SITL: JSON
[dds_udp.parm --synthetic-clock -4] JSON control interface set to 127.0.0.1:9002
[dds_udp.parm --synthetic-clock -4] Starting sketch ‘ArduCopter’
[dds_udp.parm --synthetic-clock -4] Starting SITL input
[dds_udp.parm --synthetic-clock -4] Using Irlock at port : 9005
[dds_udp.parm --synthetic-clock -4] Waiting for connection …
[dds_udp.parm --synthetic-clock -4] bind port 5760 for SERIAL0
[dds_udp.parm --synthetic-clock -4] SERIAL0 on TCP port 5760
[INFO] [relay-9]: process started with pid [50891]
[micro_ros_agent-3] [1727820992.205032] info | UDPv4AgentLinux.cpp | init | running… | port: 2019
[micro_ros_agent-3] [1727820992.205304] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 4
[ruby $(which gz) sim-2] ruby: No such file or directory – sim (LoadError)
[ruby $(which gz) sim-1] ruby: No such file or directory – sim (LoadError)
[ERROR] [ruby $(which gz) sim-1]: process has died [pid 50863, exit code 1, cmd ‘ruby $(which gz) sim -v4 -s -r /home/usmannoor/ardu_ws/install/ardupilot_gz_gazebo/share/ardupilot_gz_gazebo/worlds/iris_runway.sdf --force-version 8’].
[INFO] [launch]: process[ruby $(which gz) sim-1] was required: shutting down launched system
[INFO] [relay-9]: sending signal ‘SIGINT’ to process[relay-9]
[INFO] [rviz2-8]: sending signal ‘SIGINT’ to process[rviz2-8]
[ERROR] [ruby $(which gz) sim-2]: process has died [pid 50865, exit code 1, cmd ‘ruby $(which gz) sim -v4 -g --force-version 8’].
[INFO] [parameter_bridge-7]: sending signal ‘SIGINT’ to process[parameter_bridge-7]
[INFO] [robot_state_publisher-6]: sending signal ‘SIGINT’ to process[robot_state_publisher-6]
[ERROR] [rviz2-8]: process has died [pid 50883, exit code -2, cmd ‘/opt/ros/humble/lib/rviz2/rviz2 -d /home/usmannoor/ardu_ws/install/ardupilot_gz_bringup/share/ardupilot_gz_bringup/rviz/iris.rviz --ros-args’].
[INFO] [mavproxy.py -5]: sending signal ‘SIGINT’ to process[mavproxy.py -5]
[INFO] [dds_udp.parm --synthetic-clock -4]: sending signal ‘SIGINT’ to process[dds_udp.parm --synthetic-clock -4]
[INFO] [micro_ros_agent-3]: sending signal ‘SIGINT’ to process[micro_ros_agent-3]
[ERROR] [parameter_bridge-7]: process has died [pid 50881, exit code -2, cmd ‘/home/usmannoor/ardu_ws/install/ros_gz_bridge/lib/ros_gz_bridge/parameter_bridge --ros-args --params-file /tmp/launch_params_x11sm49t’].
[relay-9] [INFO] [1727820992.224248843] [rclcpp]: signal_handler(signum=2)
[INFO] [launch]: process[ruby $(which gz) sim-2] was required: shutting down launched system
[ERROR] [micro_ros_agent-3]: process has died [pid 50868, exit code -2, cmd ‘/home/usmannoor/ardu_ws/install/micro_ros_agent/lib/micro_ros_agent/micro_ros_agent udp4 --middleware dds --verbose 4 --port 2019 --ros-args -r __node:=micro_ros_agent -r __ns:=/’].
[robot_state_publisher-6] [INFO] [1727820992.229499194] [rclcpp]: signal_handler(signum=2)
[robot_state_publisher-6] terminate called after throwing an instance of ‘rclcpp::exceptions::RCLError’
[robot_state_publisher-6] what(): could not create subscription: rcl node’s context is invalid, at ./src/rcl/node.c:428
[dds_udp.parm --synthetic-clock -4] Connection on serial port 5760
[dds_udp.parm --synthetic-clock -4] Loaded defaults from /home/usmannoor/ardu_ws/install/ardupilot_gazebo/share/ardupilot_gazebo/config/gazebo-iris-gimbal.parm,/home/usmannoor/ardu_ws/install/ardupilot_sitl/share/ardupilot_sitl/config/default_params/dds_udp.parm
[dds_udp.parm --synthetic-clock -4] bind port 5762 for SERIAL1
[dds_udp.parm --synthetic-clock -4] SERIAL1 on TCP port 5762
[dds_udp.parm --synthetic-clock -4] bind port 5763 for SERIAL2
[dds_udp.parm --synthetic-clock -4] SERIAL2 on TCP port 5763
[dds_udp.parm --synthetic-clock -4] Home: -35.363262 149.165237 alt=584.000000m hdg=353.000000
[ERROR] [robot_state_publisher-6]: process has died [pid 50879, exit code -6, cmd ‘/opt/ros/humble/lib/robot_state_publisher/robot_state_publisher --ros-args -r __node:=robot_state_publisher --params-file /tmp/launch_params_lu_h1pla --params-file /tmp/launch_params_xfjk1o34’].
[dds_udp.parm --synthetic-clock -4] No JSON sensor message received, resending servos
[relay-9] terminate called after throwing an instance of ‘rclcpp::exceptions::RCLError’
[relay-9] what(): failed to initialize rcl node: the given context is not valid, either rcl_init() was not called or rcl_shutdown() was called., at ./src/rcl/guard_condition.c:67
[dds_udp.parm --synthetic-clock -4] No JSON sensor message received, resending servos
[ERROR] [relay-9]: process has died [pid 50891, exit code -6, cmd ‘/opt/ros/humble/lib/topic_tools/relay /gz/tf /tf --ros-args’].
[mavproxy.py -5] Connect tcp:127.0.0.1:5760 source_system=255
[mavproxy.py -5] Log Directory:
[mavproxy.py -5] Telemetry log: mav.tlog
[mavproxy.py -5] Waiting for heartbeat from tcp:127.0.0.1:5760
[mavproxy.py -5] link 1 down
[dds_udp.parm --synthetic-clock -4] No JSON sensor message received, resending servos
[dds_udp.parm --synthetic-clock -4] No JSON sensor message received, resending servos
[ERROR] [mavproxy.py -5]: process[mavproxy.py -5] failed to terminate ‘5’ seconds after receiving ‘SIGINT’, escalating to ‘SIGTERM’
[ERROR] [dds_udp.parm --synthetic-clock -4]: process[dds_udp.parm --synthetic-clock -4] failed to terminate ‘5’ seconds after receiving ‘SIGINT’, escalating to ‘SIGTERM’
[INFO] [mavproxy.py -5]: sending signal ‘SIGTERM’ to process[mavproxy.py -5]
[INFO] [dds_udp.parm --synthetic-clock -4]: sending signal ‘SIGTERM’ to process[dds_udp.parm --synthetic-clock -4]
[ERROR] [mavproxy.py -5]: process has died [pid 50875, exit code -15, cmd '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 --non-interactive '].
[ERROR] [dds_udp.parm --synthetic-clock -4]: process has died [pid 50871, exit code -15, cmd 'arducopter --model json --speedup 1 --slave 0 --sim-address=127.0.0.1 --instance 0 --defaults /home/usmannoor/ardu_ws/install/ardupilot_gazebo/share/ardupilot_gazebo/config/gazebo-iris-gimbal.parm,/home/usmannoor/ardu_ws/install/ardupilot_sitl/share/ardupilot_sitl/config/default_params/dds_udp.parm --synthetic-clock '].

=> gz sim is not being found when you run the launch.

I reinstall the gazebo harmonic to make it work corectly
now after getting through all the configuration steps
after lauching the ros2 iris.launch.py
i am getting this only in the terminal gazebo and sitl is not launching
[dds_udp.parm --synthetic-clock -2] No JSON sensor message received, resending servos

Are the DDS / SITL examples that do not rely on Gazebo working?

It’s difficult to trace what might be going wrong on your system. As there are many dependencies when using ArduPilot with ROS, the only way to track down a problem is to systematically work through all the simpler examples. Running the various processes using individual launch files in separate terminals is the best way to isolate which dependency is not working.

1 Like