Intel® RealSense™ ROS 2 Sample Application#

This tutorial tells you how to:

  • Launch ROS nodes for a camera.

  • List ROS topics.

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

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

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

Run the Sample Application#

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

  2. Check if your installation has the amr-realsense Docker* image.

    docker images |grep amr-realsense
    #if you have it installed, the result is:
    amr-realsense
    

    Note

    If one or both of the images are not installed, continuing with these steps triggers a build that takes longer than an hour (sometimes, a lot longer depending on the system resources and internet connection).

  3. If the image is not installed, Intel® recommends installing the Robot Complete Kit with the Get Started Guide for Robots.

  4. Check that EI for AMR environment is set:

    echo $AMR_TUTORIALS
    # should output the path to EI for AMR tutorials
    /home/user/edge_insights_for_amr/Edge_Insights_for_Autonomous_Mobile_Robots_2023.1/AMR_containers/01_docker_sdk_env/docker_compose/05_tutorials
    

    If nothing is output, refer to Get Started Guide for Robots Step 5 for information on how to configure the environment.

  5. Run the command below to start the Docker* container:

    docker compose -f $AMR_TUTORIALS/realsense.tutorial.yml run --rm realsense bash
    
  6. Check for latest Intel® RealSense™ firmware updates.

    1. Open the Intel® RealSense™ viewer application:

      realsense-viewer
      

      In the Intel® RealSense™ viewer, if any firmware update is available, a window popup appears in the upper right corner.

    2. During the firmware update installation, do not disconnect the Intel® RealSense™ camera. Press Install in the window popup.

    3. After the installation is complete or if no update is available, close the Intel® RealSense™ viewer.

    4. Exit the Docker* image:

      exit
      
  7. Run an automated yml file that opens the Intel® RealSense™ ROS 2 node and lists camera-relevant information.

    docker compose -f $AMR_TUTORIALS/realsense.tutorial.yml up
    

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

    ../_images/7D402688-0369-4FDA-BB1B-107523B9B43F-low.png
  8. To close this, do the following:

    • Type Ctrl-c in the terminal where you did the up command.

    • Run this command to remove stopped containers:

    docker compose -f $AMR_TUTORIALS/realsense.tutorial.yml down
    

Troubleshooting#

In some cases, the stream may not appear due to permission issues on the host. You may see this error message:

ERROR: Pipeline doesn't want to pause.
  1. To fix this, install the librealsense udev rules.

    git clone https://github.com/IntelRealSense/librealsense
    # Copy the 99-realsense-libusb.rules files to the rules.d folder
    cd librealsense
    sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
    sudo udevadm control --reload-rules
    sudo udevadm trigger
    
  2. Then open the gst-launch command.

If the problem persists, you can try any or all of the following:

  • Verify that $DISPLAY has the correct value.

  • Perform an Intel® RealSense™ hardware reset:

# Open realsense docker container
docker compose -f $AMR_TUTORIALS/realsense.tutorial.yml run --rm realsense bash

# While in realsense container, open the realsense-viewer application
realsense-viewer
# In  realsense-viewer menu, go to "More" and then select "Hardware Reset"
# Wait for reset to complete and then close the realsense-viewer application.
  • Reboot the target.

For Intel® RealSense™ documentation, see https://dev.intelrealsense.com/docs/docs-get-started.

For calibration issues, see https://dev.intelrealsense.com/docs/self-calibration-for-depth-cameras.

For general robot issues, go to: Troubleshooting for Robot Tutorials.