• Pepe

Using Rviz Camera overlay

This is a quick tutorial on how to overlay the Rviz displays on top of a camera feed. This tutorial will not include how to get a camera going in ROS, and how to get a TF of the camera position going. For that you can visit this link that explains how to use the a camera or video stream with ROS, and for the TF you can get some information here (will do a TF tutorial later).

The first step is to get your camera up and going with Ros and to have a Robot model ( in our case we have a robot description made by a .xacro).

The second step is to make a TF for your camera, this is the one that we added to our system in the .xacro file:

<!-- Add this to the top of the file after "<robot > -->

<xacro:include filename="$(find common_description)/urdf/camera/fisheye_180.xacro"/>

<property name="z_offset" value="0.05"/>

<property name="x_offset" value="0.09"/>

<property name="y_offset" value="0.00"/> <!-- CAMERA -->

<fisheye_180 name="fisheye"









The content of fisheye_180.xacro is the following:

<?xml version="1.0"?>

<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

<xacro:include filename="$(find common_description)/urdf/camera/base_camera.xacro"/>

<xacro:macro name="fisheye_180" params="name parent translateX translateY translateZ roll pitch yaw">

<xacro:base_camera name="${name}"









<box size="0.04 0.04 0.01"/>





And the content of base_camera.xacro is:

<?xml version="1.0"?>

<robot name="base_camera"


<xacro:macro name="base_camera" params="name parent translateX translateY translateZ roll pitch yaw **geometry">

<joint name="${name}_camera_joint" type="fixed">

<parent link="${parent}"/>

<child link="${name}_camera_link"/>

<origin xyz="${translateX} ${translateY} ${translateZ}" rpy="${roll} ${pitch} ${yaw}"/>

<axis xyz="1 0 0" />


<link name="${name}_camera_link">


<origin xyz="0 0 0" rpy="0 0 0" />


<xacro:insert_block name="geometry" />




<origin xyz="0 0 0" rpy="0 0 0" />


<xacro:insert_block name="geometry" />


<material name="grey">

<color rgba="0.2 0.2 0.2 1.0"/>






After the camera has a valid urdf (made by the .xacro file) we need to calibrate the camera. To calibrate the camera we used the camera_calibration ROS package. To be able to calibrate it we printed a chess board that we found on the internet.

The next step was to add the calibration file to the camera launch file. This is the launch file we used:


<!-- launch video stream -->

<include file="$(find video_stream_opencv)/launch/camera.launch" >

<!-- node name and ros graph name -->

<arg name="camera_name" value="0" />

<!-- means video device 0, /dev/video0 -->

<arg name="video_stream_provider" value="0" />

<!-- set camera fps to (if the device allows) -->

<arg name="set_camera_fps" value="30"/>

<!-- set buffer queue size of frame capturing to (1 means we want the latest frame only) -->

<arg name="buffer_queue_size" value="1" />

<!-- throttling the querying of frames to -->

<arg name="fps" value="30" />

<!-- setting frame_id -->

<arg name="frame_id" value="fisheye_camera_link" />

<arg name="camera_info_url" value="file:///$(find dev_platform_base)/config/cameras/Camera_fisheye.yaml" />

<!-- flip the image horizontally (mirror it) -->

<arg name="flip_horizontal" value="false" />

<!-- flip the image vertically -->

<arg name="flip_vertical" value="false" />

<!-- force width and height, 0 means no forcing -->

<arg name="width" value="800"/>

<arg name="height" value="600"/>

<!-- visualize on an image_view window the stream generated -->

<arg name="visualize" value="false" />



And the last step is to run your robot with the camera launch file. If you have a working system the camera should be up and running and you can open the camera view in rviz.


Tel: +44 ‭118 334 2361


Ross Robotics Limited

Unit 1, Twyford Industrial Estate, Ruscombe Business Park, Twyford, Reading, Berkshire RG10 9NJ, United Kingdom

© 2019 Ross Robotics Ltd