This guide walks you through how to map your environment using the RoboCam robot and ROS 2, and how to detect and visualize objects in 3D space using a depth camera and a clustering algorithm.
Before you begin, make sure all necessary packages are installed.
sudo apt update
sudo apt install ros-humble-slam-toolbox
sudo apt install ros-humble-navigation2 ros-humble-nav2-bringup
sudo apt install ros-humble-pcl-conversions ros-humble-pcl-msgs libpcl-devMake sure your custom package (e.g., sensor_handler) includes:
rclcppsensor_msgspcl_conversionsvisualization_msgs
Start the simulated or physical RoboCam robot along with the Nav2 navigation system:
ros2 launch robocam one_robot_ign_launch.pyOptional: Customize navigation behavior in:
robocam_navigation/config/nav2.yaml
Use SLAM Toolbox to build the map in real-time:
ros2 launch robocam_navigation slamtoolbox_launch.pyEdit this launch file if you need to change SLAM configuration:
robocam_navigation/launch/slamtoolbox_launch.py
Launch your custom clustering node to detect objects using the depth camera's point cloud data:
ros2 run sensor_handler depth_camera_node --ros-args -p publish_markers:=true- Subscribes to
/r1/depth_camera/points - Filters and downsamples point cloud
- Performs Euclidean clustering using PCL
- Publishes detected objects as markers (
/cluster_marker_array)
You can disable visualization using:
--ros-args -p publish_markers:=falseUse keyboard teleop to drive the robot and let SLAM + clustering work together:
ros2 run robocam omni_teleop_keyboard.pyAs you drive around, a 2D map is built and 3D clusters are detected and shown in RViz.
Once you're done exploring:
ros2 run nav2_map_server map_saver_cli -f ~/my_mapThis saves my_map.yaml and my_map.pgm or .png in your home directory.
You can tune the behavior of the clustering node in depth_camera_node.cpp:
ClusterTolerance: distance between points (e.g.0.3)MinClusterSize: ignore small noise clusters (e.g.10)MaxClusterSize: filter out very large clusters (e.g.1000)VoxelGridleaf size: downsample for faster processing (e.g.0.1f)
| Step | Action |
|---|---|
| 1️⃣ | Launch RoboCam and Nav2 |
| 2️⃣ | Start SLAM Toolbox |
| 3️⃣ | Launch depth clustering node |
| 4️⃣ | Drive the robot with keyboard |
| 5️⃣ | Save the map |
- Clustering performance depends on sensor quality and environment structure.
- Markers are published using
visualization_msgs/MarkerArrayon/cluster_marker_array. - RViz setup: Add a
MarkerArraydisplay and point it to/cluster_marker_array.
Enjoy building maps and detecting objects in real-time with RoboCam and ROS 2! 🚀