File Exchange

image thumbnail

Mobile Robotics Simulation Toolbox

version 2.2 (8.31 MB) by MathWorks Student Competitions Team
MATLAB and Simulink utilities for vehicle kinematics, visualization, and sensor simulation.


Updated 15 Oct 2019

GitHub view license on GitHub

This toolbox provides utilities for robot simulation and algorithm development. This includes:

- 2D kinematic models for robot geometries such as differential drive, three, and four-wheeled vehicles, including forward and inverse kinematics
- Configurable lidar, object, and robot detector simulators
- Visualization of robotic vehicles and sensors in occupancy maps
- MATLAB and Simulink examples and documentation

Cite As

MathWorks Student Competitions Team (2020). Mobile Robotics Simulation Toolbox (, GitHub. Retrieved .

Comments and Ratings (52)

Tatyana Kim

Hello friends, thanks for this great toolbox! I am trying to get the car to drive on a line and calculate inverse kinematics. can you tell me how to connect a block of line(a map on which a black line is drawn) and calculate the inverse kinematics problem?

@Andres, can you make sure that you have Robotics System Toolbox installed? You might not have one of the required toolboxes installed.

Andres Vargas Ibañez

I got the error: "Undefined function or variable 'controllerPurePursuit'.", what can I do to fix it.

Daniel van Wensveen

Thank you so much for making this toolbox. It's been a pleasure to use and the documentation has been so helpful. To all the relevant people, thank you for making my project a success!

Joseph Thachil George

I am getting below error while running this project

'Input Port 2' of 'mrsMultiRobotAvoidance/Multi-Robot Lidar Sensor/Multi-Robot Lidar Sensor' is not connected.
Component:Simulink | Category:Block warning
Unconnected output line found on 'mrsMultiRobotAvoidance/Multi-Robot Lidar Sensor/Visuals' (output port: 1)
Component:Simulink | Category:Block warning
An error occurred while running the simulation and the simulation was terminated
Caused by:
MATLAB System block 'mrsMultiRobotAvoidance/Multi-Robot Lidar Sensor/Multi-Robot Lidar Sensor' error occurred when invoking 'stepImpl' method of 'MultiRobotLidarSensor'. The error was thrown from '
'C:\Users\Utente\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Mobile Robotics Simulation Toolbox\mathworks-robotics-mobile-robotics-simulation-toolbox-7066fa0\src\environment\+internal\createMapFromName.m' at line 39
'C:\Users\Utente\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Mobile Robotics Simulation Toolbox\mathworks-robotics-mobile-robotics-simulation-toolbox-7066fa0\src\environment\LidarSensor.m' at line 34
'C:\Users\Utente\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Mobile Robotics Simulation Toolbox\mathworks-robotics-mobile-robotics-simulation-toolbox-7066fa0\src\environment\MultiRobotLidarSensor.m' at line 83'.
Map name 'map' must be a robotics.OccupancyGrid or robotics.BinaryOccupancyGrid object.

Yuyao Zhang

Yuyao Zhang

Hello, friend, thanks for this great toolbox!
I am trying to run robots but find the robot can went through the map, could you tell me how to solve this problem?

siqi zheng

rahul sinha


I am using Matlab R2018A. Is this toolbox compatible with my Matlab

Mohanned Shahin

Hi Sebastian, thank you for the quick response. I am actually using MATLAB R2019b (Platform: macOS). I will try and download the older releases and see if it works.

Sebastian Castro

@Mohanned this is because you are using an older version of MATLAB than R2019b, which is required in the latest version of this submission. Check out some of the older releases on GitHub and see if they match your version, else try upgrading:

Mohanned Shahin

I get this error when I try to run the mrsMultiRobotAvoidance.slx Simulink model:
An error occurred while running the simulation and the simulation was terminated
Caused by:
MATLAB System block 'mrsMultiRobotAvoidance/Multi-Robot Lidar Sensor/Multi-Robot Lidar Sensor' error occurred when invoking 'stepImpl' method of 'MultiRobotLidarSensor'. The error was thrown from '
'/Users/MoShahin/Desktop/mathworks-robotics-mobile-robotics-simulation-toolbox-7066fa0/src/environment/+internal/createMapFromName.m' at line 39
'/Users/MoShahin/Desktop/mathworks-robotics-mobile-robotics-simulation-toolbox-7066fa0/src/environment/LidarSensor.m' at line 34
'/Users/MoShahin/Desktop/mathworks-robotics-mobile-robotics-simulation-toolbox-7066fa0/src/environment/MultiRobotLidarSensor.m' at line 83'.
Map name 'map' must be a robotics.OccupancyGrid or robotics.BinaryOccupancyGrid object. """

AND this warning too:

"" Warning: Variable 'map' originally saved as a robotics.OccupancyGrid cannot be instantiated as an object and will be read in as a uint32. ""

What seems to be the error, I was following the video on swarm robotics step-by-step?

Mohanned Shahin

Regarding the issue below, I got this message in the diagnostic review too:
Warning: Variable 'map' originally saved as a robotics.OccupancyGrid cannot be instantiated as an object and will be read in as a uint32.

kumar samaksha


Hello, friend, good morning!
I am trying to run omniwhels scripts with the same code and including arduino in version 2018b, to execute with the link procedures:
start code: a = arduino ('COM4', 'Mega2560', 'Libraries', 'RotaryEncoder')
using the rotary encoder library for odometry. Do you have examples for arduino or any other microcontroller to constrain the path with these codes?
Grateful and I look forward to it!

%% EXAMPLE: Triple Omniwheel discrete simulation
% Copyright 2018 The MathWorks, Inc.

clear all

a = arduino('COM4','Mega2560','Libraries','RotaryEncoder');
channelA1 = 'D2';
channelB1 = 'D3';
channelA2 = 'D18';
channelB2 = 'D19';
encoder1 = rotaryEncoder(a,channelA1,channelB1,102);
encoder2 = rotaryEncoder(a,channelA2,channelB2,102);

motor1SpeedPin = 'D6';
motor1DirectionPin = 'D7';
motor2SpeedPin = 'D9';
motor2DirectionPin = 'D8';

direction = 0;
initialPWMVoltage = 3;


rpm = readSpeed(encoder1);
%rpm2 = readSpeed(encoder2);
fprintf('A velocidade do motor é: %.2f\n',rpm);
%fprintf('A velocidade do motor é: %.2f\n',rpm2);

%% Define vehicle
wheelRadius = 2.5e-3; % Wheel radius [m]
robotRadius = 8.5e-3; % Robot radius [m]
wheelAngles = [0, 2*pi/3, -2*pi/3]; % Wheel angles [rad]
vehicle = TripleOmniwheel(wheelRadius,robotRadius,wheelAngles);

%% Simulation parameters
sampleTime = 0.01; % Sample time [s]
initPose = [0; 0; pi/4]; % Initial pose (x y theta)
bodyMode = true; % True for body frame speeds, false for world frame speeds
targetSpeed = 500;

% Initialize time, input, and pose arrays
executionTime = 0:sampleTime:10; % Time array
vxRef = 0.2*ones(size(executionTime)); % Reference x speed
vyRef = 0.1*ones(size(executionTime)); % Reference y speed
wRef = zeros(size(executionTime)); % Reference angular speed
wRef(executionTime < 5) = -0.5;
wRef(executionTime >=5) = 0.5;
vel = [vxRef;vyRef;wRef];
pose = zeros(3,numel(executionTime)); % Pose matrix
pose(:,1) = initPose;

%% Simulation loop
for idx = 2:numel(executionTime)
% Solve inverse kinematics to find wheel speeds
if bodyMode
rpm = inverseKinematics(vehicle,vel(:,idx-1));
refWorld = worldToBody(vel(:,idx-1),pose(:,idx-1));
rpm = inverseKinematics(vehicle,refWorld);

% Compute the velocities
velB = forwardKinematics(vehicle,rpm);
vel = bodyToWorld(velB,pose(:,idx-1));

% Perform forward discrete integration step
pose(:,idx) = pose(:,idx-1) + vel*sampleTime;

%parar motores:

%% Display results
close all
hold on
plot(pose(1,1),pose(2,1),'ro', ...
pose(1,end),pose(2,end),'go', ...
axis equal
title('Vehicle Trajectory');
xlabel('X [m]')
ylabel('Y [m]')

Sebastian Castro

@Bernd -- there is a Simulink preference that should let you load models from newer versions, which I believe should work for these models because nothing major was done besides saving them in R2019b format:

Bernd Schmidt

The MATLAB Release Compatibility tells that the toolbox works with R2018a to any release. Today's Installation in R2018b via the Add-On Explorer shows that only R2019b is supported (simulink models do not work). Also the github repository only contains release 2.1 and 2.2 and no release 2.0 which worked with R2018b on another machine for a student project. This makes things a bit complicated and unpredictable.

Sebastian Castro

@Rakeshwar: These maps need to be occupancy map objects according to Robotics System Toolbox. Also, the tool right now only plots circular robots but you can always customize the source code to plot a square if you'd like. If you'd like more details or clarifications, email us at

Rakeshwar Elango

In this toolbox example "mrsCarRRT.m" 1) How the "complexMap.mat" is created because when I created a Map it was not accepting, when I tried to load in that program!
2)During the simulation the robot is shown circular but can you please guide how to make the robot look rectangular like a car instead of circular.

Chen po-lun

yan pyay



Botir Kuchkorov


Sebastian Castro

@Manish: Yes, it should be possible. There are several examples for single-robot waypoint following, and it's just a matter of using this same functionality with the multi-robot environment.

Manish Wankhede

Hi, i am trying to perform multi-robot environment (say 3 robots) with each robot following the waypoint. is it possible with current toolbox utilities? if yes, could you please give the example.

Sebastian Castro

@Zhuofan: The wheel angles are the angles the wheels are pointing towards, relative to the body frame of the robot. This angle affects the direction of motion when you spin wheels -- for example, the triple omniwheel model has the wheels at 0, +120, and -120 degrees. If you look at the help file, there should be a diagram explaining it.

@Kristi: I think your question is about the UAV Library which is a separate File Exchange submission. My understanding, though, is that quadrotors don't need a separate waypoint follower since you have full control over the direction of motion, and can instantly change direction unlike a fixed-wing aircraft which has a limited turning radius.

Zhuofan Hu

I have a Question about the generic omniwheels example.
What does the "Wheel angle" exactly mean?
I mean, what is the coordinate of the wheels' angle?

Kristi Davis

How do I adapt the fixed wing waypoint path following model to a quadrotor? I can change the type of the waypoint follower block, the UAV guidance model block, and the UAV animation block, but the heading control from the fixed wing remains and the guidnace model requires roll, pitch, yaw and thrust and I only see roll, and yaw to feed in.

Sebastian Castro

@Juan Pablo: You can use the VideoWriter functionality in MATLAB.

How I can create a video mp4 or avi from the simulations?

lxl luo

Yu-Cheng Deng

Sebastian Castro

@Thanh: Because a differential drive robot can only move in the body X direction!

thanh le

In the block "Differential Drive Simulation". body's speed inlcude Vx and Vy. why did you force Vy = 0?


Sebastian Castro

@Dabarshi -- no, it does not. You will need at least R2016b, due to the MATLAB features required by the toolbox.

Dabarshi Mitra

I wanted to know if this toolbox works with Matlab R2015a, because in my case i can't access the simulink library for this toolbox.
thank you

Radim Linke

Martin Sereinig

Hi, regarding my last question. I solved the problem now! I installed the toolbox into 2 different foldes, so matlab was not able to find the new library!

Melih Özcan

Hello Mr Sebastian and everybody,
I need a simulation environment to apply noisy sensor models and noisy motion model for a differential drive. As far as I understand, this toolbox is sufficient for that purpose, with maybe little modifications to add noise. I still want to ask you though, do you think I can use this toolbox for that study?
Thanks in advance!

@Truong -- as of yesterday, there's a new MultiRobotEnv that does support multi-robots (as well as equivalent Simulink functionality). Give it a look :)

Truong N. T. Nhu

Thank you for this great toolbox Sebastian. If the Visualizer2D works for multi-robots, I bet this toolbox will be extremely useful for academic as well as application purposes.

Hasan Güner

Julia Li

Sebastian Castro

Thanks for the input, Martin!

Make sure you add this entry to your Watch List so you know when we make updates.

Also, if there's anything else you want to reach me about, you can email us at

Martin Sereinig

Hi Sebastian,
maybe you can remember we already meet at robocup german open last year. I am no working on a new university, and changed the field of research from Rescue Robots to Industrial Applications. But still in the field of mobile robotics.

Multiple robots would be nice. I know it is posible in a more complex simulation, but for fast and easy visualisation it would be great in the robot visualisation tool. Just plot more robots, additional it would be great to inklude the outer dimentions of the robot in the plot (as a box, or circle) and additional y-axes.

Thank you for your fast response.

Sebastian Castro

Hi Martin,

Right now it's just single-robot, but I have a future plan to make it work with multiple robot. Glad that people are asking about it!

My idea was to have a "floating" block that represents the world itself, and then each robot you put in will plot itself on that map.

Martin Sereinig

Hi, i work in the research field of mobile robotics and control systems. I would like to work with this toolbox more. I started to implement my own kinematics and i want to compare different solutions.

I had a problem with the robot visualisation tool.
Is it posible to use more robots in one plot or to use more plots simultanious? If i try that i always get an error.


Gabriel Lara

nuur fakrul

are u have simple analysis for kinematic modeling for mobile robot using script. for example when robot to moving left, moving right, moving forward, and rotational moving in centre.



Added navigation and obstacle avoidance with reinforcement learning example. Added simple examples of RRT path planner. Updated all toolbox reference and syntax to R2019b


Added robot soccer and path following with obstacle avoidance examples. Visualization now has customizable robot colors and object markers. Bug fixes.


Added multi-robot support.

Other new features: Nonzero robot radius for visualization and multi-robot detection with lidar sensors, "Generic Omniwheel" kinematic model for simulating vehicles with arbitrary wheel configurations, new examples.

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

Inspired: Robotics Playground