Skip to content

Realsense

GitHub code

ROS2 Realsense. (Only installed by default for the template workspace.)

To enable Realsense, set the REALSENSE argument to YES in the compose.yaml file of your desired workspace (e.g., husky_ws/docker/compose.yaml). After making these changes, rebuild the Docker image.

Note: These scripts have only been tested on the RealSense D435i and D455.

See Last tested for the latest validation status.

🐳 Start Container

Make sure your system meets the system requirements and have followed the setup instructions before using this workspace.

Run the following commands in a Ubuntu desktop environment. If you are using a remote server, make sure you're using a terminal within a remote desktop session (e.g., VNC) instead of SSH (i.e., don't use ssh -X or ssh -Y).

cd ~/ros2-essentials/template_ws/docker
docker compose build
xhost +local:docker
docker compose up -d
# The initial build will take a while, please wait patiently.

If your user's UID is 1000, you may replace the docker compose build command with docker compose pull.

The commands in the following sections assume that you are inside the Docker container:

# in a new terminal
docker exec -it ros2-template-ws bash
# and then start systemd-udevd in the container
sudo /lib/systemd/systemd-udevd --daemon

If the initial build somehow failed, run:

rm -r build install
colcon build --symlink-install

Once you have finished testing, you can stop and remove the container with:

docker compose down

Simulation

Realsense test with gazebo

  • realsense_gazebo package: Gazebo simulation of the robot with RealSense D435 camera.
  • Launch Gazebo with turtlebot3 in tmux
    ros2 launch realsense_gazebo realsense_bringup.launch.py
    
  • Run the control tool in new window of tmux
    ros2 run teleop_twist_keyboard teleop_twist_keyboard
    

Real Hardware

Realsense test in real world

You can modify the camera setting in realsense.yaml under realsense_launch/config

  • Launch Realsense camera node
    ros2 launch realsense_launch realsense.launch.py
    
  • Along with RViz
    ros2 launch realsense_launch realsense.launch.py launch_rviz:=true
    

If you encountered strange issues, make sure that systemd-udevd is running in the container, which is required to access IMU data.

Tools

Realsense viewer:

realsense-viewer

Updating Firmware

Updating firmware via realsense-viewer will fail at 30% if systemd-udevd is not running, which could result in the following error:

Recovery device did not connect in time!

Make sure to start systemd-udevd in the container before updating firmware:

sudo /lib/systemd/systemd-udevd --daemon
realsense-viewer
# and then update firmware via realsense-viewer

systemd-udevd is required to detect when the (recovery) device reconnects after requesting the camera to switch to recovery mode.

Example output of a successful firmware update:

Started Firmware Update process
Trying to back-up camera flash memory
Backup completed and saved as '/home/user/.xxxxxxxxxxxx.xxxxxxxx_xxxxxx.bin'
Requesting to switch to recovery mode
DFU device 'xxxxxxxxxxxx' found
Recovery device connected, starting update..
Internal write is in progress
Please DO NOT DISCONNECT the camera
Firmware Download completed, await DFU transition event
Discovered connection of the original device
Device reconnected successfully!
FW update process completed successfully

Troubleshooting

Check USB devices (on host):

lsusb

Check udev rules:

ls -l /lib/udev/rules.d/ | grep realsense

Show extrinsic and intrinsics:

rs-enumerate-devices -c

Show serial number:

rs-enumerate-devices -s

List firmware version:

rs-fw-update -l

References