Skip to content

Camera

Bridge rgb camera between gazebo to ros

Gazebo

sdf specification

Add sensor plugin to world

add sensor plugin to world
1
2
3
4
5
<plugin
  filename="gz-sim-sensors-system"
  name="gz::sim::systems::Sensors">
  <render_engine>ogre2</render_engine>
</plugin>
RGB Camera
  <gazebo reference="camera_link">
    <sensor name="camera" type="camera">
      <camera>
        <horizontal_fov>1.3962634</horizontal_fov>
        <image>
          <width>640</width>
          <height>480</height>
          <format>R8G8B8</format>
        </image>
        <clip>
          <near>0.1</near>
          <far>15</far>
        </clip>
        <noise>
          <type>gaussian</type>
          <!-- Noise is sampled independently per pixel on each frame.
               That pixel's noise value is added to each of its color
               channels, which at that point lie in the range [0,1]. -->
          <mean>0.0</mean>
          <stddev>0.007</stddev>
        </noise>
        <optical_frame_id>camera_link_optical</optical_frame_id>
        <camera_info_topic>camera/camera_info</camera_info_topic>
      </camera>
      <always_on>1</always_on>
      <update_rate>20</update_rate>
      <visualize>true</visualize>
      <topic>camera/image</topic>
    </sensor>
  </gazebo>

ROS2

check ros gz sim demo

Bridge

  • image_raw
  • image_info
gz_bridge.yaml
- ros_topic_name: "/camera/image_raw"
  gz_topic_name: "/camera/image_raw"
  ros_type_name: "sensor_msgs/msg/Image"
  gz_type_name: "gz.msgs.Image"
  direction: GZ_TO_ROS
# camera info
- ros_topic_name: "/camera/image_info"
  gz_topic_name: "/camera/image_info"
  ros_type_name: "sensor_msgs/msg/CameraInfo"
  gz_type_name: "gz.msgs.CameraInfo"
  direction: GZ_TO_ROS

Image Transport

automatically compress the video stream in the background

```yaml title=launch launch: - arg: name: use_sim_time default: "true" description: Use simulation (Gazebo) clock if true - node: pkg: "ros_gz_image" exec: "image_bridge" output: screen args: "/camera/image" param: - name: use_sim_time value : true - name: camera.image.compressed.jpeg_quality
value: 75 # using topic_tools relay to republish camera_info topic - node: pkg: "topic_tools" exec: "relay" output: screen args: "'camera/camera_info' 'camera/image/camera_info'" param: - name: use_sim_time value : $(var use_sim_time)

ros_gz_image

use image_transport

image transport bridge
sudo apt install ros-jazzy-ros-gz-image
ros2 run ros_gz_image image_bridge /camera/image_raw

rqt

ros2 run rqt_image_view rqt_image_view /camera/image_raw

alt text