Artificial Intelligence - Methods and Applications (Fall 13)

Assignment 2

The purpose of this assignment is to practice writing robot control software with a hybrid deliberative/reactive architecture. Microsoft Robotic Developer Studio (MRDS) will be used to simulate a robot and its environment. You are to create a controller that allows the robot to navigate the environment and constructing a map of it.

MRDS can simulate many different robots and environments. In this assignment, a Robosoft Kompai robot is to be used in the Factory environment. The Kompai has a laser scanner and a position sensor that may be used, and can be controlled by setting angular and linear speeds.


  1. Write a program that interacts with the Kompai robot in MRDS. This involves implementing functions for reading the laser scanner and position sensor, as well as setting the angular and linear speeds.
  2. Implement a hybrid controller that enables the robot to navigate the environment, exploring as much as possible the environments, limited to a square given as input in the form of coordinates. The robot should also construct a map of the assigned square.

The assignment should be solved independently or in a group of two students.


Creating new MRDS services is probably the most common way to develop with MRDS. This is however not what you will do in this assignment. Instead, you are to use the Lokarria http interface. Much like a web browser makes connections to a web server, the program you are to write will get access the robot's sensors and motors by making http connections to the MRDS server. While you are free to play around with MRDS while developing your application, note that your client program should work with MRDS as provided.

The program can be written in any programming language available in the labs. It should be possible to compile and execute on the windows or linux machines in the cs-labs. Remember to describe how to execute your solution in the assignment report.


The controller application you are to implement should be able to guide the simulated MRDS robot around any square area given to it as input (i.e, the robot is given the coordinates of the lower left and upper right corners of the area it is to explore). The robot should make a map of the area and, in the end, be able to output the map as a gif image. (In Java, the classes BufferedImage and ImageIO can be useful for this purpose.)

The controller's architecture should be hybrid, i.e., should have both deliberative and reactive features. The architecture should be modular, e.g., with a planning module, a chartographer, a navigator, and reactive control modules.

An established method for map making using a grid Cspace should be applied (see, e.g., Murphy chapter 11). It is recommended that the number of cells in your grid Cspace corresponds to the number of pixels in the map you are to produce. You are also required to use a sensible sensor model for the laser scanners (e.g., HIMM).

Your controller application should be named mapper and placed in ~/edu/5DV122/lab2/. The program should be started with five command line arguments:

mapper url x1 y1 x2 y2

  • url specifies the address and port to the machine running MRDS.
  • x1, y1, x2, y2 give the coordinates of the lower left and upper right corners of the area the robot should explore and map. Note that these coordinates are given in the coordinate system of the Factory environment and thus correspond to the information you can get from the position sensor.

As an example, the call

mapper http://localhost:50000 -65 0 0 60

should interact with a locally running instance of MRDS and gives the robot a suitable area to explore.

Your program should save the current map as an image file every 5 seconds. This means that the if the program is interrupted, the progress it has made thus far is still available.

Microsoft Robotics Developer Studio 4

For this assignment, Microsoft Robotics Developer Studio 4 (MRDS) will be used as a simulation environment for a robot. The simulated robot is a Robosoft Kompai robot. The controller program you write will control the simulated robot through an HTTP interface.

Installing MRDS

MRDS is available in all the windows labs. Run it by executing c:/MRDS4/store/launchers/StartLokarriaFactory.bat. If you wish, you can also install MRDS on your own Windows computer. MRDS is unfortunately not available for Linux and Mac.

Please follow these steps in order to install MRDS.

  1. Download MRDS from
  2. Install MRDS. We recommend that you choose Custom installation and change the default installation directory to c:\MRDS4.
  3. When MRDS is installed, select Microsoft Robotics Developer Studio 4 from the start menu and select the choice Build all samples. The shell command may produce a few errors or warnings, usually nothing to worry about.
  4. When compilation is finished, you may test that MRDS is working by running one of the example environments from the folder Visual Simulation Environments on the start menu.
  5. Download and unpack
    • Before unpacking the file, it must be unlocked. Right click on the zip file and select Properties. In the Properties dialog, at the bottom, there will be an "unblock" button; click it and then extract the file.
  6. Copy the files in the MRDS Installation Files-folder to your MRDS directory, overwrite any existing files.
  7. Copy StartLokarriaFactory.bat into the store/launchers/ directory in your MRDS installation directory.
  8. Run MRDS by executing store/launchers/StartLokarriaFactory.bat in your MRDS installation directory.
    1. MRDS should print a security warning in the console, and start a 3D simulation environment and a map-view.
    2. MRDS may however also display the message *** Initialization failure: Could not start HTTP Listener, in that case you must grant permission for MRDS to open the specified http port. See Point 4 in the Microsoft MRDS getting started guide for details. You may also run MRDS as administrator in order do avoid this problem.
  9. Visit http://localhost:50000 to access the MRDS HTTP interface.

Using MRDS

Controlling the robot

When MRDS has been started (see above) you should see a 3D view, a map view and a small window with a joystick. Navigate the 3D view by using the arrow keys (hold down shift in order to increase the movement speed of the camera).

Since MRDS may connect to a real, physical, robot, the joystick interface is intentionally non-intuitive. In order to control the robot, you must click the "Sticky Buttons" box and press 0. After that, the robot can be controlled by clicking and dragging the joystick wheel.

Accessing the HTTP interface

With MRDS running, visit http://localhost:50000. This should put up a page with the title Microsoft Robotics Home. If this page displays, MRDS is running. Now you can access the http interface that will be used to interact with the robot. A full specification of the http interface (named Lokarria) is found in the RobuBox manual, section 5.4.

  • http://localhost:50000/lokarria/laser/echoes
    Returns the current laser scan in JSON format. Each scan includes 271 distances from the center of the robot to the closest obstacle, in different directions. The scan also includes any overflows and reflectors, these can usually be ignored (see the RobuBox manual for details). Note that the reflector of the laser rotates counter-clockwise, such that the first item in the laser scan corresponds to the rightmost beam. Read the manual carefully.
  • http://localhost:50000/lokarria/laser/properties
    Returns information about the laser configuration, such as angle between each laser beam in the scan. This information usually does not change and may hence be read only once at program startup.
  • http://localhost:50000/lokarria/differentialdrive
    This interface is used both to read the current speed of the robot and to set a new speed. A normal GET request (usually made by the webbrowser by default) will return the current speed, while a POST is used to set the speed. The chrome application Postman may be used to test sending commands to the robot.
  • http://localhost:50000/lokarria/localization
    Used to find the current pose (position and orientation) of the robot. Note that the orientation is given as a Quaternion and may be difficult to interpreet directly. See the RobuBox manual for details.

MRDS provides several other http interfaces, get a complete list by visiting http://localhost:50000 and selecting Service directory.

Generating log files

Loggs hare generated using a Google Chrome Web App named MRDS Log Client. In order to install the webapp, download ChromeMRDS.crx. In Chrome, open Tools -> Extentions, then drag and drop the downloaded file into the Chrome Window. Chrome will ask you if you wish to install the addon, select yes and you're good to go. The web app can be started from the program section of a New Tab window in Chrome.


You can implement your solution to this assignment in one of the following languages: Python, Java, JavaScript, C, C++. If you want to use another language, please ask the teacher for permission. Note that the program must run on the Windows computers in our labs. You are allowed to use most extension modules, but please ask for permission before doing so.

All languages listed above has builtin modules for using the http protocol. You can find some java code for communicating with the robot here. For the code to run, you will also need the following Json libraries:

You may also find the code for quaternions in this file useful.

What to hand in

You should hand in a complete and well-written report in the box marked Artifcial Intelligens - Methods and Applications on the fourth floor of MIT-Huset before the due date (see schedule). The report may be brief but it is important that you include a title page and make some sensible breakdown into headings. Describes how your solution works on a level that does not lose interesting details. It should be clear from your report which parts of your controller are deliberative and which parts are reactive. It is especially important that you include an example of how to run your program and to explain how inputs and outputs from the program should be interpreted. Also describe how your work went and which problems and issues you faced when developing the program.

Please place your code in ~/edu/5DV122/lab2/ of one of the members of your group and identify this group member in your report.