Share via


Robotics Tutorial 1 (VPL) - Accessing a Service

Glossary Item Box

Microsoft Robotics Developer Studio Send feedback on this topic

Robotics Tutorial 1 (VPL) - Accessing a Service

Writing an application using RDS is a simple matter of orchestrating 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.

This tutorial teaches you how to use a basic service that reads the output of a contact sensor (referred in this tutorial as a bumper) and displays a message in the Console window.

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:

Samples\RoboticsTutorials\Tutorial1\mvpl

This tutorial teaches you how to:

  • Add and Configure New Activities
  • Connect Activities
  • Add and Configure a Simple Dialog Box
  • Designate Your Sensor.
  • Run Your Application

See Also:

  • Getting Started

Prerequisites

Hardware

You need a robot with a contact sensor. Contact sensors are typically simple mechanical switches that send a signal when physical contact is made. These sensors can also be distance detection devices (like sonars or infrared sensors) that provide a simple binary signal when a particular threshold is detected. Connect the sensor to your robot's microcontroller (its "brick" or "brain") 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.

It is also possible to run this tutorial using a simulated robot. See the notes below.

Software

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 a 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 many of the services are tailored for 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

Open Microsoft Visual Programming Language (from the RDS Start menu) to create a new project, or if you already have it open then create a new project by selecting New from the File menu.

Step 1: Add and Configure New Activities

Drag a Generic Contact Sensors service from the Services toolbox onto the diagram panel. The activity block appears with the name GenericContactSensors.

Figure 1

Figure 1 - Add a GenericContactSensors activity block

Add a Data activity by dragging one from the Basic Activities toolbox into your diagram. Place it to the right of the sensor service activity. Select string from the drop-down list and enter Ouch! in its text box.

Step 2: Connect Activities

Connect the ContactSensor's notification output to the Data activity's input by dragging from the round Notification connection pin on the ContactSensor activity to the Action pin (the arrow pointing into the block) on the Data activity.

If you dragged the connection from the correct connection point, you should see the Connections dialog box. Choose ContactSensorUpdate in the From column and and Create in the To column in the Connections dialog and click OK.

Figure 2

Figure 2 - Connections Dialog Box

This connection sends ContactSensorUpdate messages from the Contact Sensor to the Create action of the Data activity. Although the Data activity does not use the data coming from Contact Sensor, it uses the message to trigger the creation of the data (Ouch!) that you entered.

Your diagram should now look like the following illustration.

Figure 3

Figure 3 - Connected Sensor and Data Activities

Step 3: Add and Configure a Simple Dialog Box

Now drag a Simple Dialog service into your diagram window and place it to the right of the Data block. Connect the two activities. In the Connections dialog which opens, select DataValue in the From column and AlertDialog in the To column then click OK.

A Data Connections dialog box will pop up. Select value from the drop-down list as the value to be sent to the target Message. This means that the text "Ouch!" is sent to the message text of the Alert form (called AlertText) displayed by the Simple Dialog.

Figure 4

Figure 4 - Data Connections Dialog Box

Your diagram should now look like the following illustration.

Figure 5

Figure 5 - Completed Diagram

Step 4: Designate Your Sensor

The GenericContactSensor activity represents a generic service that can be applied to a contact (touch) sensor for different robots. Before you run your application, you need to tell VPL which sensor you want to use.

Right-click on the GenericContactSensor activity block to open its context pop-up menu. Choose the Set Configuration command. In the dialog box that appears, under Set Configuration, choose Use a manifest. If no manifest shows up in the list, choose Import Manifest and chose the appropriate manifest for the sensor you are using, then click OK. If you are using a real robot, make sure you select a manifest that includes a contact sensor, also called a bumper.

You can also select one of the simulation manifests, such as the LEGO NXT or iRobot Create. For example, you can use LEGO.NXT.Tribot.Simulation.manifest.xml. However, because you cannot easily press a bumper on a simulated robot you should drag a SimpleDashboard service onto your diagram as well. This service does not require any connections. When you run the program, you can use the Simple Dashboard to drive the robot so that it hits an obstacle and triggers the bumper.

Step 5: Run Your Application

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

Press the bumper on your robot. You should see an Alert dialog appear on the screen with the message "Ouch!". New dialogs will appear every time you press the bumper.

The log messages are also recorded by the Console Output service. To view the messages, you can run a web browser and go to the page https://localhost:50000. Click on the Debug and Trace Messages link in the menu at the left of the page. Make sure that the q1:Info checkbox is checked and then look at the list of messages at the bottom of the page.

As noted above, if you are using simulation you need the Simple Dashboard so you can drive the robot so that it hits an obstacle with its bumper. Be careful to avoid making the robot fall over when it hits the obstacle.

Summary

In this tutorial, you learned how to:

  • Add and Configure New Activities
  • Connect Activities
  • Add and Configure a Simple Dialog Box
  • Designate Your Sensor.
  • Run Your Application

 

 

© 2012 Microsoft Corporation. All Rights Reserved.