ros2 gazebo camera not publishing data

asked 2021-02-12 16:20:19 -0500

simonsure gravatar image

updated 2022-07-13 09:58:50 -0500

lucasw gravatar image

Currently, I have ROS2 Foxy-Fitzroy installed on Ubuntu 20.04. With a launch file I'm starting gazebo and loading a world. A python file then calls the service /spawn_entity to place an robot into the world. The robot is given as an urdf file. The robot is correctly displayed in GAZEBO and rqt shows that some node is registered to publish data on the topic /custom_ns/camera1/image_raw. Now, I could make the following observation:

  • The terminal, in which Gazebo has been started, is showing the following warnings. Those explain, why the nodes are not registered on the topics /custom and /custom_info. Still, there should be data published.

This is the code from the urdf:

  <gazebo reference="camera_link">
    <sensor type="camera" name="camera1">
      <update_rate>1</update_rate>
      <camera name="head">
        <horizontal_fov>1.2</horizontal_fov>
        <image>
          <width>420</width>
          <height>240</height>
          <format>R8G8B8</format>
        </image>
        <clip>
          <near>0.02</near>
          <far>300</far>
        </clip>
        <distortion>
          <k1>0.0</k1>
          <k2>0.0</k2>
          <k3>0.0</k3>
          <p1>0.0</p1>
          <p2>0.0</p2>
        </distortion>
      </camera>
      <plugin name="camera_controller" filename="libgazebo_ros_camera.so">
        <ros>
          <namespace>custom_ns</namespace>
          <argument>image_raw:=custom</argument>
          <argument>camera_info:=custom_info</argument>
        </ros>
        <camera_name>camera1</camera_name>
        <frame_name>camera_link</frame_name>
        <hack_baseline>0.07</hack_baseline>
      </plugin>
    </sensor>
  </gazebo>

I migrated this from ROS1 according to the following guide: https://github.com/ros-simulation/gazebo_ros_pkgs/wiki/ROS-2-Migration:-Camera It still recommends using the upper notation for passing custom topics despite the warning in the terminal.

I would appreciate any help as there is no solution in sight after several days of work!

edit retag flag offensive close merge delete

Comments

1

So, after some digging I found the reason. The plugin worked fine but the problem were the QoS settings within in RViz, which did not align by default. Just settings those to best efford solved the issue immediately.

simonsure gravatar image simonsure  ( 2021-02-20 03:05:58 -0500 )edit

Thanks for the hint! I also can't display the pointcloud, but changing the setting didn't work. I don't receive any message on the camera topic (even though it is published). Is it normal that both image and point cloud are coming on the same topic?

francesco gravatar image francesco  ( 2021-05-09 07:09:00 -0500 )edit