File Exchange

image thumbnail

2D Local Grid Map

version 1.0.0.0 (1.15 MB) by Alireza
This code is a Matlab implementation of 2D Local Grid Map

14 Downloads

Updated 31 Aug 2015

View License

In this experiment, L by L meters surrounding environment of a mobile robot is presented in the form of a grid. The data is acquired using a 2D laser range finder (LRF) mounted in front of a robot to scan horizontal plane. The 2D laser range finder provides 180 points per reading, 1 point per degree. Range data further than 40 meters is disregarded since it may contain false measurement caused by laser beam passing through glass or mirror reflection. Laser hitting points located inside the local grid are directly used for computing the local grid, and points outside the local grid (> 10m) and within the threshold (< 40m) are interpolated and points on the border of the local grid are used instead. The desired end points input to the Bresenham's line algorithm to indicate free and occupied cells. Bresenham's line algorithm determines which cells on the 2-dimensional grid should be selected to form a close approximation to a straight line between laser origin and end point. The end points on the boarder of the local grid map are used to determine free cells and end points positioned inside the grid are used to determine free and occupied cells. For having a consistent local map it is needed to continuously integrate a new local grid into the previous local grid map. This is done by rotation and translation of the previous grid map on the new computed grid. The difference between the robot poses in two consecutive frames is used to compute the transformation matrix. The odometry data provides robot's pose. The robot pose is defined by (x, y, \theta) where x and y are coordinates relative to some known start point and \theta is the robot's heading. After transformation, it is needed to update the map values. Free and occupancy counters are defined, and counter values are updated using Reflectation mapping policy: C = hit /(hit + miss). Where hit represents the number of times a beam ended in that cell while miss stands for the number of times a beam passed through that grid cell.
---------------------------------------------------------------
Inputs are: laser range data (L) and estimated odometry (X)
Output is: local occupancy grid map
The functions are:
init - initialize mapping
mp - build current local grid map from laser data
prc - load and pre-process data
shw - show grid map, laser points, robot locations, and current robot direction
trns - transform map t-1 on map t
upd - update current local map
---------------------------------------------------------------
The code runs on Linux/Windows with MATLAB R2013a
it needs "Piotr's Image&Video Toolbox Version 3.01" for transformation
a dataset "localized.data" is included so you can simply run Demo.m
The data used in this work comes from the robotics course by Dr. Mohan Sridharan
Here you can see the video result:
https://www.youtube.com/watch?v=FYkHxVOPGgA&index=1&list=PL3j0riEbsbtJKZ22PbRU7JeL3BlHz4UpH

Comments and Ratings (9)

Jack Chen

very good!

faiza gul

When I try to run it it does not work

Nice and short demo, also easy to run (if you read the instructions that say it needs Piotr's toolbox ;) )

I'm getting the following error when running demo file. Can you please resolve the issue.
----------------------------------------------------------------------->

Error using getPrmDflt (line 50)
prm must be a struct or a cell

Error in imtransform2 (line 69)
[method,bbox,show,pad,useCache,us,vs] =
getPrmDflt(varargin,dfs,1);

Error in trns (line 34)
mapt = imtransform2(map + 1, H,'nearest');
% transformation ( + 1! help us to find
indexes easier )

Error in init (line 22)
tmap = trns(map, X, i, i + st, gs); %
transform map t - 1 (on the map t)

Error in Demo_LocalMap (line 25)
[fc, oc] = init(i, X, Lx, Ly, trsh, gs,
sz, st); % initialize mapping

Alireza

You need "Piotr's Image&Video Toolbox Version 3.01" for transformation (imtransform2)

thanks for ur work but i cant find the function
mapt = imtransform2(map + 1, H, 'method', 'nearest');

Updates

1.0.0.0

link added

1.0.0.0

description

1.0.0.0

edit description

1.0.0.0

FX

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

Inspired by: Bresenham's Line