Skip to content

ROS With Arducam ToF Camera – for Raspberry Pi

ROS 2 with time of flight camera

About ROS

Robot Operating System (ROS or ros) is an open-source robotics middleware suite. Although ROS is not an operating system (OS) but a set of software frameworks for robot software development, it provides services designed for a heterogeneous computer cluster such as hardware abstraction, low-level device control, implementation of commonly used functionality, message-passing between processes, and package management.

Using ROS2 with Arducam ToF Camera

To properly use ROS2 with Arducam ToF Camera, the camera driver and necessary dependencies have to be installed first.

Step 1. Pull the repository.

git clone https://github.com/ArduCAM/Arducam_tof_camera.git

Step 2. Change the directory to Arducam_tof_camera

cd Arducam_tof_camera

Step 3. Installation (Driver, Dependencies, SDK, OpenCV)

./Install_dependencies.sh

When you see the reboot prompt, enter y. Raspberry Pi will automatically reboot.

Step 4 Installing ROS2

The follow-up steps will help you install ROS2 Environment on Bullseye OS or Bookworm OS.

Step 4.1 Installing ROS2 on Bulleye OS

Please run the following commands in the terminal:

curl -s https://raw.githubusercontent.com/v1ster/rpi-bullseye-ros2/main/install.bash | bash

#Modify enviroment viriables
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc 
echo "export ROS_DOMAIN_ID=7" >> ~/.bashrc 
source ~/.bashrc 
sudo apt install python3-colcon-common-extensions

Step 4.2 Installing ROS2 on Bookworm OS

Please run the following commands in the terminal:

# Install relevant packages and dependencies
wget https://s3.ap-northeast-1.wasabisys.com/download-raw/dpkg/ros2-desktop/debian/bookworm/ros-jazzy-desktop-0.3.2_20240525_arm64.deb
sudo apt install ./ros-jazzy-desktop-0.3.2_20240525_arm64.deb
sudo pip install --break-system-packages vcstool colcon-common-extensions

# Setup environment 
source /opt/ros/jazzy/setup.bash

# Test demo programme
mkdir -p ./ros2_ws/src
cd ./ros2_ws
sudo git clone https://github.com/ros2/examples src/examples -b jazzy
colcon build --symlink-install

Step 5. Compile & run ROS2 on your Raspberry Pi

Compile

cd Arducam_tof_camera/ros2_publisher
colcon build --merge-install

Run

. install/setup.bash 
ros2 run arducam_rclpy_tof_pointcloud tof_pointcloud

Step 6. Previewing on your HOST computer

Install ROS2 on your host PC, and run rviz2

rviz2

Click Add > By topic > Select PointCloud2

ROS2 time of flight camera GUI

Enable PointCloud2, change Fixed Frame to sensor_frame, and change Size (m) to 0.001, and you will see a real-time point cloud preview like the following:

point cloud preview with rviz2 on ROS2