Click here to Skip to main content
13,005,192 members (64,153 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 10 Sep 2007

Microsoft Robotics VPL Pad Services Orchestration

, 10 Sep 2007
Rate this:
Please Sign up or sign in to vote.
An article to orchestrate gamepad services using VPL and Microsoft Robotics Environment

VPL splash screen


Before going on, I assume that you have a minimal knowledge of CCR and DSS libraries.

The verb says that "Writing an application using the Microsoft Robotics Studio is a simple matter of orchestrating the input and output between a set of services. Services represent the interface to software or hardware and allow you to communicate between processes that perform specific functions".

An interesting question is: how do I orchestrate input and output?

In the previous articles (padservice and padservicegui), we created two pad services: one handles pad actions such as stick movement or button pressing, the other one gives feedback about these actions. In this article, we will orchestrate them using VPL.

Visual Programming Language (VPL) is a new programming language released with Microsoft Robotics Studio. The first time I used the IDE, I was a little bit confused. After many VPL projects, I came to a decision: I will use VPL simply for message orchestration. VPL is very powerful, but when I need to develop something complex like variable manipulation or loops, I rapidly get confused. So whenever I have to develop something complex, I use C#( or VB.NET) to create services and I use them as logical block to connect using VPL. Whenever I need to coordinate services, I use VPL. I've tried to orchestrate services via code (C#), but VPL is really the master in this case. You could also use old C# (programmatic) approach to orchestrate message services, but the new IDE is simple, amazing, too fast to compete with. Try to emulate what we will do in VPL using C# and you'll see the differences. VPL has also the ability to create services that you can later reuse as the C# ones.

The Project

Well, the first unusual thing regarding VPL is that tutorials or samples are better as images. No code is normally written in VPL. Configurations and expressions require quite often a keyboard. But if you know C# syntax, you don't have a problem. Remember that this is not a basic tutorial and a very little bit of knowledge is required.

Let's begin, start opening VPL IDE. In the service section, type pad. You should see the pad services. You must download and compile pad services sources. Please read Introduction to download and compile them.

Step 1

Drag and drop inside the diagram two services (Pad and PadGui) as shown:

Step 2

From the message notification of Pad service, drag a message line to PadGui Service (from circle to square). A pop up window should open as in the following image. There we specify that whenever a RightStickUpdate from pad service is notified, a RightStickUpdate message is sent to the PadGui Service. That's the orchestration!

Step 3

The next step is about values. Messages can be seen as typed vectors vor values. So the message from Pad Service takes a value that we will pass to the PadGui Service using a RightStickUpdate message. Please note that Pad Service Message Types and PadGui Service Message Types have the same names but are of different type because of their different namespaces. The default value passed to destination is by default null.

Step 4

Here we set the Stick destination value from the source Stick value.

Step 5

After we set the value for this Connection, we should have the following diagram. Now when the pad service sends a notification of type RightStickUpdate we send a message of type RightStickUpdate to the PadGui Service.

Step 6

Now copy and paste the PadGui Service. We have now two references to one service instance. You should have a similar diagram.

Step 7

Now we repeat what we have done for message type RightStickUpdate but now we consider the LeftStickUpdate types.

Step 8

The main difference regarding value is that now we expand the destination Stick value and we see that this is a Composite value. Instead of using a complex value, we use two double values. LeftStickUpdate is composed by two double values. So here we don't pass a Stick as a value but we pass a Stick created from two double values. This allows us to use complex types when we have complex source values or simple values coming from different sources. Note that you have to enable Edit values directly to enter an expression. When writing expression, you have the support of intellisense.

Step 9

The diagram is like the following picture. Now we orchestrate two different notifications from pad service.

Step 10

Press F5 and move the pad sticks. You will see that the graphic indicators will move accordingly to the pad values.

Step 11

As we have done for RightStickUpdate and LeftStickUpdate connect even the ButtonPressed1Update and ButtonReleased1Update message types notifications. The process is the same. You should arrive at this:

Step 12

Press F5 and move your pad stick pressing button1. You will see that B1 label changes from black to red pressing and releasing the button1.

Step 13

If you need to handle the 3 remaining buttons, handle the remaining type notifications.


In these three articles, you have seen the full process of writing and orchestrating services. I used the pad service to move a Lego NXT robot. You can imagine a robot as a set of services (2 motor services and 2 sensor services for example), and in the same way you orchestrate a pad you can orchestrate a robot. The next article will cover how to move the robot using the pad. Have fun with robotics and start projecting the next planet lander NASA will send out in the space. :)

As usual, comments and suggestions are welcome.

- Matteo Ameglio


  • September 2007: First release


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
I'm a MS BI consultant. I've worked for years in web development and i'm currently a robotic hobbyst.

You may also be interested in...

Comments and Discussions

GeneralNice work, but I have a question.... Pin
staffert14-Dec-07 10:52
memberstaffert14-Dec-07 10:52 
Generalnice Pin
rbudman29-Nov-07 1:40
memberrbudman29-Nov-07 1:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170627.1 | Last Updated 10 Sep 2007
Article Copyright 2007 by Pedro77
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid