Skip to content

About

ROS 2 Humble project for SLAM mapping and autonomous navigation with Nav2, AMCL, MPPI, and Stage.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

ROS 2 Mapping and Autonomous Navigation

University robotics project that builds a complete ROS 2 Humble workflow for mapping and autonomous navigation. The project converts recorded 3D LiDAR data into a 2D laser scan, creates an occupancy map with SLAM Toolbox, localizes a simulated AgileX Scout Mini with AMCL, and executes a sequence of navigation goals through Nav2.

Occupancy map generated with SLAM Toolbox

Highlights

  • 2D occupancy-grid mapping from recorded PointCloud2 data
  • Point-cloud conversion with pointcloud_to_laserscan
  • Localization with Adaptive Monte Carlo Localization (AMCL)
  • Nav2 planning and control with the MPPI controller
  • Stage simulation of an omnidirectional AgileX Scout Mini
  • Sequential waypoint execution through a ROS 2 C++ action client
  • Configurable launch files, frames, topics, maps, and goal files

System overview

flowchart LR
    A["Recorded /ugv/rslidar_points"] --> B["PointCloud2 to LaserScan"]
    B --> C["SLAM Toolbox"]
    J["Recorded odometry and TF"] --> C
    C --> D["Occupancy map"]
    D --> E["Stage simulation"]
    E --> F["AMCL localization"]
    F --> G["Nav2 planning and MPPI control"]
    H["CSV waypoints"] --> I["C++ goal publisher"]
    I --> G
Loading

Assignment and implementation

Project requirement Implementation
Build a map from recorded odometry, TF, and LiDAR data PointCloud2 conversion and SLAM Toolbox mapping launch pipeline
Simulate the assigned omnidirectional robot Custom AgileX Scout Mini model and world for Stage
Localize and navigate in the reconstructed map AMCL, Nav2 planning, MPPI control, costmaps, and recovery behaviors
Read x,y,theta goals from CSV and send them sequentially C++ NavigateToPose action client with rejection retries and result tracking
Provide task-specific visualization RViz configurations for map, TF, laser scan, AMCL particles, paths, and goals
Save the reconstructed and serialized map PGM/PNG/YAML map files and SLAM Toolbox pose graph artifacts

Repository structure

second_project/
|-- config/       # SLAM Toolbox, point-cloud conversion, and Nav2 parameters
|-- csv/          # Navigation waypoints
|-- launch/       # Mapping and navigation launch files
|-- map/          # Occupancy map and serialized SLAM pose graph
|-- rviz/         # RViz configurations
|-- src/          # C++ waypoint action client
`-- world/        # Stage simulation world and robot model
tools/
`-- map_processing/  # Offline map inspection and cleanup utilities

Original development environment

The project was developed and run inside the robotics course Docker environment. The image was based on ros:humble-perception; the colcon_ws workspace and rosbag directory were mounted from the host, and graphical applications such as RViz and Stage were forwarded from the container. Cyclone DDS was used as the ROS middleware implementation.

The course Docker image is not bundled in this repository. The package can be built inside the original environment or an equivalent ROS 2 Humble container with the dependencies below.

Requirements

  • Docker-based ROS 2 Humble environment, or a native ROS 2 Humble installation
  • colcon and rosdep
  • Nav2
  • SLAM Toolbox
  • pointcloud_to_laserscan
  • RViz 2
  • Cyclone DDS
  • stage_ros2_stageros
  • Python 3 and Pillow for the optional map-processing tools

Build

Clone the repository into the src directory of the container's ROS 2 workspace, install available dependencies, and build the package:

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone https://github.com/MasterPula/ros2-mapping-navigation.git
cd ~/ros2_ws
rosdep install --from-paths src --ignore-src -r -y
colcon build --symlink-install --packages-select second_project
source install/setup.bash

Some ROS 2 distributions may require stage_ros2_stageros to be installed from source.

Mapping workflow

The provided rosbag contained noisy odometry on /odom, a 3D point cloud on /ugv/rslidar_points, and transforms on /tf and /tf_static. Start SLAM Toolbox, convert the recorded point cloud to a laser scan, and optionally play the rosbag automatically:

ros2 launch second_project mapping.launch.py \
  play_bag:=true \
  bag_path:=/path/to/rosbag

The launch file can save the generated occupancy map when rosbag playback finishes. A pose graph can also be serialized manually:

ros2 service call /slam_toolbox/serialize_map \
  slam_toolbox/srv/SerializePoseGraph \
  "{filename: '/path/to/map'}"

Navigation workflow

Launch the omnidirectional Scout Mini model in Stage together with the map server, AMCL, Nav2 servers, RViz, and the waypoint publisher:

ros2 launch second_project navigation.launch.py

The goal_publisher node reads x, y, and theta values from second_project/csv/goals.csv. It sends each pose to the Nav2 NavigateToPose action server, waits for the result, retries rejected goals, and reports the final success/failure count.

Useful launch overrides include:

ros2 launch second_project navigation.launch.py \
  rviz:=false \
  stage_gui:=false \
  start_goals:=true \
  goals_file:=/path/to/goals.csv

Map-processing tools

The scripts in tools/map_processing/ were used to inspect, convert, clean, and validate the generated occupancy map. They are offline development utilities and are not required to run the ROS 2 package.

License

Licensed under the Apache License 2.0. See LICENSE.

About

ROS 2 Humble project for SLAM mapping and autonomous navigation with Nav2, AMCL, MPPI, and Stage.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages