ROSbot 2R: Enabling Camera in Gazebo Simulation

Hello, I am wondering if I can open the camera in the ROSbot 2R simulation environment in Gazebo. If I run:

$ ros2 launch rosbot_gazebo simulation.launch.py

There is no camera data if I try to see in the rqt

Hello @ertyu116,

Currently, there is no support for publishing camera data on the jazzy branch. You can use the humble branch, which is dedicated to ROSbot 2R. The jazzy branch is being developed primarily for ROSbot 3 and the camera simulation will most likely appear within a few weeks.

Regards

Is there any way I can publish the camera data from jazzy for rosbot2r? Should I make my own urdf and setup camera configuration,?

Hello @ertyu116,

You can add the following code to simulate camera in Gazebo:

    <gazebo reference="${reference_frame}">
      <sensor type="rgbd_camera" name="${sensor_name}">
        <always_on>true</always_on>
        <visualize>false</visualize>

        <topic>${topic}</topic>
        <update_rate>${frequency}</update_rate>

        <camera>
          <optical_frame_id>${frame_id}</optical_frame_id>
          <horizontal_fov>${fov}</horizontal_fov>
          <image>
            <width>${width}</width>
            <height>${height}</height>
          </image>
        </camera>

      </sensor>
    </gazebo>

Remember that gazebo topics are different from ROS fingers, so it is necessary to also add information to gz_ros_bridge, which will convert the gazebo news to ROS.

Regards

I am a new of the gazebo and xacro. Is it okay to put this code into the rosbot_macro.urdf.xacro file?

  <gazebo reference="camera_mount_link">
  <sensor type="rgbd_camera" name="oak_camera">
    <always_on>true</always_on>
    <visualize>false</visualize>

    <topic>camera/color/image_raw</topic>
    <update_rate>20</update_rate>

    <camera>
      <optical_frame_id>1</optical_frame_id>
      <horizontal_fov>1.089</horizontal_fov>
      <image>
        <width>640</width>
        <height>480</height>
      </image>
    </camera>

  </sensor>
</gazebo>

Hello @ertyu116,
This is how it will work, with the command: gz topic -l you can check the topics in Gazebo. To convert messages from gazebo to ROS you need to add a rule in the gz_ros_bridge configuration file.

I will add that the frame identifier is most likely wrong because there is no frame with this name in tf_tree.
Regards