This project implements a Simultaneous Localization and Mapping (SLAM) system using Lidar data in MATLAB. It processes laser scans to build an occupancy grid map, detect lines and corners, and optimize the robot’s trajectory using a pose graph with loop closure detection.
- Lidar Data Processing
- Reads and preprocesses raw Lidar scans from .mat files.
- Converts scans into world coordinates for mapping.
- Feature Extraction
- PCA-based line detection for extracting structured features.
- Corner detection for identifying key environmental points.
- Scan Matching (Fast and Brute-force methods) for pose estimation.
- Pose Graph Optimization to correct accumulated errors.
- Loop Closure Detection for reducing trajectory drift.
- Creates an occupancy grid to represent the environment.
- Updates map with detected lines and key scans.
- Real-time plotting of robot trajectory, scan points, and pose graph.
-
Main Files main.m: Entry point for executing the full SLAM pipeline. helperinitialization.m: Initializes map and SLAM parameters. helperreadframe.m" Reads and processes Lidar scan frames.
-
Core SLAM Components helperclassposegraph.m: Implements pose graph optimization. helperclassnode.m: Defines nodes (robot poses) in the pose graph. helperclassedge.m: Defines edges (constraints) between nodes. helperloopclosuredetect.m: Detects loop closures for correcting global map alignment.
-
Mapping & Feature Detection helperoccugridcreate.m: Creates an occupancy grid map from Lidar data. helpermapextractlocalmap.m: Extracts local map for scan matching. helpercornerdetection.m: Identifies corner points in the scan data.
-
Scan Matching & Transformation helpermatchingfast.m: Fast scan matching for quick pose estimation. helpermatchingbrute.m: Brute-force scan matching for refinement. helpertransformrobotworld.m: Transforms robot's local frame to world coordinates.
Prerequisites MATLAB (Recommended: R2018b or later).
Installation
- Clone the repository
- Open MATLAB and add the project folder to the path: addpath(genpath('path_to_project_folder'));
To execute the SLAM process, run: main
- Execution Time: The SLAM pipeline processes the dataset in ~55 - 60 seconds.
- Scan Matching Accuracy: Achieves 90% success rate in feature alignment.
- Mapping Precision: Captures key environmental structures with minimal drift.