Bringing together the best of concurrent and distributed development, Microsoft Robotics Development Studio (MRDS) services allow you to create useful service-oriented applications.

by Sara Morgan Rea

Jun 5, 2008

Page 2 of 5

Understanding Services
Services are key objects in MRDS and a typical robotics application will utilize more than one service to accomplish a common goal. Each service may perform a specific function, such as reading data from a sensor or sending commands to an actuator. Central services, known as orchestration services, will be used to coordinate the actions of all the other services. Each service will expose the data that it collects through state variables. These state variables represent the service at the time they are requested.

Since more than one service can be involved in an application, they need a to communicate with each other. Services communicate by sending and receiving messages through DSS ports. A DSS port is similar to the port assigned when you run an application in Visual Studio. Messages contain operations, which indicate what the request is for. For example, a GET operation is used to get the entire state for a service. The SUBSCRIBE operation allows a service to receive event notifications regarding state changes with another service.

Figure 1. The Control Panel Interface: This diagram shows the flow of information between services responsible for collecting and displaying data from a robot's sensors.

To understand how this works, let's examine a situation in which multiple services are responsible for collecting information from a robot's sensors and displaying that information in a control panel. While Service A collects information from a robot's sound sensor, Service B collects information from its touch sensor. Both services make their data available to other services through state variables. An orchestration service, Service C, is responsible for subscribing to state changes for Service A and Service B. It then displays the data it collects in a Control Panel interface, which is used to view the robot's sensor data (see Figure 1).

Creating a Service in MRDS
If you are new to MRDS, you may want to take a few minutes to get familiar with the features it supports. You can refer to my previous article, "An Introduction to Programming Robots with Microsoft Robotics Studio." To follow along with the code in this article, you will need to have both Visual Studio 2008 and MRDS 2008 CTP installed on your machine. Download the CTP version of MRDS here.

MRDS provides a Visual Studio 2008 template for creating new service projects. Once you have installed MRDS, go to File>New>Project. You should see a Robotics project type and, within that, a template named Simple Dss Service RDS 2008. Select this as the template and enter a name and location for the project. In the sample code available with this article, the project is called MouseTracker (see Figure 2).

Author's Note: Avoid renaming projects after they have been created. By default, the service will be named DssService1. If you create the project DssService1, do not attempt to rename the project after it is created. Several references to this project name have been added to the properties of the project and unless you change them all, you could have difficulty executing your application.