Home

Awesome

<h1 align="center"> <img src="https://www.intelrealsense.com/wp-content/uploads/2020/09/intel-realsense-logo-360px.png" alt="Intel® RealSense™" title="Intel® RealSense™" /> </h1> <p align="center"> ROS Wrapper for Intel(R) RealSense(TM) Cameras<br> <a href="https://github.com/IntelRealSense/realsense-ros/releases">Latest release notes</a> </p> <hr>

rolling iron humble foxy ubuntu22 ubuntu20

GitHubWorkflowStatus GitHubcontributors License

<hr>

Table of contents

<hr>

ROS1 and ROS2 Legacy

<details> <summary> Intel RealSense ROS1 Wrapper </summary> Intel Realsense ROS1 Wrapper is not supported anymore, since our developers team are focusing on ROS2 distro.<br> For ROS1 wrapper, go to <a href="https://github.com/IntelRealSense/realsense-ros/tree/ros1-legacy">ros1-legacy</a> branch </details> <details> <summary> Moving from <a href="https://github.com/IntelRealSense/realsense-ros/tree/ros2-legacy">ros2-legacy</a> to ros2-master </summary> </details>

Installation on Ubuntu

<details> <summary> Step 1: Install the ROS2 distribution </summary> </details> <details> <summary> Step 2: Install latest Intel&reg; RealSense&trade; SDK 2.0 </summary>

Please choose only one option from the 3 options below (in order to prevent multiple versions installation and workspace conflicts)

</details> <details> <summary> Step 3: Install Intel&reg; RealSense&trade; ROS2 wrapper </summary>

Option 1: Install debian package from ROS servers (Foxy EOL distro is not supported by this option):

Option 2: Install from source

sudo apt-get install python3-rosdep -y
sudo rosdep init # "sudo rosdep init --include-eol-distros" for Foxy and earlier
rosdep update # "sudo rosdep update --include-eol-distros" for Foxy and earlier
rosdep install -i --from-path src --rosdistro $ROS_DISTRO --skip-keys=librealsense2 -y
colcon build
ROS_DISTRO=<YOUR_SYSTEM_ROS_DISTRO>  # set your ROS_DISTRO: iron, humble, foxy
source /opt/ros/$ROS_DISTRO/setup.bash
cd ~/ros2_ws
. install/local_setup.bash
</details> <hr>

Installation on Windows

PLEASE PAY ATTENTION: RealSense ROS2 Wrapper is not meant to be supported on Windows by our team, since ROS2 and its packages are still not fully supported over Windows. We added these installation steps below in order to try and make it easier for users who already started working with ROS2 on Windows and want to take advantage of the capabilities of our RealSense cameras

<details> <summary> Step 1: Install the ROS2 distribution </summary> </details> <details> <summary> Step 2: Download RealSense&trade; ROS2 Wrapper and RealSense&trade; SDK 2.0 source code from github: </summary> </details> <details> <summary> Step 3: Build </summary>
  1. Before starting building of our packages, make sure you have OpenCV for Windows installed on your machine. If you choose the Microsoft IOT way to install it, it will be installed automatically. Later, when colcon build, you might need to expose this installation folder by setting CMAKE_PREFIX_PATH, PATH, or OpenCV_DIR environment variables

  2. Run "x64 Native Tools Command Prompt for VS 2019" as administrator

  3. Setup ROS2 Environment (Do this for every new terminal/cmd you open):

    • If you choose the Microsoft IOT Binary option for installation

      > C:\opt\ros\humble\x64\setup.bat
      
    • If you choose the ROS2 formal documentation:

      > call C:\dev\ros2_iron\local_setup.bat
      
  4. Change directory to realsense-ros folder

    > cd C:\ros2_ws\realsense-ros
    
  5. Build librealsense2 package only

    > colcon build --packages-select librealsense2 --cmake-args -DBUILD_EXAMPLES=OFF -DBUILD_WITH_STATIC_CRT=OFF -DBUILD_GRAPHICAL_EXAMPLES=OFF
    
    • User can add --event-handlers console_direct+ parameter to see more debug outputs of the colcon build
  6. Build the other packages

    > colcon build --packages-select realsense2_camera_msgs realsense2_description realsense2_camera
    
    • User can add --event-handlers console_direct+ parameter to see more debug outputs of the colcon build
  7. Setup environment with new installed packages (Do this for every new terminal/cmd you open):

    > call install\setup.bat
    
</details> <hr>

Usage

Start the camera node

with ros2 run:

ros2 run realsense2_camera realsense2_camera_node
# or, with parameters, for example - temporal and spatial filters are enabled:
ros2 run realsense2_camera realsense2_camera_node --ros-args -p enable_color:=false -p spatial_filter.enable:=true -p temporal_filter.enable:=true

with ros2 launch:

ros2 launch realsense2_camera rs_launch.py
ros2 launch realsense2_camera rs_launch.py depth_module.depth_profile:=1280x720x30 pointcloud.enable:=true
<hr>

Camera Name And Camera Namespace

User can set the camera name and camera namespace, to distinguish between cameras and platforms, which helps identifying the right nodes and topics to work with.

Example

Default behavior if non of these parameters are given:

> ros2 node list
/camera/camera

> ros2 topic list
/camera/camera/color/camera_info
/camera/camera/color/image_raw
/camera/camera/color/metadata
/camera/camera/depth/camera_info
/camera/camera/depth/image_rect_raw
/camera/camera/depth/metadata
/camera/camera/extrinsics/depth_to_color
/camera/camera/imu

> ros2 service list
/camera/camera/device_info
<hr>

Parameters

Available Parameters:

Parameters that can be modified during runtime:

Parameters that cannot be changed in runtime:

<hr>

ROS2(Robot) vs Optical(Camera) Coordination Systems:

image

<hr>

TF from coordinate A to coordinate B:

<hr>

Extrinsics from sensor A to sensor B:

d435i

administrator@perclnx466 ~/ros2_humble $ ros2 topic echo /camera/camera/extrinsics/depth_to_color
rotation:
- 0.9999583959579468
- 0.008895332925021648
- -0.0020127370953559875
- -0.008895229548215866
- 0.9999604225158691
- 6.045500049367547e-05
- 0.0020131953060626984
- -4.254872692399658e-05
- 0.9999979734420776
translation:
- 0.01485931035131216
- 0.0010161789832636714
- 0.0005317096947692335
---
<hr>

Published Topics

The published topics differ according to the device and parameters. After running the above command with D435i attached, the following list of topics will be available (This is a partial list. For full one type ros2 topic list):

This will stream relevant camera sensors and publish on the appropriate ROS topics.

Enabling accel and gyro is achieved either by adding the following parameters to the command line:</br> ros2 launch realsense2_camera rs_launch.py pointcloud.enable:=true enable_gyro:=true enable_accel:=true </br> or in runtime using the following commands:

ros2 param set /camera/camera enable_accel true
ros2 param set /camera/camera enable_gyro true

Enabling stream adds matching topics. For instance, enabling the gyro and accel streams adds the following topics:

<hr>

RGBD Topic

RGBD new topic, publishing [RGB + Depth] in the same message (see RGBD.msg for reference). For now, works only with depth aligned to color images, as color and depth images are synchronized by frame time tag.

These boolean paramters should be true to enable rgbd messages:

The current QoS of the topic itself, is the same as Depth and Color streams (SYSTEM_DEFAULT)

Example:

ros2 launch realsense2_camera rs_launch.py enable_rgbd:=true enable_sync:=true align_depth.enable:=true enable_color:=true enable_depth:=true 
<hr>

Metadata topic

The metadata messages store the camera's available metadata in a json format. To learn more, a dedicated script for echoing a metadata topic in runtime is attached. For instance, use the following command to echo the camera/depth/metadata topic:

python3 src/realsense-ros/realsense2_camera/scripts/echo_metadada.py /camera/camera/depth/metadata
<hr>

Post-Processing Filters

The following post processing filters are available:

Each of the above filters have it's own parameters, following the naming convention of <filter_name>.<parameter_name> including a <filter_name>.enable parameter to enable/disable it.

<hr>

Available services

<hr>

Efficient intra-process communication:

Our ROS2 Wrapper node supports zero-copy communications if loaded in the same process as a subscriber node. This can reduce copy times on image/pointcloud topics, especially with big frame resolutions and high FPS.

You will need to launch a component container and launch our node as a component together with other component nodes. Further details on "Composing multiple nodes in a single process" can be found here.

Further details on efficient intra-process communication can be found here.

Example

Manually loading multiple components into the same process

Limitations

Latency test tool and launch file

For getting a sense of the latency reduction, a frame latency reporter tool is available via a launch file. The launch file loads the wrapper and a frame latency reporter tool component into a single container (so the same process). The tool prints out the frame latency (now - frame.timestamp) per frame.

The tool is not built unless asked for. Turn on BUILD_TOOLS during build to have it available:

colcon build --cmake-args '-DBUILD_TOOLS=ON'

The launch file accepts a parameter, intra_process_comms, controlling whether zero-copy is turned on or not. Default is on:

ros2 launch realsense2_camera rs_intra_process_demo_launch.py intra_process_comms:=true
</details>