GZ SIM: multiple x500 depth cameras bridged to ROS2

Hi!

I recently found the gz model for x500 with a depth camera, and would like to transfer the images from gz to ROS2. For this, I found that the image_bridge from ros_gz_image is suitable (GitHub - gazebosim/ros_gz: Integration between ROS (1 and 2) and Gazebo simulation). I have no problem using this package after installing the correct version (apt install ros-humble-ros-gzgarden) for one instance. My issue is that I want to use several instances of x500_depth - it seems like all of them publishes camera data on the same topics in gz, namely /camera and /depth_camera. Does anyone know if it is possible to change this in order to incorporate the model name as a namespace parameter in the topics? (/x500_depth_0/camera, /x500_depth_1/camera)

Regards,
Kristoffer

Hi @Kristoffer_Bergman , the depth_camera sensor used in x500_depth does not implements subtopics (which would allow to nest the topic under the model namespace). You can set the topic name, see the sdf file of the camera: https://app.gazebosim.org/RudisLaboratories/fuel/models/OakD-Lite :

<sensor name="StereoOV7251" type="depth_camera">
        <pose>0.01233 -0.03 .01878 0 0 0</pose>
        <camera>
          <horizontal_fov>1.274</horizontal_fov>
          <image>
            <width>640</width>
            <height>480</height>
            <format>R_FLOAT32</format>
          </image>
          <clip>
            <near>0.2</near>
            <far>19.1</far>
          </clip>
        </camera>
        <always_on>1</always_on>
        <update_rate>30</update_rate>
        <visualize>true</visualize>
        <topic>depth_camera</topic>
      </sensor>

but as you say, depth_camera is hardcoded.

Thanks @Benja for your quick reply!

Do you know if sensors in gz support subtopics? If not, do you have any other idea of how to change the sdf file in order to support several camera sensors that does not publish on the same topic?

I checked and my understanding is that that sensor does not support subtopics, you would need to implement that feature.

The workaround would be to dynamically edit the sdf file before using it, and change the topic element. But, the camera model is fetched from fuel, therefore you first need to fetch the camera model from fuel and implement it in x500_depth

Hi, Sorry to bump this old conversation but I would like to share the solution that worked for me, in my case I added the Gazebo plugin like this:

        <plugin name="camera_controller" filename="libgazebo_ros_camera.so">
          <alwaysOn>true</alwaysOn>
          <updateRate>0.0</updateRate>
          <cameraName>my_namespace/camera</cameraName>
          <imageTopicName>image_raw</imageTopicName>
          <cameraInfoTopicName>camera_info</cameraInfoTopicName>
          <frameName>mono_cam/base_link</frameName>
          <namespace>my_namespace</namespace>
        </plugin>

Like this I am able to see both images.
Camera of drone 1:


Camera of drone 2 (Drone 2 is on the ground):

The only problem I encountered is that the topic is quite lengthy, but I think this would be a non-issue due to launch files. I just thought of this solution, I will update if I think of a more refined approach.

1 Like

hi sorry but may i know where did you put that plugin, and also when I run that have an error in the px4 saying pxh> [Err] [SystemLoader.cc:92] Failed to load system plugin [libgazebo_ros_camera.so] : Could not find shared library.