← Back to Blog
navigationamrslamnavigation

SLAM and Navigation: How Robots Self-Localize and Move

Learn how robots use SLAM for mapping, self-localization, and path planning with ROS 2 Nav2 stack.

Nguyen Anh Tuan1 tháng 7, 20253 min read
SLAM and Navigation: How Robots Self-Localize and Move

What is SLAM?

SLAM (Simultaneous Localization and Mapping) is a classic robotics problem: a robot must simultaneously build a map of its surrounding environment and determine its own position on that map. This is the foundation for autonomous robots to operate in previously unknown spaces.

This problem is difficult because two factors depend on each other — accurate localization requires a good map, but building a good map requires accurate localization.

Common SLAM Methods

LiDAR SLAM

Uses laser sensors to scan the environment in 2D or 3D. Common algorithms:

Visual SLAM

Requires only a camera, much cheaper than LiDAR:

Autonomous robot using SLAM for mapping and navigation

ROS 2 Nav2 Stack

Nav2 is a complete navigation system for ROS 2, encompassing the entire pipeline from SLAM to motion control.

Nav2 Architecture

Sensor Data → SLAM → Map
                       ↓
Goal Position → Planner → Controller → Motor Commands
                       ↑
                  Costmap (obstacle layer + inflation layer)

Basic Nav2 Configuration

The nav2_params.yaml file is the central configuration hub:

bt_navigator:
  ros__parameters:
    global_frame: map
    robot_base_frame: base_link
    default_bt_xml_filename: navigate_w_replanning_and_recovery.xml

controller_server:
  ros__parameters:
    controller_frequency: 20.0
    FollowPath:
      plugin: "dwb_core::DWBLocalPlanner"
      max_vel_x: 0.5
      min_vel_x: -0.1
      max_vel_theta: 1.0

Launch Nav2 with SLAM

# Start SLAM (create new map)
ros2 launch nav2_bringup slam_launch.py

# Or use saved map (localization mode)
ros2 launch nav2_bringup localization_launch.py map:=/path/to/map.yaml

# Start navigation
ros2 launch nav2_bringup navigation_launch.py

Costmap and Obstacle Avoidance

Nav2 uses costmap — a layered cost map for path decisions:

Each cell on the costmap has a value from 0 (free) to 254 (obstacle). The planner finds the path with the lowest total cost.

Sensor system and costmap for autonomous robot obstacle avoidance

Real-World Applications in Vietnam

Delivery robots in factories: Using RPLiDAR A2 (around 5 million VND) combined with Nav2 allows AMR robots to move between production stations, a core component of robot fleet management. Factory maps are usually stable, so SLAM only needs to run once, then switch to localization mode.

Restaurant service robots: Visual SLAM with Intel RealSense D435 camera significantly reduces hardware costs compared to LiDAR, suitable for environments with many moving people.

Practical Deployment Tips

  1. Choose appropriate sensor: LiDAR for industrial environments (high accuracy), camera for consumer applications (low cost)
  2. Calibrate carefully: The transform between sensor and base_link must be accurate; 1-2 cm error can cause serious drift
  3. Test recovery behaviors: Robots will get stuck — configure spin, backup, and wait recovery in the behavior tree
  4. Monitor with RViz2: Always visualize costmap and path planning when debugging

SLAM and navigation are two fundamental skills for any autonomous robot. With ROS 2 Nav2, you can deploy a complete navigation system without starting from scratch.

Related Articles

Related Posts

Multi-robot Coordination: Thuật toán phân công task
fleetamrprogramming

Multi-robot Coordination: Thuật toán phân công task

Các thuật toán phân công nhiệm vụ cho đội robot — từ Hungarian algorithm, auction-based đến RL-based task allocation.

20/3/202612 min read
Wheeled Humanoid: Tương lai robot logistics và warehouse
humanoidfleetamr

Wheeled Humanoid: Tương lai robot logistics và warehouse

Robot hình người trên bánh xe — tại sao thiết kế hybrid này đang thay đổi ngành logistics và vận hành kho hàng.

3/3/202611 min read
Deep DiveOutdoor Navigation và Multi-Robot Coordination
navigationmulti-robotoutdoormapfvda5050Part 5

Outdoor Navigation và Multi-Robot Coordination

GPS-denied navigation, terrain classification, multi-robot traffic management với VDA5050, và MAPF algorithms cho robot fleet.

20/2/202611 min read