Student Lounge

Sharing technical and real-life examples of how students can use MATLAB and Simulink in their everyday projects #studentsuccess

No Robot? No Problem! – Program Robots Using Simulations

Today,  Jose Avendano Arbelaez shares another guest post with us. Make sure you let us know your thoughts in the comments section.

– –

Robotics programmers have been putting more emphasis on simulation for both hardware and software design. Here are a few reasons why:

  1. You may not have available hardware, or selecting the right hardware depends on some initial analysis.
  2. You want to make sure your robot will behave as expected before testing on hardware. This will reduce the chances of putting unsafe code on your robots.

Because of these benefits of simulation, we have created tools to develop and test robotics algorithms in simulation. This post will help you get familiar with some of our robot simulation libraries.

Virtual Worlds – Dynamic 3D Visualizations

For many beginner robotics programmers, it is important to get immediate and accurate feedback on a robot’s behavior. The Robotics Playground provides a set of configurable virtual worlds. This is particularly useful if you are trying to move to which is a leading environment for controls design and robotics integration. You can test Stateflow charts for navigation and explore logic for moving objects. You can also close the loop and implement some robot perception by using multiple of the following available sensors:

  • Encoder
  • Distance sensor
  • Object sensor
  • Gyroscope
  • Compass
  • Contact switch
  • Lidar sensor

The environments can also be modified by changing the size, location and other properties of the 3D components directly from the Simulink blocks for any of the available environments.

If you are looking for a simple simulation environment in Simulink that includes physics, sensors, and rich visuals; the Robotics Playground is a great place to begin your journey. This library is also a great place to get started if you are planning to move your algorithms to Simulink-supported hardware like LEGOVEX, and Arduino. Simulink can automatically generate and deploy production-ready code to supported hardware providing an effortless transition from simulation to hardware testing. These environments are built using Simscape Multibody, if you are interested in physical modeling and simulation of 3D assemblies and environments, this library can also provide you with great reference examples.

Use Real-World Maps with Lines and Obstacles

Do you know what your environment looks like? The Mobile Robotics Training Toolbox can create dedicated 2D maps for line following and obstacle avoidance from pictures of your actual robot field. This toolbox is the complement of our Mobile Robotics Training and it is especially helpful for developing and testing path navigation algorithms. You can check out our earlier post on Autonomous Navigation and Planning for information on the training, but you can also just use the toolbox independently to simulate 2-Dimensional robot dynamics and perform early prototyping of supervisory logic. This Simulink toolbox comes with:

  • Robot visualizer
  • Line sensor
  • Encoder
  • Distance sensor
  • Kinematic utilities for differential drive robots
  • Application to import maps from pictures

Before you get started with this toolbox, we encourage you to explore the training videos which have detailed lessons to follow along implementing all the toolbox functionality.

 Prefer Working in MATLAB? Need Kinematic Models?

The Mobile Robotics Simulation Toolbox was designed with MATLAB algorithm developers in mind. This toolbox includes:

  • Lidar sensor
  • Object detector
  • Robot Visualizer
  • Detailed examples
  • Kinematic models for:
    • Differential drive robot
    • Omnidirectional wheel robots
    • Mecanum wheel robots
    • 4-wheeled vehicles with steering

In this case, you also get important global measurements like the position and orientation of your robot and objects, and customizable 2D maps. Some of the examples in this toolbox include closed-loop waypoint tracking, object detection and following, and lidar navigation using several kinematic models. Our video on Getting Started with the Mobile Robotics Simulation Toolbox will show you how install and use this toolbox. Additionally, all the contents of this toolbox have equivalent MATLAB and Simulink functionality so you can choose the programming approach you are most comfortable with, and get access to a rich library of models, sensors, and visualizations. The Mobile Robotics Simulation Toolbox is also well integrated with the Robotics Systems Toolbox. So, you can implement the complete suite of ground vehicle and mapping algorithms contained within your installed MATLAB libraries.

Need More? Use ROS-Based Simulators

Once you move on to more advanced robotics applications you might need more detailed physics, higher customization, and likely faster execution. Many commercially available simulation environments have support for the Robot Operating System (ROS). If you are already working with a simulator such as Gazebo or V-REP you might consider developing your robot logic with MATLAB and/or Simulink. We have a lot of content demonstrating how to use model-based design to interact with both ROS-enabled robots and simulators. Check out our blog post on Getting Started with MATLAB, Simulink, and ROS which has anything you need to prototype, execute and deploy robot control algorithms and transport them to you preferred ROS platforms.


If you are at early development stages of your robot algorithms, need a way to test algorithms while your robots are being built, or simply just don’t have a robot to program; pre-built simulation libraries for MATLAB and Simulink for any experience level. Use the table below to match your simulation requirements to our available tools. 

Robotics Playground 


Mobile Robotics Training Toolbox


Mobile Robotics Simulation Toolbox


  • 3D Visuals
  • Customizable obstacle and object maps
  • Common robot sensors
  • Simulink library and MATLAB API
  • 2D Visuals
  • Common kinematic models
  • MATLAB and Simulink Libraries
  • Integrated with Robotics System Toolbox

More detailed environments, physics and robots? Getting Started with MATLAB, Simulink, and ROS

Testing your algorithms in simulation environments can help you get results faster and maybe even prevent potentially dangerous robot behavior. If you get a chance to try any of these toolboxes, let us know how they help you by writing to or in the comments files below.

  • print


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.