Setting Up Microsoft Robotics Developer Studio to Program Your Mindstorms NXT

As we have emphasized in other articles, Microsoft Robotics Developer Studio is a very good tool to program your robots. Support and samples for generic sensors and devices as well as for several robotic platforms are included, among which we can find Lego Mindstorms NXT, but you can practically control and simulate almost any type of robot. MS RDS provides several interesting features such as Concurrency and Coordination Runtime (CCR) which represents a highly concurrent, message oriented programming model with coordination features that do not present the need of semaphores, locks, manual threading or other types of data, variables or procedures, Decentralized Software Services (DSS) which provides a service-oriented application model, or a graphical design and configuration environment such as the DSS Manifest Editor (DSSME). The Visual Programming Language (VPL) is the graphical development environment for your application, and it can also generate readable C# for improved versatility and the Visual Simulation Environment (VSE) is the primary tool for developing simulations of robots and their environment.

Basically the process of programming a robot under RDS consists of creating services that interact with each other, each service handling physical components of the robot, for instance a motor or a sensor, or coordinating components, such as a “drive” service that can coordinate two motors at a time for handling differential drive applications. Each of them is a REpresentational State Transfer (REST) web service, using dsshost.exe as a service bus.

Getting started

First of all, a wireless Bluetooth connection is required for the computer to communicate with the NXT brick as two serial over Bluetooth ports will be created, one for transmitting and the other for receiving data from the NXT. If your computer does not have such an interface, you can buy a Bluetooth USB radio for around 30 US Dollars. From the Mindstorms Bluetooth support page it seems that there are issues regarding Bluetooth communication of the NXT, only certain types of Bluetooth drivers and chipsets being properly supported. Nevertheless we have used something like this and installed it using standard Microsoft drivers under Windows 7 and XP. A Bluetooth USB dongle is also available at the Lego Shop website.

After setting up your Bluetooth radio you need to set up a connection with the NXT. On your NXT brick you need to make it visible by selecting Bluetooth -> Visibility from the main menu. After that you can start the Bluetooth device scan from the computer. After you have set up the NXT with the computer, you will see the virtual COM ports created.

Microsoft Robotics Developer Studio version 4 only runs under Windows 7 (32 or 64 bit). Other requirements are:

  • MS DirectX 9.0c compatible graphics card;
  • 2 GHz dual-core CPU or faster;
  • At least 10 GB of free disk space;
  • At 2 GB of RAM;
  • At least 2 USB 2.0 channels.

You also need to be logged on as an administrator as this will be required not only for installing software but also for building and running your applications.

The MS RDS 4 package can be downloaded from Microsoft’s Download Center here. DirectX 9.0c, XNA 4.0 and PhysX 2.8.1 are automatically installed with the package however .NET 4 framework is also required. If you do not have a version of MS Visual Studio installed, the .NET 4 package is also available at the Download Center here.

In order be able to write new services (create Class Library, use Reference Platform, etc.) with RDS, you should also install MS Visual Studio before installing RDS 4. You can download express versions of the software from Microsoft here.

After installation of the RDS 4 software is complete the first step to do is to run “Build All Samples” command found under Microsoft Robotics Developer Studio 4 folder in the Start Menu.

Creating the first program using VPL

After setting up the hardware and the software you can start up Microsoft Visual Programming Language to create your first NXT program. In the Service list on the right you will find services for the NXT brick, Lego sensors and devices as well as for third party HiTechnic and other hardware. In the Activity section you will find program blocks required to define behaviors and actions of your robot. Any activity or service can be dragged and dropped in the work area or Diagram and each of them can be configured by defining parameters appearing in the Properties section.

The first NXT application is based on the tutorial example in the MSDN Library, and will turn on the light sensor when the touch sensor is pressed. To commence we will drag the Lego NXT Brick (v2) service onto the diagram. Even if we will not address the brick in our example the service is required in every NXT program as it handles the communication between the computer and the NXT. In the properties section select “Set initial configuration” and under “Settings” you can configure the service. Under “NxtBrickState” enter the outgoing COM port number noted when you configured the Bluetooth connection. You can tick the “ShowInBrowser” option if you want the service to open a web page in your browser so that you can monitor and further configure your device. You will be prompted to log on with your user credentials.

Next you will add the Lego NXT Touch Sensor (v2) and Lego NXT Light Sensor (v2) services to the diagram. Also select “Set initial configuration” for both of them and under “Partners” select the NXT brick to which they are connected, in our case the LegoNXTBrickv2 added earlier. You also need to define the port numbers the sensors are physically connected to under the “SensorPort” parameter.

Now we need to establish a relation between the light and touch sensor. Notifications (i.e. sensor states) will be captured from the touch sensor so that the light from the light sensor will turn on or off. Select the round notification pin on the LegoNXTTouchSensorv2 and drag it onto the LegoNXTLightSensorv2. The “Connections” dialog will appear and here you need to define the connection From: TouchSensorUpdate To: SpotlightUpdate. After clicking ok the “Data Connections” dialog will pop up for you to define the data which is being sent to the light sensor. Select Value TouchSensorOn Target IsOn.

Now you can run your program by selecting Run -> Start. The NXT beep will signify that the connection is successful and you can press the touch sensor to observe the light sensor turning on. The DSS service will open the web page where you will also be able to monitor changes. Below you can see the service displaying a successful connection to the NXT and sensors attached.

Running services and activity monitoring of the service below.

This concludes our first NXT program creating using visual programming in the RDS 4 environment.



  • Enoel

    Now make one with one kit and the camera. When a motor moves one dretciion, it touches one button, when it moves the other way, it touches another button (using a differential)And one can go one way to hit the fifth button and the other to strum. Building three differentials could get tough with the extremely limited kit