Intel® RealSense™ ROS 2 Sample Application

This tutorial tells you how to:

  • Launch ROS nodes for a camera.

  • List ROS topics.

  • Confirm that Intel® RealSense™ topics are publishing data.

  • Retrieve data from the Intel® RealSense™ camera (data coming at FPS).

  • Visualize an image from the Intel® RealSense™ camera displayed in rviz2.

This Intel® RealSense™ ROS 2 Sample Application can be run using two different types of Intel® RealSense™ cameras. The next section explains how to run this sample application using an Intel® RealSense™ USB camera (for example, Intel® RealSense™ D435i). The subsequent section focuses on an Intel® RealSense™ Depth Camera D457 in MIPI mode, which is connected to an Axiomtek Robox500 ROS2 AMR Controller.

Using Intel® RealSense™ USB camera

  1. Connect an Intel® RealSense™ USB camera (for example, Intel® RealSense™ D435i) to the host.

  2. Install the librealsense2 and realsense2 tools:

    sudo apt-get install -y ros-humble-librealsense2-tools
    
    Copy to clipboard
  3. To download and install the Intel® RealSense™ ROS 2 sample application, run the command below:

    sudo apt-get install -y ros-humble-realsense2-tutorial-demo
    
    Copy to clipboard
  4. Set up the ROS 2 environment:

    source /opt/ros/humble/setup.bash
    
    Copy to clipboard
  5. Run the Intel® RealSense™ ROS 2 sample application:

    ros2 launch realsense2_tutorial realsense2_tutorial.launch.py
    
    Copy to clipboard

    Expected output: The image from the Intel® RealSense™ camera is displayed in rviz2, on the bottom left side.

    ../../../_images/rs_tutorial_usb.png
  6. To close this, do the following:

    • Type Ctrl-c in the terminal where the tutorial was run.

Using Intel® RealSense™ Depth Camera D457 on an Axiomtek Robox500 ROS2 AMR Controller

The following steps are required in order to setup the Axiomtek Robox500 ROS2 AMR Controller to support the Intel® RealSense™ Depth Camera D457.

Axiomtek Robox500 ROS2 AMR Controller Setup

Connect an Intel® RealSense™ Depth Camera D457 to the Axiomtek Robox500 ROS2 AMR Controller as shown in the below picture. Now, power-on the target.

../../../_images/rs_tutorial_Axiomtek_gmsl_camera_connection.png

Note

Select the “MIPI” mode of the Intel® RealSense™ Depth Camera D457 by moving the select switch on the camera to “M”, as shown in the below picture.

../../../_images/MIPI_USB_Switch_in_D457.jpeg

BIOS settings

Go to the BIOS menu by pressing “Del” or “Esc” button when the board is powered on. The following BIOS settings should be set to enable Intel® RealSense™ Depth Camera D457 support on an Axiomtek Robox500 ROS2 AMR Controller.

  • Intel Advanced Menu -> Power & Performance -> CPU-Power Management Control -> C States -> < Disable > (Note: If enabled, fps drops)

  • Intel Advanced Menu -> System Agent (SA) Configuration -> MIPI Camera Configuration -> < Enable > (Note: Enable all four cameras in this menu)

  • Camera BIOS settings.

Camera BIOS settings

BIOS setting

Camera 1

Camera 2

Camera 3

Camera 4

MIPI Port

0

1

2

3

Lane user

x2

x2

x2

x2

Port speed

2

2

2

2

I2C Channel

I2C5

I2C5

I2C5

I2C5

Device0 I2C Address

12

14

16

18

Device1 I2C Address

42

44

62

64

Device2 I2C Address

48

4a

68

6c

Install librealsense2 and realsense2 tools

sudo apt install -y ros-humble-librealsense2-tools
Copy to clipboard

Install intel-ipu6 (intel-ipu6-dkms) driver

  1. Create a /etc/modprobe.d/blacklist-ipu6.conf file and add the lines of the listing below. This will prevent the loading of the existing default intel_ipu6_isys kernel module.

    # kernel builtin ipu6 driver and realsense D4XX driver clash with intel-ipu6-dkms installation.
    blacklist intel_ipu6_isys
    blacklist intel_ipu6_psys
    blacklist intel_ipu6
    
    Copy to clipboard
  2. Reboot the target.

  3. Install the intel-ipu6-dkms:

    sudo apt install -y intel-ipu6-dkms
    
    Copy to clipboard
  4. Run the following command for dkms to force-install the intel-ipu6 driver:

    dkms install --force ipu6-drivers/20230621+iotgipu6-0eci8
    
    Copy to clipboard
  5. Check the dkms status by using the following command:

    $ dkms status
    ipu6-drivers/20230621+iotgipu6-0eci8, 5.15.0-1048-intel-iotg, x86_64: installed
    
    Copy to clipboard

    If the dkms status is not “installed”, then rerun the command from step number 4.

  6. modprobe the installed intel-ipu6 driver:

    sudo modprobe intel-ipu6-isys
    
    Copy to clipboard

    Note

    The modprobe command must be run after every system reboot. This is because the intel-ipu6-isys kernel module is not loaded by OS at boot. It must be loaded manually using the above command.

  7. After installation, check the status of the loaded intel-ipu6-isys kernel module. The kernel module loaded must be /lib/modules/5.15.0-1048-intel-iotg/updates/dkms/intel-ipu6-isys.ko as shown below:

    $ modinfo intel-ipu6-isys | head -3
    filename:       /lib/modules/5.15.0-1048-intel-iotg/updates/dkms/intel-ipu6-isys.ko
    description:    Intel ipu input system driver
    license:        GPL
    
    Copy to clipboard

Add the user to the video and render group

# Add the $USER to the video group
sudo usermod -a -G video $USER

# Add the $USER to the render group
sudo usermod -a -G render $USER
Copy to clipboard

Install and run the Intel® RealSense™ ROS 2 sample application

  1. To download and install the Intel® RealSense™ ROS 2 sample application run the below command:

    sudo apt-get install -y ros-humble-realsense2-tutorial-demo
    
    Copy to clipboard
  2. Set up the ROS 2 environment:

    source /opt/ros/humble/setup.bash
    
    Copy to clipboard
  3. Run the following command to bind the Intel® RealSense™ Depth camera D457 with intel-ipu6 driver with metadata enabled:

    rs_ipu6_d457_bind.sh
    
    Copy to clipboard
  4. Run the Intel® RealSense™ ROS 2 sample application:

    ros2 launch realsense2_tutorial realsense2_tutorial.launch.py use_sub_camera:=false
    
    Copy to clipboard

    Expected output: The image from the Intel® RealSense™ camera is displayed in rviz2, on the bottom left side.

    ../../../_images/rs_tutorial_gmsl_Axiomtek.png
  5. To close this, do the following:

    • Type Ctrl-c in the terminal where the tutorial was run.