Home

>

Components

ZED Stereo Camera

In this tutorial, we will show you how to connect and use ZED camera, on your rover.

Prerequisites

No items found.

Home

>

Components

ZED Stereo Camera

In this tutorial, we will show you how to connect and use ZED camera, on your rover.

ZED stereo camera is a type of camera capable of capturing image from two points at the same time. Using stereo disparity – the difference in object location as seen by the left and right lenses –  cameras like ZED are capable of distinguishing the distance of objects from the camera. This data can then be used to in a wide array of cases. In robotics, stereo cameras are commonly used for mapping the environment, object recognition,  3D scanning and in many other.

What to expect?

Prerequisites

No items found.

List of components

To complete this tutorial, you need to have on your rover additional computer, which supports CUDA operations (for example NVIDIA Jetson), has internet connection, and ROS installed (on your and the rover computers).

Mechanical integration

As every ZED camera model has many mounting options and flat bottom, each of the camera models can be easily integrated with the rover. You can 3D print a special plate, which you will attach to the rover using mounting holes, and attach the camera to this plate. Anything that works for you is okay.

Wiring and electronics connection

To connect ZED camera to your additional computer, you need to have one free USB slot on the computer, and connect the camera with a USB cable.

Software integration

ZED SDK

First, you need to install the ZED SDK on your additional computer. Go to the stereolabs page and download installer version, that corresponds your additional computer, and its configuration.

Then, open a terminal in a directory where you have downloaded the installer script and add execution permission to it:

And then, start the installation:

At the beginning of the installation, you will be shown the Software License, just hit q to close it after reading. Next you will be asked for administrator password, and might have to answer some questions on dependencies, tools and samples installation. Type y for yes and n for no and hit Enter (hitting Enter without typing anything chooses default option).

Remember that you need to have CUDA on your borad computer, to use ZED SDK. If it's not installed, when you run ZED SDK installer, it will ask you, whether should it be installed during SDK installation. On Jetson computers CUDA is automatically installed with JetPack, but if you have any problems, try

ROS packages

The ZED ROS wrapper package lets you use the ZED stereo cameras with ROS. It provides you data like left and right rectified/unrectified images, depth map, 3D point cloud and more. To install it, go to src directory in your ROS workspace on board computer, and clone the github repository

Now you have to install all required dependencies. Assuming you are still in src directory, go to the parent directory (cd ..) and type

Now you have to build the packages

If build somehow fails with error including CUDA_TOOLKIT_ROOT_DIR, it means you don't have CUDA installed. Try

Running the package

Running the nodes is actually simple, but we want to have the data visible on other computers connected to the rovers as well. To ensure that, we need to say where (on what computer) is the ROS master. To do so, first source your ROS workspace directory

Path given in this command is relative assuming you are in your ROS workspace directory.

Now we need to export environment variables before running the node. This way we will communicate with the correct ROS master. To export the variables, type on your board computer:

Now you are ready to launch the node

Make sure to provide corret launch file, based by your ZED camera model. Possible options:
  • zed.launch
  • zedm.launch
  • zed2.launch
  • zed2i.launch

Now if everything is fine, you should see on every computer connected to the rover topics from the ZED node. You can list them (after sourcing ROS workspace) with

Examples

Visualizing the data

With the zed_wrapper node running, you can visualize the data from ZED camera in rviz. To do so, you need to add camera display in displays section, and choose the correct image topic.

For the image topic, you can choose anything you want from the options. Different topics give different images, for example

  • rgb/image_rect_color gives color rectified image
  • rgb_raw/image_raw_color gives color unrectified image

You can also choose whether you want the left or right camera sensor (it's included in the image topic name)

With this setup you can see video image from the ZED camera connected to your board computer.

You may occur low quality video, if you try to visualize the camera output like this (without processing) on other computer connected to the rover (not the one that is connected to ZED camera with USB cable). The reason is large size of the data that you are sending.
Surely changing Transport Hint (option below camera image) to compressed will help a bit, but won't solve the problem completely

What next?

Stereo cameras are commonly used in projects involving autonomous navigation, you might be interested in a tutorial about it. They are however, not the only way of teaching a Leo Rover how to move on it's own. Check out our line follower tutorial if you want to learn more. You can also check our Knowledge Base for more instructions.

Contents

Need help? Contact us - contact@fictionlab.pl