Export (0) Print
Expand All

Robotics Tutorial 4 (VPL) - Drive-By-Wire

Microsoft Robotics

Glossary Item Box

Microsoft Robotics Developer StudioSend feedback on this topic

Robotics Tutorial 4 (VPL) - Drive-By-Wire

Microsoft Robotics Developer Studio (RDS) provides a re-usable design for writing services. This design allows you to write a service once to a common hardware specification and then use that service across a variety of hardware robotic platforms.

This tutorial teaches you how to author a service that partners with abstract, base definitions of hardware services. Based on a configuration file (a manifest), your service binds at runtime to a specific implementation of these services. The tutorial displays a Windows user interface (Winform) that allows basic user control of a robot's movement.

This tutorial is provided in the Microsoft Visual Programming Language (VPL) language. You can find the project files for this tutorial at the following location under the Microsoft Robotics Developer Studio installation folder:

Sample location

This tutorial can also be used in a Simulation without requiring any robotic hardware.

This tutorial teaches you how to:



You need a robot with microcontroller and a contact sensor. The sensor can also be distance detection devices (like sonar or infrared sensors) that provide a simple binary signal when a particular threshold is detected. Configure your contact sensors so that one is at the front and the other is at the rear.

This tutorial also requires two motors in a two-wheeled differential/skid drive configuration.

Connect the sensors and motors to your robotic platform following the normal conventions for the hardware you are using.

To determine if support is included in RDS for your robot and to setup your hardware, see Setting Up Your Hardware. You may be able to apply this tutorial for other robots that provide similar services (or create your own services by performing the Service Tutorials included in RDS). Setting up your hardware may also provide you with any recommended guidelines for setting up your PC to communicate with your robot.


This tutorial is designed for use with Microsoft Visual Programming Language.

Microsoft Visual Programming Language (VPL) is an application development environment designed on a graphical dataflow-based programming model rather than control flow typically found in conventional programming. Rather than series of imperative commands sequentially executed, a dataflow program is more like a series of workers on an assembly line who do their assigned task as the materials arrive. As a result, VPL is well suited to programming a variety of concurrent or distributed processing scenarios.

VPL is targeted for beginning programmers with a basic understanding of concepts like variables and logic. However, VPL is not limited to novices. The compositional nature of the programming language may appeal to more advanced programmers for rapid prototyping or code development. In addition, while its toolbox is tailored developing robot applications, the underlying architecture can be applied to other applications. As a result, VPL may appeal to a wide audience of users including students, enthusiasts/hobbyists, as well as possibly web developers and professional programmers.

You will also need Microsoft Internet Explorer or another conventional web browser.

Getting Started

To begin, open the VPL development environment and create a new project by selecting New from the File menu.

Now drag a Direction Dialog from the Services toolbox into your diagram. The Direction Dialog provides a simple window with five buttons to control the robot: a left button, right button, Forwards button, backward button, and a stop button.

The Direction Dialog is designed to let you press a button on the dialog to trigger an event which passes the name of the button as a string. By connecting to this event, you can use an If activity block to control the motors of the robot.

Step 1: Define the Operations

Add a new Switch activity and a new Calculate to your diagram. The Switch compares its input message to the the values in its entries and sends the message to output of the first entry (from top to bottom) that matches the message.

Connect the Calculate block to the ButtonPressed notification of the DirectionDialog block and type Name in the text box to get the name of the button that was pressed.

In the Switch block, enter "Stop" (include the quotes). Click the Plus ( + ) button in the lower left of the activity block to display another condition. Enter, "Forwards". Click the Plus button three more times and enter "Backwards", "Left", and "Right" in the text boxes.

Figure 1

Figure 1 - Add the actions in the switch block

Insert seven Data activities. Connect:

  • One to the "Stop" output and entering 0.0.
  • One to the "Forwards" output and enter 0.8.
  • One to the "Backwards" and enter -0.8.
  • Two to the "Left" output, entering -0.6 and 0.6.
  • Two to the "Right" output, entering 0.6 and -0.6

Insert two Join activities. Label the local variables in the Join text boxes as Left and Right. For each Join, connect the two Left Data blocks to one of Join activities and connect to the two Right Data blocks to the other.

Figure 2

Figure 2 - For each action specify the motor power values

The Join activities take the two data value inputs and send them together as a composite message.

Now connect the output of the first three Data blocks to a Merge block. Do likewise with the two Join blocks. Connect each of these new Merge blocks to a Generic Differential Drive service. In the first case, you will have to set both the Left Wheel and Right Wheel powers to value, i.e. they are both the same. For the second case, the Left and Right values from the Join will automatically be forwarded to the corresponding wheel powers. (This only works because the order in the Join matches the order in the drive request, not because VPL is smart about matching the fields up).

Your diagram is now complete and should look like the following.

Figure 3

Figure 3 - Merge the values to set drive power

Step 2: Use Alternative Dataflow Diagrams

As a variation of this diagram, instead of using the Stop button, you can use the ButtonReleased event of the DirectionDialog service so that the robot goes when you press the buttons and stops when you release them. If you do not add this code, the robot will keep driving until you press the Stop button.

Figure 4

Figure 4 - Stop driving when a button is released

Step 3: Run Your Application

Run your application by choosing the Run command from the Run menu or by pressing F5.




© 2012 Microsoft Corporation. All Rights Reserved.

© 2014 Microsoft