Lightweight ROS (Noetic) point‑cloud mapping node that aggregates incoming point clouds into a simple map and estimates odometry using a GTSAM iSAM2 pose graph. Includes a basic collision‑check service against the accumulated map.
This repository provides:
- A catkin package
barracuda_mappingwith a single C++ nodeslam_node. - A launch file and YAML config for topics/frames.
- Optional Docker setup for a reproducible environment.
Note on dependencies: the project uses liboctomap and octomap_msgs directly and does not rely on octomap_ros or octomap_server. The Docker image and package manifest have been trimmed accordingly.
- Incremental pose graph with GTSAM iSAM2 (prior + between factors).
- Transforms incoming point clouds into
mapframe via TF2 and aggregates them. - Publishes odometry as
nav_msgs/Odometry. - Collision check service to test if a sphere intersects the current map.
catkin_ws/src/barracuda_mapping/src/slam_node.cpp: Main node implementation.launch/gtsam_slam.launch: Launches the node and loads parameters.config/gtsam_params.yaml: Default parameters (topics, frames, output topic).srv/CheckCollision.srv: Service definition for collision checking.CMakeLists.txt,package.xml: Build and dependencies.
Dockerfile,docker-compose.yml,entrypoint.sh: Containerized build/run.
- Build and run with docker compose:
docker compose up --build
This starts a container, builds the catkin workspace, sources the environment, and launches gtsam_slam.launch.
Notes:
- The compose file uses
network_mode: hostto expose ROS topics directly. - An NVIDIA GPU is reserved in the compose file, but the node itself does not require GPU.
The launch file loads defaults from config/gtsam_params.yaml.
All parameters are loaded into the node’s private namespace via the launch file.
pointcloud_topics(list|string): Input point cloud topic(s). Example:- List:
["left_camera/zed_point_cloud"] - Single string also supported. Falls back to
/pointsif unset.
- List:
odometry_topic(string): Output odometry topic. Default:slam/odometry.map_frame(string): Map/world frame. Default:map.base_frame(string): Robot base frame. Default:base_link(overridden tobarracuda/base_linkin the YAML).octomap_resolution(double): OcTree resolution in meters per voxel. Default:0.25.downsample_enabled(bool): Enable VoxelGrid downsampling before OctoMap insertion. Default:true.downsample_leaf_size(double): VoxelGrid leaf size in meters. Defaults tooctomap_resolutionif unset. Default:0.25in the provided YAML.
See config/gtsam_params.yaml for an example configuration.
- Subscribed point cloud(s): from
~pointcloud_topics(e.g.,left_camera/zed_point_cloud). - Published odometry:
~odometry_topic(defaultslam/odometry) asnav_msgs/Odometry. - Service:
check_collision(barracuda_mapping/CheckCollision)- Request:
geometry_msgs/Point center,float64 radius - Response:
bool collision
- Request:
- Published OctoMap (for RViz):
octomap_full(octomap_msgs/Octomap): Full map message (latched).octomap_binary(octomap_msgs/Octomap): Binary map message (latched).
Example service call:
rosservice call /check_collision "center: {x: 0.0, y: 0.0, z: 0.0} radius: 0.5"
The node looks up TF from each cloud’s frame_id to map_frame at the message timestamp, and falls back to the latest available transform when necessary. Make sure your TF tree publishes map_frame -> ... -> <cloud frame> and map_frame -> base_frame as appropriate.
- Pose graph: starts with a prior at index 0, then adds a
BetweenFactorbetween the last pose and the current TF-derived pose, updating iSAM2 incrementally. - Map growth: transformed (optionally downsampled) points are appended to a single
pcl::PointCloud<pcl::PointXYZ>. There is no loop‑closure map correction in this minimal example. - Namespacing:
odometry_topicwithout a leading/resolves relative to the node namespace (in the launch file it runs underns="barracuda").
- Edit
config/gtsam_params.yamlto change input topics and frames. - Pass per‑launch overrides with
<param>tags in a custom launch file. - Add filtering/downsampling or loop‑closure logic to
src/slam_node.cppas needed.
- No odometry output: verify TF is available between cloud frames and
map_frame. - No point clouds received: confirm
~pointcloud_topicsmatches actual topic names. - CMake cannot find octomap: ensure
liboctomap-devis installed in your environment. In Docker this is preinstalled; for native builds on Ubuntu 20.04/ROS Noetic:sudo apt-get install liboctomap-dev ros-noetic-octomap-msgs.
- RViz: Add an
Octomapdisplay and set Topic to/barracuda/octomap_fullor/barracuda/octomap_binary. Fixed Frame should match yourmap_frame(defaultmap). - Note:
octomap_serveris not required here since the node publishesoctomap_msgs/Octomapdirectly, which RViz can visualize without conversion.
If you prefer building outside Docker on Ubuntu 20.04 with ROS Noetic:
- Install deps:
sudo apt-get update && sudo apt-get install -y build-essential libgtsam-dev liboctomap-dev ros-noetic-octomap-msgs ros-noetic-pcl-ros ros-noetic-tf2-eigen ros-noetic-tf2-sensor-msgs - Build:
cd catkin_ws && source /opt/ros/noetic/setup.bash && catkin_make - Source:
source devel/setup.bash