Skip to content

Camera feed and depth camera

Adnan Munawar edited this page Feb 20, 2023 · 6 revisions

These features only work on Linux with ROS installed. Additionally, you should have the following packages installed on your system.

cv-bridge # Can be installed via apt install ros-<version>-cv-bridge
image-transport # Can be installed via apt install ros-<version>-image-transport

Once these packages are installed, you can rebuild ambf to automatically enable support.

Now you can edit your world.yaml file that contains the cameras for which you want to enable camera feed and/or depth pointcloud publishing.

NOTE: Cameras can be defined either in a world file or regular ADF files (as shown here world_stereo.yaml and here stereo_cameras.yaml). The world filepath is defined in the launch file (as shown here world filepath in launch file). If you are using a different launch file by providing the --launch_file argument, then most probably you are also using a different world file as defined in that launch file, so always make sure that you are setting the flags below for the correct camera for it to publish its video and/or depth.

The default world file is located here: https://github.com/WPI-AIM/ambf/blob/ambf-1.0/ambf_models/descriptions/world/world.yaml

Inspecting its contents:

enclosure size: {length: 10.0, width: 10.0, height: 3.0}
lights: [light1]
cameras: [camera1] # You can see, we are going to load a camera called camera1 which is defined later in this file
environment: "./checkered_floor.yaml"
namespace: /ambf/env/
max iterations: 50
gravity: {x: 0.0, y: 0.0, z: -9.81}
...
...
camera1:
  namespace: cameras/
  name: default_camera
  location: {x: 4.0, y: 0.0, z: 2.0}
  look at: {x: 0.0, y: 0.0, z: -0.5}
  up: {x: 0.0, y: 0.0, z: 1.0}
  clipping plane: {near: 0.1, far: 10.0}
  field view angle: 0.8
  monitor: 0
  # multipass: True
  # publish image: True
  # publish image interval: 1 # Publish every nth scene update
  # publish depth: True
  # publish depth interval: 10 # Publish every nth scene update
  # publish image resolution: {width: 1920, height: 1080}

By uncommenting/adding the following line, we can enable camera feed publishing

  publish image: True
  # publish image interval: 1 # Publish every nth scene update. Default 1

and by uncommenting this field, we can enable depth pointcloud computation and publishing

  publish depth: True
  # publish depth interval: 10 # Publish every nth scene update. Default 10

The camera feed is published to the following topic:

/<namespace>/<camera_name>/ImageData/*

and the depth pointcloud is published to the following topics:

/<namespace>/<camera_name>/DepthData/

You can also view either topic in RViz.

Setting the image resolution:

The default resolution of published images and depth point cloud is 640x480 pixels. To change it, the following field can be set by un-comment/adding it to the camera description. :

publish image resolution: {width: 1920, height: 1080} #In pixels

In this case, the published image from the specific camera will be 1920x1080 pixels.

Example:

Here is an example image:

Clone this wiki locally