File Exchange

image thumbnail

Implement Simultaneous Localization and Mapping (SLAM) with

version (113 KB) by Mihir Acharya
Develop a map of an environment and localize the pose of a robot for autonomous navigation.


Updated 16 Nov 2018

View Version History

View License

Develop a map of an environment and localize the pose of a robot or a self-driving car for autonomous navigation using Robotics System Toolbox™.
The robot needs to be driven manually when it obtains the LiDAR scans of the environment. On running this code, you can obtain a map of the environment and the pose of the robot relative to the map. This could be further used with commands like buildMap to generate an occupancy grid and perform path planning for autonomous navigation.
Watch the overview video for this functionality here:

Cite As

Mihir Acharya (2021). Implement Simultaneous Localization and Mapping (SLAM) with (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

catherine wangari

if you are getting an error related to " robotics.LidarSLAM ". Try to install the navigation toolbox in matlab. That worked for me.

博白 赵

Thanks for the code. And I have a small question that how to import or load the occupancy map into Simulink for indoor localization?


Where is " robotics.LidarSLAM "

Harry Chang

Thanks for the code - Though it's not a big thing, I have a small suggestion.
In the code you've used 'mapResolotion'. It may be a small typo so maybe we can use 'mapResolution'.

Minh Nhat Vu

I have a text file with over 250000 point of rplidar A1 scan. How can I create a MAT file like the offlineSLAMData

Minh Nhat Vu

Can i directly connect the RPlidar to matlab and perfrom scan to create a map

Mihir Acharya

Hello Hammia,
This error occurs when MAT file for offlineSLAMData is not found at the path specified in the code. I have updated the zip file with the required MAT file in the zipped folder and changed the code to read it from there. While the new zip file is getting ready and published, you can try following ways to resolve this error -
1) From the first line of the code. try removing 'data' from the path. Or, if you have access to the MAT file, try loading it from command window using load('offlineSlamData.mat'); and comment out the first two lines in the code which is giving the error.
2) Try running the code from command window by typing - openExample('robotics/OfflineSLAMExample')
Once you run this command, the current folder on the left side in MATLAB will change to the path where the offlineSLAMData is stored.
you can also refer the documentation page for this example here -
Let me know if this doesn't work.


I tried to run the program but it gives me the following error:
Error using load
Unable to read file 'data\offlineSlamData.mat'. No such file or directory.
Error in SLAM_implementation (line 4)

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!