# Simultaneous Localization and Mapping (SLAM)

Robot localization and mapping using a grid map and particle filter.

Canonical: https://aasmanbashyal.com.np/projects/slam

[Read paper (PDF)](https://aasmanbashyal.com.np/pdf/slam.pdf)

## Abstract

Simultaneous Localization and Mapping (SLAM) is a method used to numerically solve the problem of extracting a map and determining localization in an unknown environment for mobile robot navigation. It has been widely popular due to its broad range of applications in robotic systems.

Navigating in an unexplored environment is challenging. Various approaches have been developed for this problem, including probabilistic, feature-based, and graph-based methods. We use a grid-map based approach derived from Tiny SLAM, enhanced with a particle filter layer. This approach resulted in an improved map with fewer orientation errors and can handle greater robot motion speeds. However, the robot motion does not incorporate any control measures, resulting in errors in map updates due to inertial jerk.

## Introduction

### Navigation

Navigating in unknown environments presents a unique set of challenges, primarily related to localization and mapping. The localization challenge involves determining the precise position of an entity within an unfamiliar area, while the mapping challenge focuses on creating an accurate representation of the environment. Simultaneous Localization and Mapping (SLAM) offers an iterative solution to these challenges, continuously updating its understanding of both position and environment. However, the process is often complicated by errors in motion and measurements, which can significantly impact accuracy. To address this, a probabilistic approach is employed, allowing for a more robust and flexible response to the uncertainties inherent in navigating unknown spaces. This approach helps in making more informed decisions based on the likelihood of different scenarios, enhancing the overall effectiveness of the navigation system.

### TINY SLAM

TINY SLAM is a simple solution to the SLAM problem, designed for use on embedded platforms. It's quite small, with only about 200 lines of code, and is easy to understand.

### MAP (Occupancy Grid Map)

![Occupancy Grid Map](https://aasmanbashyal.com.np/img/slam/gridmap.webp)

Occupancy Grid Map

MAP is an Occupancy Grid Map used in navigation and mapping where each grid cell is assigned a probability. This probability, denoted as P(mi), represents the chance that the cell is not occupied. Initially, all grid cells are given a value of 0.5, indicating a neutral stance where it's equally likely for the cell to be occupied or unoccupied. This setup allows for a dynamic and probabilistic approach to understanding and mapping an environment.

### Particle Filter

The Particle Filter is a probabilistic method used to provide the best estimation in systems like SLAM . It involves a process called resampling, which helps in refining the accuracy of the estimation. In this approach, each 'particle' represents a possible state, and these particles are evaluated based on their likelihood or the probability of being correct. The most probable particles are then more likely to survive and be carried over to the next generation of estimations. This method significantly improves the performance of existing SLAM systems by continuously updating and refining the understanding of the environment based on the probability of different scenarios.

![Particle filter in action](https://aasmanbashyal.com.np/img/slam/bwpf.webp)

Particle filter in action

## Methodology

### System Block Diagram

![System Block Diagram](https://aasmanbashyal.com.np/img/slam/systemdiagram.webp)

### Flow diagram

![Flow diagram](https://aasmanbashyal.com.np/img/slam/messageflow.webp)
