SLAM
Before reading the documentation of this section, it is highly advised to go through the entire ROS2 Humble tutorial which is available using this link: Tutorials — ROS 2 Documentation: Humble documentation.
The software usedinterface for the rovercamera is:is provided through the realsense-ros ROS2 wrapper package realsenseai/realsense-ros: ROS Wrapper for RealSense™ Cameras., Itwhich enables integration of the camera with the ROS 2 ecosystem. This repository has been cloned and is one ofinto the packages/submodules of the workspace. The other repository that has been clonedworkspace and is nowincluded anotheras packagea inpackage. Additionally, the workspacelibrealsense isSDK realsenseai/librealsense: RealSense SDK, which provides the low-level drivers and APIs for the camera—is also included as a separate package.
The primary package responsible for SLAM (Simultaneous Localization and Mapping) and map generation is rtt_slam. Within this package, all required dependencies are declared in the package.xml file, ensuring proper integration with the rest of the ROS 2 system.
Launch File Documentation
The launch file defines and orchestrates all nodes and processes required for perception, SLAM, and data streaming. It ensures proper initialization order and parameter configuration.
Database Reset:
ExecuteProcess(
cmd=['rm', '-r', os.path.expanduser('~/.ros/rtabmap.db')],
output='screen',
)
Before starting SLAM, any previously stored map database is deleted. This ensures that mapping starts from a clean state and avoids conflicts with prior runs.
Realsense Camera Launch:
The launch file is included with specific parameters:
- IMU enabled (
enable_gyro,enable_accel) - IMU fusion (
unite_imu_method=2) - Depth aligned to RGB (
align_depth.enable=True) - RGB-D output enabled
- Point cloud generation enabled
- Synchronization enabled (
enable_sync=True) - Matching RGB and depth resolutions (
424×240 @ 30Hz)
This configuration ensures consistent and synchronized sensor data for downstream processing.
IMU Filtering:
Node(
package='imu_filter_madgwick',
executable='imu_filter_madgwick_node',
)
The imu_filter_madgwick ROS package node processes raw IMU data:
- Converts raw IMU data into a filtered orientation estimate
- Uses the Madgwick filter algorithm
- Magnetometer is disabled (
use_mag=False) - Outputs orientation in the ENU (East-North-Up) frame
Topic remapping ensures compatibility with RealSense IMU topics.
RTAB-MAP SLAM
The SLAM system is launched via:
- rtabmap
Key configurations:
- Subscribes to RGB, depth, camera info, and IMU topics
- Uses approximate time synchronization (
approx_sync=True) - Sets
base_linkas the robot reference frame - Enables occupancy grid generation from depth data
Important grid parameters:
Grid/RangeMax: 2.0 m (maximum sensing range)Grid/RangeMin: 0.05 m (minimum sensing range)Grid/CellSize: 0.02 m (map resolution)- Voxel filtering enabled
This setup enables real-time 3D mapping and localization.
Static Transform
Node(
package='tf2_ros',
executable='static_transform_publisher',
)
A static transform is published between:
base_link(robot frame)camera_link(camera frame)
This defines the spatial relationship between the robot and the sensor. This is necessary as the default TF-tree is not compatible with Nav2.
Video Streaming to Basestation
ExecuteProcess(
cmd=['/bin/bash', os.path.expanduser('~/stream.sh')],
)
A separate script (stream.sh) is executed to stream camera data to the base station.
Streaming Script Documentation
This script uses GStreamer to transmit video over UDP.
Paragraph Breakdown:
rosimagesrc ros-topic="/camera/camera/color/image_raw"
Captures image directly from a ROS topic.
videoconvert ! video/x-raw,format=I420
Converts image format for encoder compatibility
x264enc tune=zerolatency speed-preset=superfast
Encodes video using H.264 with low-latency settings
rtph264pay pt=96
Packages encoded video into RTP packets
udpsink host=145.126.xx.XXX port=4500
Sends the stream to the base station via UDP