RoboHum V2 (Part 3b – Microsoft Robotics Studio)
Now that we have a working hardware platform, we can start with the guts of our robot…
When I started with the upgrade of RoboHum, I initially decided to use the newly released Microsoft Robotics Developer Studio 2008 CTP July Downloads. After spending a few hours debugging some issues I had running it on Windows CE, I decided to revert back to Microsoft Robotics Studio (1.5) Refresh.

What is Microsoft Robotics Studio (MSRS)
Microsoft® Robotics Studio is a Windows-based environment for hobbyist, academic and commercial developers to create robotics applications for a variety of hardware platforms. The Microsoft Robotics Studio includes a lightweight REST-style, service-oriented runtime, a set of visual authoring and simulation tools, as well as tutorials and sample code to help you get started.
Services, Messages, and Ports
A DSS Service is the basic component upon which Microsoft Robotics applications are built. In fact, DSS services are a generic construct that can and have been used outside of the context of robotics. DSS services contain state and the service state is manipulated via messages sent to the service on a service port.
Messages sent to a service are structured .NET classes that may contain a message payload that determines how or even if state will be modified, or what part of a service state should be retrieved. There are also message that do not directly manipulate state, but may have some other side-effects. Services respond to messages such as CREATE, LOOKUP, UPDATE, etc. In addition, you can define messages that extend the semantics of the core messages.
Ports are the mechanism through which services communicate. Ports accept a set of message types that are defined by the service itself. In addition, ports are also used for outbound communication in situations such as subscribing to event notification from a service.
From Home Automation with Microsoft Robotics Developer Studio 2008 by Charles Stacy Harris III
We are going to create a very basic service for RoboHum (Creatively called RoboHum).
- Open the Microsoft Robotics Studio Command Prompt
- Create the service
cd Samples
dssnewservice /service:RoboHum
- Open the created service using Visual Studio
Our RoboHum service will support 2 messages.
SetMotor1 controls the forward/backwards motor and the SetMotor2 controls the left/right motor. Here is the implementation of the SetMotor1 message
[DataContract]
public class SetMotorRequest1
{
private bool direction = false;
[DataMember]
public bool Direction
{
get { return direction; }
set { direction = value; }
}
private bool motor = false;
[DataMember]
public bool Motor
{
get { return motor; }
set { motor = value; }
}
}
SetMotorRequest1 is the actual message payload. The polarity of each motor and if it is on or off can be set!
public classSetMotor1: Update<SetMotorRequest1, PortSet<DefaultUpdateResponseType, Fault>>
{
publicSetMotor1()
: base(newSetMotorRequest1())
{
}
}
Next, we need to add our SetMotor1 & SetMotor2 messages to our operations port
[ServicePort()]
public class RoboHumOperations : PortSet<DsspDefaultLookup, DsspDefaultDrop, Get, Replace, SetMotor1, SetMotor2>//, SetMotor1, SetMotor2>
{
}
SetMotor1Handler is a message receiver that is active on the main port and which responds to the update message by updating internal state, and notifying subscribers of the change in state.
[ServiceHandler(ServiceHandlerBehavior.Concurrent)]
public IEnumerator<ITask> SetMotor1Handler(SetMotor1 setMotor)
{
if (setMotor.Body.Motor)
value |= 0x01;
else
value &= 0xFE;
if (setMotor.Body.Direction)
value |= 0x02;
else
value &= 0xFD;
Console.WriteLine("SetMotor1Handler - 0x{0}", value.ToString("X02"));
RoboHumService.SX_outp(0x78, value);
setMotor.ResponsePort.Post(DefaultUpdateResponseType.Instance);
yield break;
}
This is a very basic example of what is required to write a DSS service!
Next step is to convert our service to .NET Compact Framework (Before you start, please read Developing DSS Services for Windows CE)
- Open the Microsoft Robotics Studio Command Prompt
cd samples
cd robohum
DssNewService.exe /generateCFproject:robohum.csproj
- Open the converted project in Visual Studio and build it (cf.robohum.csproj)
Next step is to package and deploy the new service
- Open the Microsoft Robotics Studio Command Prompt
cd samples
cd robohum
dssdeploy /p /cf /m:robohum.manifest.xml robohum.exe
- Copy RoboHum.exe to the EBOX-2300 (\Program Files\MSRS)
- Run RoboHum.exe (This will extract all the required files to run the service)
- Run –> cmd.exe
cd\program files\MSRS
bin\cf.dsshost /p:50000 /t:50001 /m:..\samples\robohum\robohum.manifest.xml
Now your service should be running and ready to receive messages
[NOTE] on the EBOX-2300 it takes +/- 30-60 seconds for the service to start up the first time!
Here is the Visual Programming Language (VPL) Diagram of the current program controlling RoboHum
As you can see from this diagram, I have a GameController (XBOX 360 Remote control). Each time a button is pressed on the controller (I use X as forward and A as backwards) to send SetMotor1 to my RoboHum service. I also use the point-of-view buttons to turn left or right (Sending SetMotor2)!
Running services on remote nodes
Although this is a very simple VPL, it has 1 part that was extremely difficult. This VPL will run on my local machine… how does it know how to contact the RoboHum service located on another node? In V1.5 I had to manually edit the manifest. I have been assured that this will get easier in future released but for now, I had to do the following
- Compile the VPL program as a service
- Manually edit the manifest
<?xml version="1.0"?>
<Manifest xmlns:robohum="http://schemas.tempuri.org/2008/09/robohum.html" xmlns:gamecontroller="http://schemas.microsoft.com/robotics/2006/09/gamecontroller.html" xmlns:diagram="http://schemas.tempuri.org/2008/10/robohumapp/diagram.html" xmlns:this="urn:uuid:febf43ac-2747-4580-a858-fa16ef8ab218" xmlns:dssp="http://schemas.microsoft.com/xw/2004/10/dssp.html" xmlns="http://schemas.microsoft.com/xw/2004/10/manifest.html">
<CreateServiceList>
<ServiceRecordType>
<dssp:Contract>http://schemas.tempuri.org/2008/10/robohumapp/diagram.html</dssp:Contract>
<dssp:PartnerList>
<dssp:Partner>
<dssp:Service>http://192.168.0.57:50000/robohum</dssp:Service>
<dssp:Name>diagram:RoboHum</dssp:Name>
</dssp:Partner>
<dssp:Partner>
<dssp:Contract>http://schemas.microsoft.com/robotics/2006/09/gamecontroller.html</dssp:Contract>
<dssp:PartnerList />
<dssp:Name>diagram:GameController</dssp:Name>
<dssp:ServiceName>this:GameController</dssp:ServiceName>
</dssp:Partner>
</dssp:PartnerList>
<Name>this:Diagram</Name>
</ServiceRecordType>
<ServiceRecordType>
<dssp:Contract>http://schemas.tempuri.org/2008/09/robohum.html</dssp:Contract>
<dssp:PartnerList />
<Name>this:RoboHum</Name>
</ServiceRecordType>
<ServiceRecordType>
<dssp:Contract>http://schemas.microsoft.com/robotics/2006/09/gamecontroller.html</dssp:Contract>
<dssp:PartnerList />
<Name>this:GameController</Name>
</ServiceRecordType>
</CreateServiceList>
</Manifest>
Thank you to Trevor Taylor for all his support in getting this to work!
And that is it… my RoboHum can be controlled using my XBOX 360 controller! What is next in V3?
- Webcam support
- GPS Support
- Create a simple ping service to test for network connectivity (And to emergency stop RoboHum if out of WiFi reach)
- Ready indicator (Either some lights or a buzzer to indicate that RoboHum is ready to receive messages)
- Implement a break message (This should turn the motor in opposite direction for 100ms)
The possibilities are now officially endless… I have a computer on wheel!!!
If you found this interesting or useful, please 