Robot Simulator IconThis was a quick and dirty project for a robotics class that I took at Georgia Tech in 2005. In this project, I built a Matlab simulator for testing out some simple obstacle avoidance/navigation code. My hope is that someone uses this a springboard to make a more complete version.


I’ve spent plenty of time working on robotics projects, and I have enjoyed all aspects of the design process from mechanical to electrical to computer science. However, if you are only interested in the computer science part (control theory, artificial intelligence, creating behavior) then having to have an electromechanical platform to run your code on can be a big hassle!

One solution to this is to use a pre-made platform (such as in this project). However, this too can be problematic because everything can break, and when developing algorithms, it is often convenient to prototype them in a simulated environment where real-life confounders don’t hinder your creativity.


This problem is often solved by robot simulators. One that I’ve used with great success is differential steering model. This is a simple, but very useful model for robotic actuation. With this type of drive system the robot can drive straight, trace an arc, or even turn in place.

close up of the robot

Simulated World

The simulated robot can make its way around a simulated environment represented by a .png file where black represents walls, and white represents flat, clear terrain. Thus any “environment” can be shown as a black and white image. For testing, I used two types of terrains, an organic-looking obstacle course and an “office” with square walls and corners.

[terrain images][terrain images]


So, now that we have a simulated robot in a simulated world we want it to do something. The goal I was working towards was this: Make the robot wander around the environment covering most of the area and not hitting any of the walls. This is accomplished with a pretty simple algorithm:

  1. Go straight unless sensors are blocked
  2. If one sensor is blocked, turn away from it
  3. If both are blocked, turn towards the farthest
  4. Turn until both sensors are free
  5. Continue going straight

There is a lot of room for improvement here (obviously), but this was a very quick project.


Check out a couple of videos. Here we see the robot’s path as it drives around the area.


Download the demo and run “>>setup.m” Please feel free to make improvements to this. If you do, let me know!

9 thoughts on “Robot Simulator

  1. hi, i just try your simulator and it is awesome ;)… can or not this code i’m extend to be multi-robot? or do you have the code…?..


  2. i tried… and i got tired, because still do not success… maybe you can give some idea to start…


  3. i can plot multi robot now.. but just cannot drive all the robot yet… one more thing, do you have any idea how i want to do robot-robot avoidance?


  4. Hello. I would like algorithm. It’s quite interesting .. and I would like more details.
    Thank you

  5. hi nice job……if you can , would you send me the matlab code for the robot with the sensors……it would be a great help ……

    thank for your time!

  6. hlw,it is a very nice work.
    may i plz know how to run the files sequentialy?i mean first i run the setup.m file but when i tried to run the others they r giving error…so mayb b i am wrong with the input and outputs.
    plz guide

Leave a Reply

Your email address will not be published.