Using ROS with Spinnaker
Applicable Products
All Teledyne FLIR machine vision GenICam USB3 or GigE cameras
Overview
The Robot Operating System (ROS) is a powerful open-source framework for building and programming robots.
Spinnaker has a package (flir_camera_driver) which bridges ROS and the Spinnaker SDK for use with Teledyne FLIR machine vision cameras. This application note provides a guide on how to use cameras with ROS and Linux Ubuntu 20.04 Spinnaker.
This application note assumes you have a basic understanding of ROS and are familiar with its concepts and terminology. If you are a new user of ROS, we recommend you follow the tutorials provided on the official ROS website (http://wiki.ros.org/) before using ROS with Spinnaker.
Notes: ROS in this application note refers to ROS1 and does not cover ROS2. If using Ubuntu 16.04 or 18.04 then use the respective ROS distributions for those versions. At the time of writing, there are no ROS1 distributions for Ubuntu 22.04.
System Requirements
Before beginning you need:
- A computer running Ubuntu 20.04
- A Teledyne FLIR machine vision camera
- A USB3 or GigE cable to connect the camera to the computer
Install the ROS Spinnaker Package
The installation is in three parts:
- Install the Spinnaker SDK
- Install the ROS distribution
- Install the ROS driver for Spinnaker
Install Spinnaker
To install the Spinnaker SDK:
- Download the Spinnaker SDK:
From the Spinnaker page select Download now and choose the Linux version. - Follow the installation instructions.
- Launch the SpinView application to test the installation. Select your camera from the camera list. You should see an image from your camera.
Install ROS Distribution
The ROS version for Ubuntu 20.04 is ROS Noetic: http://wiki.ros.org/noetic/Installation/Ubuntu
- Add the ROS repository to your system:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' sudo apt install curl curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add – |
- Update the package list:
sudo apt update |
- Install the ROS packages:
sudo apt install ros-noetic-desktop-full |
- Create a catkin workspace. This is where all future ROS packages should be installed.
mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src |
Install ROS Driver
The ROS Spinnaker driver for Teledyne FLIR cameras is available from github: https://github.com/ros-drivers/flir_camera_driver
This is a ROS-specific API for working with Spinnaker. It provides a set of ROS nodes and topics for interacting with Teledyne cameras and is built on the Spinnaker SDK.
To use your camera with ROS you need to install the following dependencies:
- camera-info-manager
- diagnostic-updater
- dynamic-reconfigure
- image-exposure-msgs
- image-transport
- nodelet
- roscpp
- sensor-msgs
- wfov-camera-msgs
- Install the dependencies:
sudo apt install ros-noetic-camera-info-manager ros-noetic-diagnostic-updater ros-noetic-dynamic-reconfigure ros-noetic-image-exposure-msgs ros-noetic-image-transport ros-noetic-nodelet ros-noetic-roscpp ros-noetic-sensor-msgs ros-noetic-wfov-camera-msgs |
- Install the package by cloning it to your catkin workspace and building it with catkin_make:
cd ~/catkin_ws/src git clone -b noetic-devel https://github.com/ros-drivers/flir_camera_driver.git cd ~/catkin_ws catkin_make |
Note: to avoid having to source it every time you open a new terminal, source the package in your bashrc file:
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc source ~/.bashrc |
Use your Camera with the ROS Spinnaker Package
The ROS Spinnaker package provides several different ROS nodes, topics, and services for controlling the camera, reading image data, and more.
Note: If you chose not to modify the bashrc file during installation, before running any ROS commands, source the ROS noetic for each terminal with the following command:
source /opt/ros/noetic/setup.bash |
Configure the Launch File
Before obtaining images, write a launch file that has all the parameters you might want to change. Some example launch files are available in /spinnaker_camer_driver/launch/.
When testing a single camera, use the camera.launch file. In this file you specify the camera’s serial number, connection type (USB3 or GigE), frame rate, and other parameters.
If multiple cameras are connected, you must specify in the launch file the serial number of the camera you want to use with ROS otherwise camera.launch uses the first camera it finds.
When testing a stereo camera, use the stereo.launch file. You can specify the serial numbers for the left and right camera.
Run the Camera Driver Node
Note: If you chose not to modify the bashrc file, in the terminal use the command:
source ~/catkin_ws/devel/setup.bash |
To start streaming images from the camera, launch the spinnaker_camera_driver:
roslaunch spinnaker_camera_driver camera.launch |
This starts streaming images at the default frame rate and publishes them to the ‘/camera/image_raw’ topic.
View Camera Images
The rqt_image_view tool displays images in real-time.
To launch the tool, run the following:
rqt_image_view |
A window opens displaying the images being streamed.
If the window is blank, from the drop-down select the topic ‘/camera/image_raw’ to see the image.
Set Parameters
There are several parameters that can adjust the camera’s settings. These can be seen and changed using the rqt_reconfigure tool.
To launch the tool, run the following:
rosrun rqt_reconfigure rqt_reconfigure |
A window opens displaying all the configurable parameters. Use the tool to adjust camera settings such as exposure time, gain, and frame rate.