MSRS Code Page Home      MSRS Intro Program

Tutorial for Intro to Autonomous Robotics

This is a very basic tutorial that introduces you to the Microsoft Robotics Studio and some simple robotics concepts. No hardware is required, i.e. you do not need a robot. The Simulator will provide a simulated robot for you to work with.

Once you have tried out this Intro program, you should look at the Microsoft Robotics Tutorials.

NOTE: This program requires the Maze Simulator which is included in the download.


The Microsoft Robotics Studio provides an environment for building robotics applications. This Intro program uses the MSRS Framework to control a simulated robot in a maze-like world.

NOTE: You can select either the Pioneer 3DX robot (which is the default) or the Lego NXT robot in the Maze Simulator. You do NOT specify the robot type in the Intro program because it just uses the Maze Simulator.

In robotics, there is no clear definition of an autonomous robot. One meaning is that the robot is free to move around and is not restricted by a tether or "umbilical" cable for controlling the robot or feeding it power. Another meaning is that the robot as enough on-board intelligence to operate without human intervention.

This Intro program can be considered to be running inside the robot. Of course, we know that is not true. So if it makes more sense to you, assume that the program is sending commands to the robot over a wireless network, and the robot is also sending back data to the program. In that case, the program is running on your PC which is effectively the "brain" that controls the robot.


The information coming from the robot is called Sensor data.

There are two types of sensor data: proprioceptive and exteroceptive. These big words just mean internal and external. Internal information could include things like the battery voltage so that the robot knows when it is running out of power and needs to recharge. External information is about the world around the robot, like the distance to the nearest obstacle, the ambient temperature or even images from a video camera.

In this introductory example, we use the simplest of all sensors -- a bumper. A bumper is just a switch that senses when the robot runs into some other object.

Bumpers are called a contact sensors because the robot actually makes contact, i.e. bumps into, the obstacle. If this obstacle happens to be a human, then it could be harmful to the human! If it is a wall, then it might damage the robot. Either way, this is not a good sensor. Therefore bumpers are usually used as a last resort in case the other sensors have failed.

The Pioneer robot in the simulation has two bumpers, one at the front and another at the back. The Lego NXT only has one bumper at the front.

The simulated Pioneer robot actually has a Laser Range Finder (LRF) as well which is a range sensor, i.e. it measures the distance to obstacles. However, this is not used in this simple program. The advantage of a LRF is that it does not require the robot to go around crashing into things! However, a real LRF is very expensive.

Although it is not used by the Intro program, the simulated Pioneer robot has a camera mounted on top of it. You can see the view from this camera by pressing F8 in the simulation window or selecting it from the Camera menu. The Lego NXT does not have a camera.


Actuators do things. (They are usually called effectors for robotic arms.) In our case, the only actuators that we can control on the robot are its wheels.

The Pioneer and Lego NXT robots both have two wheels and the motor speed can be controlled independently for each wheel. (In case you are wondering how a robot balances, there is a third non-driven wheel called a jockey or castor wheel. The castor wheel can spin around to roll in any direction just like the wheels on an office chair.)

This configuration with two wheels on a common axis is called a Differential Drive because the two wheels can rotate in different directions. By appropriately adjusting the power to the two motors, the robot can move forwards, backwards, rotate on the spot, or move in an arc.

Running the Intro

The Documentation page has instructions for running the program.

When Intro starts, it will create two windows: A Simulator and a Dashboard. These are shown below. Click on the images for larger views.

Simulator ViewDashboard

Once you have it running, and the Dashboard is connected, you need to deliberately drive the robot into a wall to trigger the wandering behaviour. Running into a wall generates bumper messages, which the program is listening for.

Debugging information is displayed in the MSRS DOS window to let you know what the program is doing. You should see messages indicating that the robot has bumped into something, and that the program is setting the wheel speeds.

NOTE: The robot has inertia, just like a real robot, and it also takes some time for the motors to reach the desired speed. This means that there will be some lag between when you move the trackball on the Dashboard and when the robot responds. Play around and get a feel for it.


In robotics, a behaviour is a high-level function that we might consider as "intelligence". Backing away from a wall when you bump into one seems a pretty intelligent thing to do!

To simplify the problem, we try to divide up the task of programming a robot into a number of layers. At the bottom level are the actuators and sensors and the associated low-level software. The Microsoft Robotics Studio defines this layer in such a way that it independent of the type of robot.

At a higher level, we have behaviours. (There might be some intermediate levels as well, depending on the framework.) A single behaviour might work on many different robots, provided that the lower layers hide the details of how the robot actually works.

The behaviour in the Intro program is fairly complex. It works as follows:

Because the motor speeds vary randomly for each step, the robot will effectively wander around. Sometimes however, it will spend a lot of time bumping up against the wall, or will immediately run into the wall again after taking off. It is not a very smart program!

NOTE: There are several parameters in the configuration file that control this behaviour. You can experiment by editing the file and changing them. A copy of the file is included in the ZIP and is called Intro.Config.xml. This file must be located in the MSRS "store" directory. However, the first time that you run the program it will create the config file if it does not exist.

Watch the robot for a while. Notice that it seems to spend a lot of time bumping into the walls. This can't be good for the robot, but luckily it is just a sim.

It is also possible that the robot might knock itself over. This is particularly true for the Lego NXT, although the Pioneer is powerful enough to knock itself over too. Once this happens you will have to restart the program because there is no way to pick up the robot and set it on its wheels again.

If you leave the program to run for long enough, eventually the robot should visit most of the maze world. This might take a very long time, but it is the same principle that pool cleaners use to clean the bottom of a swimming pool. Some vacuum cleaning robots also wander around randomly, but usually they are smart enough not to bump into things because they have infra-red sensors.

What have you learnt?

This Intro covered several topics:

This program still needs a lot of work, which is the challenge of robotics! Just when you think you have the perfect program, the robot will do something strange. Thinking with a literal mind like a robot is not easy for us humans. Basically, we know too much and we can apply our common sense!

Sometimes these strange behaviours appear to be really smart, but you don't remember writing any code for them! These are called "emergent behaviours" because they emerge from a set of other behaviours to create a "super" behaviour. Unfortunately, not all emergent behaviours are useful.

Where to from here?

This page is a very simple tutorial! It is intended to get you up and running quickly and hopefully inspire you to start hacking away at your own robotics code.

You should open the Intro program in Visual Studio and look through it. I have put a lot of comments in the code. The DssNewService program generated the basic structure, and I have included references to the Microsoft Tutorials to show where some of the additional code came from.

Now that you have run a program, I suggest doing the Microsoft Tutorials. Note that you can use the Maze Simulator with Robotics Tutorial 1, so you don't need a real robot.

When you create the manifest for Robotics Tutorial 1, ignore the instruction that tells you to put in a Lego NXT bumper. In other words, do NOT add:

<!-- Start the NXT Bumper with default port 1 -->

Instead, put in the Maze Simulator and Dashboard from the manifest for the Intro Program. Due to the magic of MSRS, the simulated bumper will be used instead of the real Lego bumper. Here is the replacement code:


Or, if you want to use the Simple Dashboard then use the following service record instead of the one above for the Dashboard. (Note carefully that the dates are different as well as the filenames.)

Tutorial 2 is hard to do with a simulator because you have to push the bumper to make a motor work. You can probably do it using the Simulator camera to nudge the robot. You might just want to read this tutorial.

Robotics Tutorial 3 is based on the Fisher Technik robot. The Intro program does the same thing with a simulated Pioneer 3DX, but better. In fact, the Intro is based on Tutorial 3. So read through Tutorial 3 while you are looking at the code for the Intro program. See if you can pick out the differences.

That's all there is to it. Have fun playing with your simulated robot!

[ Overview ] | [ Documentation ]