Visual SLAM and localization package for autonomous robot navigation. This package provides RTAB-Map based visual SLAM using single or dual Intel RealSense cameras, or Lidar for robust robot localization, mapping, and autonomous navigation support.
The bot_localization package serves as the core localization system for the BotBrain robot platform. It manages:
- Visual SLAM (Simultaneous Localization and Mapping) using RTAB-Map
- Single/Dual RealSense camera or Lidar integration
- Map building and localization modes
- Transform chain management (map → odom → base_link)
- 2D occupancy grid generation for navigation
Main localization system launcher that orchestrates all SLAM and perception components.
Description: Master launch file that brings up the complete vision-based localization system. This file is the entry point for all localization functionality and includes multiple sub-launch files.
What Gets Launched:
This launch file includes the following sub-launch files in sequence:
- realsense.launch.py: Camera drivers and depth processing
- rtabmap.launch.py: RTAB-Map SLAM system
- rtab_manager.launch.py: RTAB-Map services management
- map_odom.launch.py: Map-to-odometry transform publisher
Launch Arguments:
None - Configuration read from workspace robot_config.yaml and {robot_model}_pkg/config/camera_config.yaml
Usage:
# Launch complete localization system
ros2 launch bot_localization localization.launch.py
Intel RealSense camera drivers and depth-to-laser conversion launcher.
Description: Dynamically configures and launches Intel RealSense camera nodes based on camera configuration. Creates camera drivers, static TF publishers, and depth-to-laserscan converters for obstacle detection.
What Gets Launched:
The launch file reads {robot_model}_pkg/config/camera_config.yaml and launches:
For each configured camera (front/back):
- RealSense camera node (LifecycleNode):
realsense2_camera_node - Static TF publisher: Publishes camera-to-base transform
- Based on
tfparameters in camera_config.yaml (x, y, z, roll, pitch, yaw)
- Based on
- depth_to_laserscan node: Converts depth image to 2D laser scan
Additional nodes:
- realsense_compressed_node (LifecycleNode): Compresses RealSense topics for bandwidth optimization
Configuration Source:
- Robot namespace from
robot_config.yaml - Camera configuration from
{robot_model}_pkg/config/camera_config.yaml- Camera types (d435i, d455, etc.)
- Serial numbers for device identification
- TF transforms (position and orientation)
Example Configuration:
camera_configuration:
front:
type: "d435i"
serial_number: "123456789"
parent_frame: "botbrain_base"
child_frame: "front_camera_link"
tf: {x: 0.08, y: 0.0175, z: 0.043, roll: 0, pitch: 0, yaw: 0}
back:
type: "d435i"
serial_number: "987654321"
parent_frame: "botbrain_base"
child_frame: "back_camera_link"
tf: {x: -0.08, y: -0.0175, z: 0.043, roll: 0, pitch: 0, yaw: 3.14159}Map-to-base_link pose publisher for localization monitoring.
Description: Launches a lifecycle node that reads the TF transform from map to base_link and publishes it as a PoseStamped message on a topic.
What Gets Launched:
- map_odom_node (LifecycleNode):
map_odom.py- Reads TF transform from
maptobase_linkat 10Hz - Publishes the transform as a PoseStamped message on
titan/map_odomtopic - Useful for monitoring robot position in the map frame
- Reads TF transform from
Parameters:
| Parameter | Type | Description |
|---|---|---|
prefix |
string | Namespace prefix for TF frames (e.g., "tita/") |
Topics Published:
map_odom(PoseStamped): Robot pose in map frame (position and orientation)
Note: This node does NOT publish TF transforms. It only publishes pose messages by reading existing TF data from RTAB-Map.
Dynamic RTAB-Map launcher that selects appropriate SLAM configuration.
Description: Intelligent launcher that reads camera/sensor configuration and includes the correct RTAB-Map launch file based on robot model and available sensors.
Selection Logic:
The launch file determines which RTAB-Map configuration to use:
-
If robot_model == "g1":
- Includes
rtabmap_lidar.launch.py - LiDAR-based SLAM for G1 humanoid robot
- Includes
-
If robot has cameras:
- 0 cameras: No RTAB-Map launched
- 1 camera (front OR back): Includes
rtabmap_single_camera.launch.py - 2 cameras (front AND back): Includes
rtabmap_double_camera.launch.py
Configuration Source:
- Reads
robot_config.yamlforrobot_modelandrobot_name - Reads
{robot_model}_pkg/config/camera_config.yamlto count cameras - Counts cameras based on
typefield presence infrontandbacksections
Included Launch Files:
rtabmap_single_camera.launch.py:
- RTAB-Map configured for single RGB-D camera
- Direct subscription to camera topics (no sync required)
- Topics:
front_camera/color/image_raw,front_camera/aligned_depth_to_color/image_raw
rtabmap_double_camera.launch.py:
- RTAB-Map configured for dual RGB-D cameras
- Includes two
rgbd_syncnodes for front and back cameras - RTAB-Map subscribes to synchronized
rgbd_image0andrgbd_image1 - Parameters:
rgbd_cameras: 2,subscribe_rgbd: True
rtabmap_lidar.launch.py (G1 robot only):
- RTAB-Map configured for 3D LiDAR SLAM
- Includes
lidar_deskewingnode for motion compensation - ICP-based registration with point-to-plane matching
- Subscribes to
/{namespace}/pointcloudtopic
RTAB-Map Common Configuration:
All RTAB-Map variants share these settings:
Localization Mode (not mapping):
Mem/IncrementalMemory: False: Localization only, no new map creationMem/InitWMWithAllNodes: True: Load full map into memorydatabase_path:{robot_model}_pkg/maps/rtabmap.dbdelete_db_on_start: False: Preserve existing map
2D SLAM Parameters (camera-based):
Reg/Force3DoF: true: Constrain to ground plane (x, y, yaw)Grid/3D: false: Generate 2D occupancy gridGrid/RangeMax: 3.0m: Maximum obstacle detection rangeGrid/CellSize: 0.10m: 10cm grid resolutionGrid/MaxGroundHeight: 0.05m: Ground plane toleranceGrid/MaxObstacleHeight: 0.8m: Maximum obstacle height
Frame Configuration:
frame_id:{prefix}base_linkmap_frame_id:{prefix}mapodom_frame_id:{prefix}odom
RTAB-Map lifecycle state manager for mapping/localization mode control.
Description: Launches a lifecycle node that provides services to manage RTAB-Map operation modes and database state.
What Gets Launched:
- rtab_manager (LifecycleNode):
rtab_manager.py- Manages RTAB-Map lifecycle transitions
- Provides services to reset map, switch modes, save/load databases
- Monitors RTAB-Map node health
Parameters:
| Parameter | Type | Description |
|---|---|---|
robot_model |
string | Robot model name for database path resolution |
Services Provided:
Services for controlling RTAB-Map operation (implementation-dependent):
- Reset database
- Switch between mapping and localization modes
- Save/load map databases
- Trigger map optimization
Lifecycle node that manages map-to-odom transform publishing:
Functionality:
- Listens to RTAB-Map pose estimates
- Computes map → odom transform from map → base_link
- Publishes transform at 20Hz for smooth navigation
- Handles lifecycle transitions (configure/activate/deactivate)
Topics:
- Subscribes:
/{namespace}/rtabmap/localization_pose(PoseStamped) - Publishes:
/tf(TFMessage) - map → odom transform
The package reads from workspace-level robot_config.yaml:
robot_configuration:
robot_name: "my_robot" # Namespace for all topics
robot_model: "go2" # Robot model
d435i_serial_number: "" # Rear camera serial
d455_serial_number: "" # Front camera serial/{namespace}/rtabmap/grid_map(OccupancyGrid) - 2D map for navigation/{namespace}/rtabmap/cloud_map(PointCloud2) - 3D point cloud map/{namespace}/rtabmap/localization_pose(PoseStamped) - Robot pose in map/{namespace}/rtabmap/mapData(MapData) - SLAM map data/tf(TFMessage) - map → odom transform
/{namespace}/d455/color/image_raw(Image) - Front camera RGB/{namespace}/d455/depth/image_rect_raw(Image) - Front depth/{namespace}/d435i/color/image_raw(Image) - Rear camera RGB/{namespace}/d435i/depth/image_rect_raw(Image) - Rear depth/{namespace}/d435i/imu(Imu) - IMU data from D435i
/{namespace}/rtabmap/reset_session- Start new mapping session/{namespace}/rtabmap/save_map- Save current map to database/{namespace}/rtabmap/load_map- Load map from database/{namespace}/rtabmap/pause- Pause SLAM processing/{namespace}/rtabmap/resume- Resume SLAM processing
/{namespace}/start_mapping- Start mapping mode (creates new map)/{namespace}/stop_mapping- Stop mapping and save database
- Start Mapping Session:
ros2 launch bot_localization localization.launch.py
ros2 service call /{namespace}/start_mapping bot_custom_interfaces/srv/StartMapping-
Drive Robot: Teleoperate robot through environment
- Cover all areas to be mapped
- Ensure good lighting and visual features
- Move slowly for better feature tracking
-
Save Map:
ros2 service call /{namespace}/stop_mapping bot_custom_interfaces/srv/StopMapping- Database Saved: Map database saved to configured path
- Configure Launch File: Set database path to existing map
- Launch Localization:
ros2 launch bot_localization localization.launch.py- Initial Pose: Robot may need initial pose hint if far from map origin
- Automatic Localization: RTAB-Map automatically localizes using visual features
bot_localization/
├── bot_localization/ # Main package directory
│ ├── bot_localization/ # Python package
│ │ └── __init__.py # Package initialization
│ ├── launch/
│ │ ├── localization.launch.py # Main launcher (orchestrates all components)
│ │ ├── realsense.launch.py # Camera drivers and depth processing
│ │ ├── map_odom.launch.py # Pose publisher node
│ │ ├── rtabmap.launch.py # Dynamic RTAB-Map launcher (selector)
│ │ ├── rtabmap_single_camera.launch.py # Single camera RTAB-Map configuration
│ │ ├── rtabmap_double_camera.launch.py # Dual camera RTAB-Map configuration
│ │ ├── rtabmap_lidar.launch.py # LiDAR RTAB-Map configuration (G1)
│ │ └── rtab_manager.launch.py # RTAB-Map lifecycle manager
│ ├── scripts/
│ │ ├── map_odom.py # Map-to-base_link pose publisher
│ │ ├── rtab_manager.py # RTAB-Map manager node
│ │ └── compressed_realsense.py # RealSense compression node
│ ├── CMakeLists.txt # Build configuration
│ ├── package.xml # Package manifest
│ └── README.md # This file
├── bot_localization_interfaces/ # Custom service/message interfaces
│ ├── srv/ # Service definitions
│ ├── CMakeLists.txt # Interface build config
│ └── package.xml # Interface package manifest
└── README.md # Top-level README
Made with ❤️ in Brazil