Run an Intel® RealSense™ ROS 2 Sample Application in Docker* Container
Run the Sample Application
- Connect an Intel® RealSense™ camera (for example, D435i) to the host.
- Go to theAMR_containersfolder:cd <edge_insights_for_amr_path>/Edge_Insights_for_Autonomous_Mobile_Robots_<version>/AMR_containers
- Run the command below to start the Docker container:./run_interactive_docker.sh amr-ubuntu2004-full-flavour-sdk:<TAG> eiforamr
- Check for latest Intel® RealSense™ firmware updates.
- Open the Intel® RealSense™ viewer application:realsense-viewerIn the Intel® RealSense™ viewer, if any firmware update is available, a window popup appears in the upper right corner.
- During the firmware update installation, do not disconnect the Intel® RealSense™ camera. PressInstallin the window popup.
- After the installation is complete or if no update is available, close the Intel® RealSense™ viewer.
- Launch ROS nodes for the camera:# for D435i camera model: ros2 launch realsense2_camera rs_launch.py align_depth:=true &Expected output:
- Display the ROS topics list:ros2 topic listThe following topics are displayed:/camera/aligned_depth_to_color/camera_info /camera/aligned_depth_to_color/image_raw /camera/color/camera_info /camera/color/image_raw /camera/depth/camera_info /camera/depth/image_rect_raw /camera/extrinsics/depth_to_color
- Send command to see that RealSense topics are publishing data:ros2 topic echo /camera/color/image_rawThe published data will have the following structure:-- header: stamp: sec: 1618393694 nanosec: 869479680 frame_id: camera_color_optical_frame height: 720 width: 1280 encoding: rgb8 is_bigendian: 0 step: 3840 data: - 159 - 174 - 156 - 163 ...PressCTRL+C.
- Get data from the Intel® RealSense™ camera (data coming at FPS):ros2 topic hz /camera/color/image_rawData received from the device:average rate: 29.709 min: 0.020s max: 0.049s std dev: 0.00422s window: 32 average rate: 29.784 min: 0.020s max: 0.051s std dev: 0.00470s window: 62 average rate: 29.772 min: 0.020s max: 0.051s std dev: 0.00436s window: 92PressCTRL+C.
- Run the rviz2 command. The image from the Intel® RealSense™ camera will be displayed in rviz2:ros2 run rviz2 rviz2 --display-config rviz2In rviz2 press:
- ADDbutton - By Topic - /camera/color/image_raw/Camera and pressOK.
- ADDbutton - By Topic - /camera/aligned_depth_to_color/image_raw/Camera and pressOK.
- From top, left side atFixed Frameselectcamera_linkorcamera_color_frame.
- From top, left side go toCamera > Topic > Reliability Policy >selectBest Effort(perform this step for both Cameras from the left side).
- The image from the Intel® RealSense™ camera will be displayed in rviz2, bottom left side.
Troubleshooting
If the following error is encountered:
$ ./run_interactive_docker.sh amr-ubuntu2004-full-flasvour-sdk:<TAG> eiforamr
bash: ./run_interactive_docker.sh Permission denied
Give executable permission to the script:
$ chmod 755 run_interactive_docker.sh
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.
Summary and Next Steps
In this tutorial, you learned how to launch ROS nodes for camera, list
the ROS topics, see that Intel® RealSense™ topics are publishing data,
get data from Intel® RealSense™ camera (data coming at FPS), and how to
see image from Intel® RealSense™ camera displayed in rviz2.
As a next step, see the Run a GStreamer* Video Pipeline using GStreamer* Plugins in Docker* Container
tutorial.