Roban2 Docs
Roban2 (ROS1) Legacy VersionsFeature ExamplesIntegrated Examples

Robot Open-Source Navigation Case

This is a SLAM (Simultaneous Localization and Mapping) and navigation system based on ROS1

System Architecture

The system integrates the following main components:

  • Livox ros driver2 - ROS driver for the Livox-MID360 LiDAR
  • FAST-LIO - LiDAR-inertial odometry algorithm and 3D point cloud map building
  • Octomap Server - 2D occupancy grid map building
  • Move Base - ROS navigation framework
  • Map Manager - Map and task point management service
  • Foxglove Bridge - Visualization bridge tool

API Documentation: API

Container Usage

If your system is not Ubuntu 20, we recommend using SLAM in a container.

We provide a Docker image that includes the build and runtime environment for SLAM. You can enter the container by running the following command:

exp1 # 如果是 VNCViewer 先执行改命令
./docker/run.sh

The subsequent build and launch commands can all be executed inside the container.

Quick Start

0. Preparation

Configure the static IP of the host computer and the IP of the LiDAR. Refer to LiDAR Configuration.

1. Building the Map

Use the following command to start map building:

source devel/setup.zsh
# source devel/setup.bash # 如果是 bash 
roslaunch kuavo_mapping build_map.launch

Main Parameters:

  • pointcloud_min_z / pointcloud_max_z: Point cloud Z-axis filtering range (default: -0.5 to 0.5)
  • occupancy_min_z / occupancy_max_z: Occupancy grid Z-axis range (default: -0.5 to 0.5)
  • sensor_model/min_range / sensor_model/max_range: Sensor effective range (default: 0.5 to 10.0 m)
  • crop_box: Whether to enable point cloud cropping (default: false)
  • foxglove: Whether to launch Foxglove visualization (default: false)

Nodes Launched:

  1. clear_pcd.sh - Clears previous PCD files
  2. livox_ros_driver2 - MID360 LiDAR driver
  3. pointcloud_to_laserscan - Converts point clouds to laser scan data
  4. fast_lio - LiDAR-inertial odometry
  5. octomap_server - 2D map building server

Point Cloud Filtering Configuration

The system supports point cloud cropping and filtering (CropBox), which is used to filter out unneeded point cloud data and improve mapping quality and system performance. The configuration file is located at kuavo_mapping/config/mid360_filter.yaml:

# CropBox Configuration for FAST-LIO
crop_box:
  enable: true              # 启用点云裁剪过滤
  negative: true            # 负向过滤(保留框外数据,过滤框内数据)
  
  # 定义边界框(世界坐标系,单位:米)
  # 当前配置:机器人周围1.5米范围内的点云
  min_x: 1.5                # X轴最小值
  max_x: -1.5               # X轴最大值
  min_y: -1.5               # Y轴最小值  
  max_y: 1.5                # Y轴最大值
  min_z: -0.05              # Z轴最小值(地面高度)
  max_z: 0.05               # Z轴最大值(高度限制)

Configuration Notes:

  • enable: Enables or disables the point cloud cropping function
  • negative: Filtering mode
    • true: Negative filtering, which filters out point clouds inside the bounding box and keeps those outside
    • false: Positive filtering, which keeps point clouds inside the bounding box and filters out those outside
  • Coordinate range: The bounding box is defined in the world coordinate system (odom frame)
  • Unit: All coordinate values are in meters

Mapping Precautions

During mapping, the robot's LiDAR must be level with the ground. If it is tilted, the point cloud data will not be aligned with the horizontal ground, and ground points will be treated as obstacles, causing mapping to fail.

It is recommended to position the robot's head motors first, then put the robot program into cali_arm mode to enable the head motors (they will not wobble once enabled), and then start mapping.

Environment Requirements:

  • Personnel position: During mapping, the user should stand behind the robot to avoid blocking the LiDAR's field of view
  • Dynamic objects: Ensure there are no dynamic objects in the environment (such as people, vehicles, animals, etc.)
  • Static environment: The environment should remain relatively static during mapping

Impact:

  • 3D map noise: Dynamic objects produce noise in the 3D point cloud map, affecting global localization accuracy
  • 2D map anomalies: Dynamic objects create occupancy cells that should not exist in the 2D grid map, affecting path planning
  • Localization accuracy: Dynamic interference in the environment reduces the localization accuracy of the SLAM algorithm

Recommendations:

  • Choose a time with low foot traffic for mapping
  • Clear temporary obstacles from the environment before mapping
  • Keep the environment stable during mapping
  • If someone must be present, make sure they stay away from the LiDAR's scanning range

2. Saving the Map

After map building is complete, run the save script:

source devel/setup.zsh
# source devel/setup.bash # 如果是 bash
rosrun kuavo_mapping save_map.sh

The script will:

  • Save the 2D grid map and 3D point cloud map to the ~/maps/ directory
  • Name the files using timestamps

3. Map Editing

The system integrates a PyQt5-based map editor for post-processing and optimizing the generated 2D grid map.

Launching the Map Editor

cd <kuavo_ros_application>/src/kuavo_slam_ws/src/ros_map_editor
python MapEditor.py ~/maps/map_YYYY-MM-DD_HH-MM-SS

Editor Features

1. Basic Operations

  • Zoom control: Supports five zoom levels: 100%, 200%, 400%, 800%, and 1600%
  • Live preview: The thumbnail at the bottom shows the current viewport position
  • File information: Displays the map file name, size, resolution, and other information

2. Editing Modes

  • Occupied: Marks the area as an obstacle (black); the robot cannot pass through
  • Unoccupied: Marks the area as passable (white); the robot can pass safely

3. Brush Sizes

  • 1x1: Single-pixel editing, suitable for fine adjustments
  • 3x3: 3x3-pixel area editing, suitable for small modifications
  • 5x5: 5x5-pixel area editing, suitable for medium modifications
  • 7x7: 7x7-pixel area editing, suitable for large modifications
  • 9x9: 9x9-pixel area editing, suitable for extensive modifications

4. Editing Methods

  • Click to edit: Click anywhere on the map to edit
  • Drag to edit: Hold down the left mouse button and drag for continuous editing
  • Live update: The display and data update immediately after editing

Editing Use Cases

1. Map cleanup

  • Remove obstacles falsely detected by sensors
  • Clean up noise produced by dynamic objects during mapping
  • Correct erroneous occupied areas produced by the SLAM algorithm

2. Restricted area marking

  • Mark areas the robot must not enter (such as ponds, flower beds, hazardous areas, etc.)
  • Set virtual boundaries and restricted zones
  • Define the robot's activity range

3. Path optimization

  • Clean up abnormal occupied areas that affect path planning
  • Optimize the passability of narrow passages
  • Adjust the passability of key nodes

Saving Editing Results

After editing, click the Save button to save your changes:

  • The editor displays a message indicating whether saving succeeded or failed
  • Changes are saved directly to the original PGM file
  • It is recommended to back up the original map file before editing

Editing Precautions

1. Data consistency

  • The editor modifies the PGM file directly, ensuring compatibility with the ROS navigation system
  • The modified map can be used by the navigation system immediately
  • It is recommended to stop the navigation system before editing to avoid data conflicts

2. Editing precision

  • Choose an appropriate brush size based on the map resolution
  • For high-resolution maps, use smaller brushes for fine editing
  • For low-resolution maps, use larger brushes for quick editing

3. Backup recommendations

  • Back up the original map file before editing
  • Record important editing operations for future maintenance
  • Save your editing progress regularly to avoid data loss

Image Examples

✍️ Before editing

Before editing

✍️ After editing

After editing

4. Enabling the Navigation System

Launching the Navigation System

source devel/setup.zsh
# source devel/setup.bash # 如果是 bash 
roslaunch kuavo_navigation kuavo_navigation.launch map:=map_YYYY-MM-DD_HH-MM-SS

Main Parameters:

  • base_local_planner: Local path planner (dwa_local_planner or mpc_local_planner; default: mpc_local_planner)

  • map: Map file path

  • foxglove: Whether to launch the Foxglove bridge (default: false)

  • odom_source: Odometry source (default: lidar)

    • robot: Use the robot's odometry
    • lidar: Use LiDAR odometry
  • crop_box: Whether to enable point cloud cropping (default: false)

  • odom_source:=robot: Uses the odometry estimated from the robot IMU and uses base_link as the robot base frame

  • odom_source:=lidar: Uses LiDAR odometry and uses lio_base_link as the robot base frame

Nodes Launched:

  1. move_base - Navigation core node
  2. global_localization - Global localization node
  3. load_map - Map loading
  4. map_manager - Map and task point management service

Global Localization

After the navigation system starts, global localization is required to determine the robot's position in the map:

Method 1: Localize using RViz

  1. Launch RViz: rviz
  2. Add Map, PointCloud2, and PoseWithCovarianceStamped displays
  3. Click the 2D Pose Estimate button, then set the robot's initial position and orientation on the map

Method 2: Localize using Foxglove

  1. Connect to the ROS1 Bridge in Foxglove Studio
  2. Add map and point cloud displays
  3. Use the pose estimation tool to set the initial position

Method 3: Localization based on task points Use the /initialpose_with_taskpoint topic to localize by task point name:

  • The system looks up the corresponding task point position based on the task point name
  • The task point position is automatically forwarded to the /initialpose topic for global localization
  • Suitable for quick localization when the task point position is known
# 通过任务点名称进行定位(只需要传任务点名称)
rostopic pub /initialpose_with_taskpoint std_msgs/String "data: 'task1'"
  1. Sending a navigation goal using RViz:

    • Click the 2D Nav Goal button in RViz
    • Click the target position on the map and drag to set the orientation
  2. Sending a navigation goal using Foxglove:

    • Use the navigation goal tool in Foxglove Studio
    • Set the target position and orientation
  3. Navigating to a task point using a service call:

    rosservice call /navigate_to_task_point "task_name: 'task1'"

Map Manager Service Interfaces

The navigation system integrates Map Manager, which provides the following service interfaces:

1. Map Management Services

  • load_map (kuavo_mapping/LoadMap)

    • Input: string map_name - Map name
    • Output: bool success - Load status, string message - Status message
  • get_current_map (kuavo_mapping/GetCurrentMap)

    • Input: none
    • Output: string current_map - Name of the currently loaded map
  • get_all_maps (kuavo_mapping/GetAllMaps)

    • Input: none
    • Output: string[] maps - List of all available map names

2. Task Point Management Services

  • task_point (kuavo_mapping/TaskPointOperation)

    • Operation type constants:
      • ADD=0 - Add a task point
      • UPDATE=1 - Update a task point
      • DELETE=2 - Delete a task point
      • GET=3 - Get all task points
    • Input:
      • int8 operation - Operation type
      • kuavo_mapping/TaskPoint task_point - Pose information of the task point
      • string name - Task point name
      • bool use_robot_current_pose - Whether to use the robot's current position
    • Output:
      • bool success - Operation status
      • string message - Status message
      • kuavo_mapping/TaskPoint[] task_points - List of task points (returned for GET operations)
  • navigate_to_task_point (kuavo_mapping/NavigateToTaskPoint)

    • Input: string task_name - Task point name
    • Output: bool success - Navigation start status, string message - Status message

Task points are published on the /task_points_markers topic for visualization.

5. Data Playback and Analysis

kuavo_navigation integrates rosbag recording and playback. During navigation, navigation data is automatically recorded to the ~/maps/ directory and a .bag file is generated.

Playing Back Navigation Data

Use the playback launch file provided by the system to play back data:

roslaunch kuavo_navigation replay_navigation.launch bag_file:=20250703_060014.bag

Playback Parameters

  • bag_file: rosbag file name (located in the ~/maps/ directory)

Playback Features

  1. Time synchronization: Automatically publishes clock information to ensure all nodes use a unified time reference
  2. Visualization: Integrates RViz display, supporting visualization of the map, point cloud, trajectory, etc.
  3. Playback control: Supports pause, resume, speed adjustment, and other playback controls
  4. Data integrity: Preserves the integrity and temporal relationships of the original data

Playback Use Cases

1. Navigation performance analysis

  • Analyze path planning performance
  • Evaluate localization accuracy
  • Check obstacle avoidance behavior

2. Problem debugging

  • Reproduce navigation anomalies
  • Analyze sensor data
  • Verify the effect of algorithm improvements

3. System validation

  • Verify the effect of parameter tuning
  • Test new features
  • Performance benchmarking

Playback Precautions

  1. File path: Make sure the rosbag file is located in the ~/maps/ directory
  2. Resource usage: Pay attention to system resource usage when playing back large amounts of data
  3. Data compatibility: Make sure the played-back data is compatible with the current system version

Configuration

Sensor Configuration

The system is optimized and configured for the Livox MID360 LiDAR:

  • Point cloud filtering parameters are in kuavo_mapping/config/mid360_filter.yaml
  • Navigation parameters are in the kuavo_navigation/config/ directory

File Structure

kuavo_slam_ws/
├── src/
│   ├── kuavo_mapping/
│   │   ├── launch/
│   │   │   ├── build_map.launch      # Map building launch file
│   │   │   └── load_map.launch       # Map loading launch file
│   │   ├── scripts/
│   │   │   ├── save_map.sh           # Map saving script
│   │   │   └── map_manager.py        # Map manager
│   │   └── config/
│   │       └── mid360_filter.yaml    # Sensor filter configuration
│   ├── kuavo_navigation/
│   │   ├── launch/
│   │   │   ├── kuavo_navigation.launch  # Navigation launch file
│   │   │   └── replay_navigation.launch # Data replay launch file
│   │   └── config/                   # Navigation configuration files
│   └── ros_map_editor/               # Map editor
│       ├── MapEditor.py              # Main program file
│       ├── UI_MapEditor.ui           # Qt Designer UI file
│       ├── ui_map_editor.py          # Generated UI Python module
│       └── README.md                 # Editor documentation
└── README.md

Precautions

  1. Map saving: Make sure map construction is complete before running the save script; otherwise the PCD file may not exist
  2. Coordinate frames: Simulation and real-robot modes use different coordinate frames; choose according to your actual setup
  3. Parameter tuning: Adjust the point cloud filtering and sensor range parameters according to the actual environment
  4. Visualization: Enabling Foxglove for real-time visualization and monitoring is recommended
  5. Global localization: Global localization must be performed before navigation to ensure the robot's position is accurate
  6. Waypoint management: The Map Manager service makes it easy to manage frequently used locations
  7. Map editing: Back up the original file before editing the map, and take care to maintain data consistency while editing
  8. Editing precision: Choose an appropriate brush size based on the map resolution to ensure the desired editing result

Troubleshooting

Common Issues

  1. PCD file does not exist: Check whether map construction has completed, and wait long enough for FAST-LIO to generate point cloud data
  2. Navigation failure: Check whether the map file path is correct, and make sure the coordinate frame configuration is correct
  3. Abnormal sensor data: Check the LiDAR connection and driver configuration
  4. Localization failure: Make sure global localization has been completed, and check whether the TF transforms are correct
  5. Waypoint operation failure: Check whether Map Manager is running properly and whether the database permissions are correct