File Exchange

image thumbnail

Ray Casting for Implementing Map based Localization in Mobile Robots

version 1.1 (58.8 KB) by

The code is an efficient implementation of ray casting used to obtain simulated range measurements.



View License

The code returns simulated range measurements for a robot with a range sensor placed in a known environment. It implements Ray Casting which is an important step for performing Map based localization in Mobile robots using state estimation algorithms such as Extended Kalman Filters, Particle Filters (Sequential Monte Carlo), Markov Localization etc.
The inputs to the castrays.m function are the Robot position, map of environment as logical matrix (Free space = 0, Obstacles = 1), Number of rays to cast, Range of LIDAR in cm.
The function can be used in performing simulations for Mobile robot Localization or for computing importance weights/Measurement probabilities for actual localization.

Comments and Ratings (10)

minzhen li

Would you please provide the script for running it ? thanks

Daiju Okamura

Very help full site. Thank-you Very much for your help.


thank you very much for the script. it is very useful but I need something more real timed. Could you please uplaod your new version? Thank you.


mustafa tanis

Whenever I try to run the code, I get "castrays requires more input arguments" error. I don't know how I can solve it


Chuck (view profile)


Whenever I try to run the code, I get "castrays requires more input arguments" error. I don't know how I can solve it.



Gloria (view profile)

Jong-Hwan Kim

Jong-Hwan Kim (view profile)

Hi could you upload your faster model? Thanks

Shikhar Shrestha

I have a new optimized version of this code which is much faster and runs almost real-time with a particle set of around 2000 particles. Its can precast on the sample map in 20 minutes at 1 pixel resolution. Do comment if anyone is interested and I will upload the file!



Corrected a minor error in the code. The upper bound of the for loop has to be n (number of scan lines).

MATLAB Release
MATLAB 7.10 (R2010a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today

Ray Casting for Robot Localization/