sup { vertical-align:text-top; }

Robotics

Simulating The World With Microsoft Robotics Studio

Sara Morgan

This article discusses:

  • Building the robot animation
  • Building the environment
  • Driving a robot or simulation
  • Creating entities
This article uses the following technologies:
C#, Robotics Studio

Code download available at:RoboticsStudio2008_06.exe(646 KB)

Contents

What is a Simulation?
Getting Started
Running a Simulation
Entities and Entity Types
Programmatically Adding a New Entity
Defining a New Entity in VSE
Creating an Entity Class
Creating a Mesh
Convert the Mesh to Binary Format
Creating a Simulation Service
Populating the Simulation Scene
Creating a Manifest
Running the Simulation
Building an Entity without a Differential Drive

Don't let the name fool you. Microsoft® Robotics Studio (MSRS) is more than just a way to play with robots. Released almost two years ago by Microsoft Research and virtually ignored by everyday business application developers, MSRS allows you to build service-based applications for a wide range of hardware devices. The toolkit includes a runtime that should be instantly familiar to Windows® Communication Framework (WCF) developers. Additionally, it features a Visual Programming Language (VPL) tool and Visual Simulation Environment (VSE).

MSRS offers a service-oriented runtime, along with the tools needed to design and deploy robotics-based applications. It includes visual authoring tools, tutorials, and documentation designed to jump-start developers new to the world of robotics. Commercial developers must purchase the toolkit for a small fee, but hobbyists and academic researchers are able to download and use it free of charge.

The MSRS runtime is composed of two lower-level runtimes that sit atop the CLR 2.0. These two runtimes are the Decentralized Software Services (DSS) and the Coordination and Concurrency Runtime (CCR). DSS is a lightweight, service-oriented runtime that is based on the Representation State Transfer (REST) principles, which are used to power the Web. CCR is a Microsoft .NET Framework library that supports asynchronous processing. This is extremely important for robotics applications, as data is constantly being sent and received from numerous sensors and actuators.

Along with the runtime, the MSRS toolkit includes a VPL tool that allows you to build robotics applications by simply dragging and dropping elements onto a design surface. MSRS also includes a VSE which allows you to experiment with complex simulations involving multiple robots and obstacles. This is the portion of MSRS I will focus on in this article. I'll cover the visual simulation environment and walk through the steps for creating a simulation using a new robotic entity. The good news is that you do not need a robot to work with the code from this article. That's what makes simulations so attractive; they provide an opportunity to learn without an investment in expensive hardware.

What Is a Simulation?

If you're not familiar with simulations, imagine a flip book—a little book with an image on each page that "moves" when you flip quickly through the pages. Simulations work in a similar manner. A simulation contains one or more entities and each of these entities is rendered inside a frame. The frame is equivalent to a page of paper in the flip book. The rate at which the frames are rendered depends on the hosting machine's graphics card.

The fundamental difference between the flip book and a simulation is that the flip book is static or predictable and the simulation is not. Each frame of a simulation is rendered dynamically and the forces that an entity encounters within each frame are not always known in advance. This is what makes simulations so useful. You can act out a scenario with a robot and see how the robot would interact with the world.

Getting Started

If you have not already done so, now would be a good time to download and install the MSRS toolkit (available at go.microsoft.com/fwlink/?LinkId=113902). The MSRS Web site currently offers a refresh installation for its 1.5 version. This includes the full version of MSRS 1.5, along with all available updates.

MSRS provides templates for Visual Studio® 2005, but even if your machine is running Visual Studio 2008, you can still run the samples included with this article. Your development machine will need a graphics card that is compatible with DirectX® 9.0. Specifically, the card must support vertex shader VS_2_0 or higher and pixel shader PS_2_0 or higher. Most high-end desktop and laptops capable of running today's graphics games will already have this.

If you are not sure what your graphics card supports, you can go to go.microsoft.com/fwlink/?LinkId=113904 for a list of graphics cards, along with the shaders they support. Additionally, you can install MSRS and use the help menu in VSE to view your supported pixel and vertex shaders. If you try to run one of the simulations included with MSRS or this article and your screen is blank, then your graphics card is not compatible.

MSRS uses the AGEIA PhysX engine to provide physics for the simulation environment. Without physics, your simulation would be useless, since it would in no way represent the world it was trying to simulate. For example, entities would be able to float around without gravity. If you read the documentation that accompanies MSRS, you will see that it mentions the use of an optional accelerator card provided by AGEIA (see ageia.com). It is not necessary for you to purchase and install this physics card in order to work with the simulations in this article; physics will still be available to your simulation through the AGEIA PhysX software engine.

Running a Simulation

At this point, you are probably anxious to see a simulation. Before you create your own simulation, you should try running one of the simulations provided with MSRS. Once installed, MSRS creates a menu folder that contains seven simulations. The first simulation in this folder, Basic Simulation Environment, will render a scene similar to Figure 1.

fig01.gif

Figure 1 Basic Simulation Environment

You might think that the basic simulation includes only two entities: a world globe and a box. In fact, the simulation scene also includes entities that represent the main camera, the ground, sky, and sun. You can see which entities are included by clicking Mode and Edit from the VSE menu.

Edit mode, shown in Figure 2, includes a left-hand pane where you can modify properties associated with each entity. These properties control everything from the name of the entity to its position in the simulation environment. Furthermore, they also allow you to precisely control how the entity is rendered, affecting how it appears in the simulation.

fig02.gif

Figure 2 Edit Mode for Modifying Entity Properties

If you return to Run mode, you can move around the simulation by using the mouse or arrow keys. This changes the point of view for the main camera, which is your view into the simulation. Another important point to mention is that VSE allows you to render the scene in different modes. Visual mode is the default and is a realistic view of the simulation scene. However, the Render menu item allows you to choose from Wireframe, Physics, Combined, or No Rendering modes.

The No Rendering option is included because rendering is just one aspect of a simulation. What is most valuable about running a simulation is the interaction among various entities. Since rendering entities within a simulation scene is expensive in terms of resources, the No Rendering option can be useful when there are a large number of entities involved.

Entities and Entity Types

An entity type allows you to define a new instance of a particular type of entity. For example, the world globe included in the basic simulation environment is a single shape entity type. The entity type acts as a template for the new entity in that it specifies properties associated with a particular type of entity. The values for these properties can be changed once the entity is created, but the entity type defines which properties are included.

VSE requires an entity type in order to add an entity to a simulation. For example, to add a robot such as the Create by iRobot, you would add a new entity from within VSE by clicking Entity and New, while in Edit mode. This will bring up the New Entity dialog box (see Figure 3).

fig03.gif

Figure 3 Insert New Entity in New Entity Dialog Box

The Create by iRobot is one of the robots for which MSRS provides an entity type. This means you can add a new Create robot to your simulation by simply using the New Entity dialog box. From the New Entity dialog box, you would select iRobot­Create as the Type and enter a unique name, such as "Create Entity." Once you press OK, the Create robot would appear in the simulation scene.

Programmatically Adding a New Entity

MSRS offers more than one way to create and work with simulations. In addition to VSE, you can add entities programmatically to a simulation by creating a DSS service project. MSRS provides a Visual Studio template that can be used to create a new DSS service. Once MSRS is installed, just select Simple Dss Service (1.5) as the template when creating a new Visual Studio project (see Figure 4).

fig04.gif

Figure 4 Create New DSS Service in the Visual Studio 2005 Template

Creating a new DSS service using the template will result in the creation of two class files. The implementation class, which by default has the same name as the project, is where you will add code to create a new entity. Simulations created programmatically will require access to assemblies not included with the Simple DSS Service template. Therefore, you will need to add references to the assemblies listed in Figure 5.

Figure 5 Assemblies Included with Simulation Project

Assembly Name Description
PhysicsEngine Provides access to the underlying AGEIA software physics engine.
RoboticsCommon Provides access to the PhysicalModel namespace, which is used to define the physical characteristics of robots.
SimulationCommon Provides access to type definitions used when working with the simulation and physics engines.
SimulationEngine Provides access to the simulation engine.
SimulationEngine.proxy Represents a proxy for the simulation engine, which is used when loading the simulation engine as a partner.

After adding the references, you will need to add the following namespace declarations to the implementation class file:

using Microsoft.Robotics.Simulation;
using Microsoft.Robotics.Simulation.Engine;
using engineproxy = Microsoft.Robotics.Simulation.Engine.Proxy;
using Microsoft.Robotics.Simulation.Physics;
using Microsoft.Robotics.PhysicalModel;

To understand what code is needed for your simulation, you should first examine the simulation tutorials provided with MSRS. The samples provided in the \samples\simulation tutorials directory from the MSRS installation correspond to the simulations available from the MSRS installed menu. For example, the basic simulation environment is the same as the SimulationTutorial1 project.

If you open the SimulationTutorial1 project using Visual Studio 2005, you can view the code used to create the basic simulation environment. The first thing to notice is the Start method, which is called automatically when a service is started:

protected override void Start()
{
      base.Start();
      // Orient sim camera view point
      SetupCamera();
      // Add objects (entities) in our simulated world
      PopulateWorld();
}

The Start method is where you add code to define your simulation environment. For the Simulation­Tutorial1 project, this involves setting up the camera and populating the simulation scene with entity objects.

In addition to the main camera, the basic simulation environment contains entities used to represent the sky, ground, box, and world globe. The code to insert the world globe, or textured sphere, is listed in Figure 6.

Figure 6 Insert the World Globe

void AddTexturedSphere(Vector3 position)
{
    SingleShapeEntity entity = new SingleShapeEntity(
       new SphereShape(
          new SphereShapeProperties(10, // mass in kg
          new Pose(), // pose of shape within entity
          1)), //default radius
       position);

    entity.State.Assets.Mesh = "earth.obj";
    entity.SphereShape.SphereState.Material = 
       new MaterialProperties("sphereMaterial", 0.5f, 0.4f, 0.5f);

    // Name the entity
    entity.State.Name = "detailed sphere";

    // Insert entity in simulation.
    SimulationEngine.GlobalInstancePort.Insert(entity);
}

The first line of code in the AddTextured­Sphere method creates an instance of the SingleShape­Entity. This type represents an entity with a single geometric shape, such as a sphere, and it is useful when you need to add an entity with a very simple physical geometry. In this case, I am creating an entity with a mass of 10 kilograms, or approximately four and one half pounds.

The mesh assigned to this entity is an object file, which has an .obj file extension. The object file is created with a 3D graphical editing tool and exported into an alias object format. MSRS requires that the mesh object file is in this format. The last thing you do in the AddTexturedSphere method is to insert the sphere entity into the simulation environment.

Defining a New Entity in VSE

Now let's create a new robot entity to represent the Boe-Bot by Parallax. The Boe-Bot is a small wheeled robot that supports a two-wheel differential drive system (for a photo, see Figure 7). For more information about the Boe-Bot, visit the Parallax Web site at parallax.com.

fig07.gif

Figure 7 Boe-Bot by Parallax (Click the image for a larger view)

The Boe-Bot is one of several robot platforms supported out-of the-box by MSRS. This means the MSRS installation includes the basic services used to operate the Boe-Bot's drive system and built-in contact sensors. While MSRS includes the platform services for the Boe-Bot, it does not actually include a Boe-Bot entity type.

Creating an Entity Class

To create a new entity type for the Boe-Bot, I need to add a class that derives from the DifferentialDriveEntity. By deriving from the DifferentialDriveEntity class, I'm able to reuse code that defines how the Boe-Bot should behave when it is moving through a simulation. The code used to create the BoeBot entity type is shown in Figure 8.

Figure 8 Create BoeBot Entity Type

[DataContract]
public class BoeBot : DifferentialDriveEntity
{
    Port<EntityContactNotification> _notifications = 
           new Port<EntityContactNotification>();

    // Default constructor, used for creating the entity from XML
    public BoeBot() { }

    // Custom constructor for building model from hardcoded values. 
    // Used to create entity programmatically
    public BoeBot(Vector3 initialPos)
    {
        MASS = 0.454f; //in kilograms  (around 1 pound)
        // the default settings approximate the BoeBot chassis
        CHASSIS_DIMENSIONS = new Vector3(0.09f, //meters wide
                                         0.09f,  //meters high
                                         0.13f); //meters long
        FRONT_WHEEL_MASS = 0.01f;
        CHASSIS_CLEARANCE = 0.015f;
        FRONT_WHEEL_RADIUS = 0.025f;
        CASTER_WHEEL_RADIUS = 0.0125f;
        FRONT_WHEEL_WIDTH = 0.01f;
        CASTER_WHEEL_WIDTH = 0.008f; 
        FRONT_AXLE_DEPTH_OFFSET = 0.01f; // distance from center of robot

        base.State.Name = "BoeBot";
        base.State.MassDensity.Mass = MASS;
        base.State.Pose.Position = initialPos;

        // chassis position
        BoxShapeProperties motorBaseDesc = 
            new BoxShapeProperties("BoeBot Body", MASS,
                new Pose(new Vector3(
                0, // Use 0 for X axis offset
                CHASSIS_CLEARANCE + CHASSIS_DIMENSIONS.Y / 2, 
                0.03f)), // minor offset in the z/depth axis
                CHASSIS_DIMENSIONS);

        motorBaseDesc.Material = 
             new MaterialProperties("high friction", 0.0f, 1.0f, 20.0f);
        motorBaseDesc.Name = "Chassis";
        ChassisShape = new BoxShape(motorBaseDesc);

        // rear wheel is also called the castor
        CASTER_WHEEL_POSITION = new Vector3(0, // center of chassis
             CASTER_WHEEL_RADIUS,              // distance from ground
             CHASSIS_DIMENSIONS.Z / 2);        // at the rear of the robot

        RIGHT_FRONT_WHEEL_POSITION = new Vector3(
             +CHASSIS_DIMENSIONS.X / 2,// left of center
             FRONT_WHEEL_RADIUS,       // distance from ground of axle
             FRONT_AXLE_DEPTH_OFFSET); // distance from center, on z-axis

        LEFT_FRONT_WHEEL_POSITION = new Vector3(
             -CHASSIS_DIMENSIONS.X / 2,// right of center
             FRONT_WHEEL_RADIUS,       // distance from ground of axle
             FRONT_AXLE_DEPTH_OFFSET); // distance from center, on z-axis

        MotorTorqueScaling = 30;

        // specify a default mesh 
        State.Assets.Mesh = "boe-bot.bos";
}

The constructor for the BoeBot class is used to set values for several variables defined in the DifferentialDriveEntity class. For example, the Mass is set with a value of 0.454, which represents the mass in kilograms. Additionally, the Boe-Bot chassis is defined in terms of the width, length, and height. These measurements were obtained by weighing the actual robot and measuring it using a metric tape measure.

The position of the Boe-Bot is defined through a set of coordinates that are passed in when the entity is created. These coordinates represent the X, Y, and Z axis points. The MSRS simulation engine uses a right-handed coordinate system, which affects the direction toward which the Z axis points.

The BoeBot constructor also defines the position of the chassis and the wheels within the entity. The DifferentialDriveSystem class makes the assumption that your robot will have two main wheels and a small rear wheel that is mostly used for balancing. Power will be assigned to the left and right motors, which control the main wheels. The difference between the power levels assigned to each wheel determines whether it moves forward, backward, left, or right. This is the same method used to drive the physical robot.

What makes the simulation so attractive is that, in theory, it does not matter whether your robot is virtual or physical—the code used to power the robot and receive data from the sensors will be the same. Some of the code that is used in the simulation project can be reused when working with the actual robot. Now, you may have noticed that I said "in theory." This is because the simulation cannot completely simulate a real-world environment. The simulation cannot account for noise—the stuff you do not expect, such as obstacles being in the wrong location.

What the simulation can do is give you a fairly realistic opportunity to experiment with a new robot design or simulate the interaction of multiple robots. This can be very useful in academic environments where resources are limited and the number of students is high.

Creating a Mesh

Each entity can be associated with a mesh, which is what makes the entity appear realistic. For example, in the case of the globe, the mesh is what makes the globe entity appear like the planet Earth. Strictly speaking, it is not necessary to associate an entity with a mesh, but in the case of complex entities, such as robots, a mesh object is preferable.

Just about any 3D graphical editing tool can be used to create the mesh. For this article, I was fortunate enough to have a colleague, Steve Grand, create a Boe-Bot mesh for me using a 3D package called SoftImage (see softimage.com for more information about this tool). The files associated with this mesh are included with the downloadable .zip file that accompanies this article. To follow along with the article, download the .zip file, extract the files, and copy the contents of the Boe-Bot folder to the /store/media directory associated with your local MSRS installation.

SoftImage is capable of exporting the image to the .obj format. Not all packages are capable of doing this. For example, SolidWorks (see solidworks.com) is a 3D package recommended by MSRS on its Channel9 Wiki (go.microsoft.com/fwlink/?LinkId=114031). Unfortunately, SolidWorks is not capable of exporting to the .obj format, so it recommends a tool named Blender (blender.org) to do the actual conversion. Keep this in mind when selecting a graphics package to create your mesh file.

The details involved with creating the Boe-Bot mesh are beyond the scope of this article, but you should know that it was created by joining multiple polygon mesh shapes. For example, the metal chassis began as a cube shape that was modified to represent the size and shape of the Boe-Bot. Additional cylinder shapes were then added to represent the wheels. A hierarchy was established to bind the wheels to the chassis and allow the entire object to function as a single shape. The result (as seen in Figure 9) is an image that represents the physical Boe-Bot.

fig09.gif

Figure 9 Using SoftImage to Create the Boe-Bot Mesh File

Convert the Mesh to Binary Format

MSRS offers a command-line tool that is capable of converting an .obj file to an optimized binary file with a .bos file extension. The benefit of this type of file is that it loads more quickly than the .obj file. The command-line tool, called Obj2bos.exe, can be accessed using the command prompt menu item included with the MSRS installation.

When working with a mesh it is important to remember that materials are used to color physical objects and each entity can be associated with one or more materials. Therefore, when you create your .obj file, it will likely include additional material files with a .mtl extensions. It may also include image files used to create textures. These files must be copied to the same location as the .obj file before using the mesh conversion tool.

The .obj file and all associated files should be placed in the /store/media directory associated with your local MSRS installation. The files associated with the Boe-Bot mesh, which are included with the code download, are: Aluminum.png, Boe-bot.mtl, Boe-bot.obj, BoebotWheel.png, and Pcb.png. Once placed in the media directory, open the MSRS command prompt and type the following:

Obj2bos.exe /i:"store\media\Boe-bot.obj"

The conversion tool will create a file named Boe-bot.bos, and it will reside within the media directory. Leave the file here, as it will be referenced later.

Creating a Simulation Service

Now I'm ready to create the Boe-Bot simulation service. If you are following along from the code download that accompanies this article, make sure you have already installed MSRS and have placed the downloaded code in the \samples folder for the local MSRS installation.

If you are creating the project from scratch, you will need to create a new DSS service using the Visual Studio 2005 template. You can name the project SimulatedBoeBot. In addition to the assembly references mentioned earlier, you will need to add a reference to the Microsoft.Xna.Framework and to add the following namespace references to the top of the SimulatedBoeBot.cs class file:

using xna = Microsoft.Xna.Framework;
using xnagrfx = Microsoft.Xna.Framework.Graphics;
using xnaprof = Microsoft.Robotics.Simulation.MeshLoader;

The Xna framework is used by MSRS to render the entities. The Xna references will be used in the code that defines the Boe-Bot entity type. All the entity types included with MSRS are contained in the Microsoft.Robotics.Simulation.Engine namespace.

Populating the Simulation Scene

One of the primary tasks for every simulation service is to insert entities into the simulation scene. This should be done when the service starts, so typically a call to a method named PopulateWorld is added to the Start method. For the Boe-Bot simulation, the PopulateWorld method will look like this:

private void PopulateWorld()
{
     AddSky();
     AddGround();
     AddBoeBot(new Vector3(1, 0, 1));
     AddBox(new Vector3(2, 1, 1));
}

The AddSky and AddGround methods are used to set up the environment where the BoeBot will reside. For the AddSky method, a new SkyDomeEntity type is created and inserted into the simulation. A directional light, which is meant to represent the sun, is also inserted into the simulation (the code for this method is shown in Figure 10).

Figure 10 Add Sky

void AddSky()  {
    // Add a sky using a static texture. We will use the sky texture
    // to do per pixel lighting on each simulation visual entity
    SkyDomeEntity sky = new SkyDomeEntity("skydome.dds",  
                                          "sky_diff.dds");
    SimulationEngine.GlobalInstancePort.Insert(sky);

    // Add a directional light to simulate the sun.
    LightSourceEntity sun = new LightSourceEntity();
    sun.State.Name = "Sun";
    sun.Type = LightSourceEntityType.Directional;
    sun.Color = new Vector4(0.8f, 0.8f, 0.8f, 1);
    sun.Direction = new Vector3(0.5f, -.75f, 0.5f);
    SimulationEngine.GlobalInstancePort.Insert(sun);
}

The AddGround method utilizes the HeightFieldEntity type to create a large horizontal plane at zero elevation. A texture image, provided with the MSRS installation, is used to represent the ground. The code for this method is seen in the following:

void AddGround()
{
    // create a large horizontal plane, at zero elevation.
    HeightFieldEntity ground = new HeightFieldEntity(
        "simple ground", // name
        "03RamieSc.dds", // texture image
        new MaterialProperties("ground",
            0.2f, // restitution
            0.5f, // dynamic friction
            0.5f) // static friction
        );
    SimulationEngine.GlobalInstancePort.Insert(ground);
}

The next thing to add is the Boe-Bot entity. The AddBoeBot method accepts an incoming Vector3 parameter which is used to represent the robot's position. This position will be passed to the BoeBot entity constructor, which was created earlier. The AddBoeBot method will also start the simulated Boe-Bot drive service as an entity partner. The code for this method is shown here:

void AddBoeBot(Vector3 pos)
{
     BoeBot boeBot = new BoeBot(pos);
     boeBot.State.Name = "SimulatedBoeBot";

     // Start simulated Boe-Bot Drive service
     CreateService(
        drive.Contract.Identifier,
          Microsoft.Robotics.Simulation.Partners.CreateEntityPartner(
           "http://localhost/" + boeBot.State.Name));

     SimulationEngine.GlobalInstancePort.Insert(boeBot);
}

The last entity to add is a solid box used to represent an obstacle. The AddBox method will create a box-shaped entity from the Single­ShapeEntity type. See Figure 11 for the code for this method.

Figure 11 Create a Box-Shaped Entity

void AddBox(Vector3 position)
{
    Vector3 dimensions =
        new Vector3(0.2f, 0.2f, 0.2f); // meters

    // create simple movable entity, with a single shape
    SingleShapeEntity box = new SingleShapeEntity(
        new BoxShape(
            new BoxShapeProperties(
              100, // mass in kilograms.
              new Pose(), // relative pose
              dimensions)), // dimensions
              position);

    box.State.MassDensity.Mass = 0;
    box.State.MassDensity.Density = 0;

    // Name the entity. All entities must have unique names
    box.State.Name = "box";

    // Insert entity in simulation.  
    SimulationEngine.GlobalInstancePort.Insert(box);
}

Creating a Manifest

Most services will partner with other services to access data and functionality needed by the service. These partner services are referenced at the top of the implementation class using the Partner attribute. For example, the Boe-Bot simulation service will partner with the simulation engine service. The code to include this partner declaration looks like this:

//Simulation Engine Port
[Partner("Engine",
     Contract = engineproxy.Contract.Identifier,
     CreationPolicy = PartnerCreationPolicy.UseExistingOrCreate)]
private engineproxy.SimulationEnginePort _engineStub =
     new engineproxy.SimulationEnginePort();

DSS services use an XML-based file known as a manifest to list the partner services associated with a base service. This tells the MSRS runtime how the base service should load and interact with these partner services. Even though the manifest is an XML-based file and can be edited with a text-based editor, it is best to use the DSS Manifest editor that is included with MSRS. The DSS Manifest editor is a visual tool that allows you to drag and drop partner services onto a design surface. Before using the DSS Manifest editor, you will need to successfully compile the base service. This will create the assembly files used by the DSS Manifest editor.

Once the DSS Manifest editor is loaded, a list of all available services will be included in the left-hand pane. To begin, you will need to locate the base service in the list of available services and drag an instance of it onto the design surface. If you do this for the Boe-Bot simulation service, the design surface will include a node for the SimulatedBoeBot service and a sub node for the simulation engine service.

The MSRS installation includes several services in the \samples folder. One such service, the SimpleDashboard, can be used as a control panel for simulated robots. The SimpleDashboard allows you to start other services used to control specific functionality for your robot. For example, the code in the SimulatedBoeBot service simply populates the simulation scene with entities, one of which is the Boe-Bot. There is no code in the service that actually moves the robot. You borrow this code from the Drive service.

In order to load and use the simple dashboard, you must add it to the manifest by locating an instance of SimpleDashboard in the list of services and dragging it to the bottom of the design surface. The end result should look like Figure 12. The last thing to do is to save the manifest to the project directory of the Simulated­BoeBot service and overwrite the manifest named SimulatedBoeBot.mainfest.xml.

fig12.gif

Figure 12 Final Version of the Manifest in the DSS Manifest Editor

Running the Simulation

You are now ready to run the SimulatedBoeBot service. This can be done by simply clicking Debug and Run from the Visual Studio 2005 menu. At first, a command prompt window should appear.

Once the service has loaded, two additional windows should appear. The interface for the Simple Dashboard is a Windows form that includes several group boxes. The right-hand side of the form (see Figure 13) includes a group box titled Remote Node. To begin, you will need to enter the name of your local machine (localhost) in the machine textbox and click Connect. This will initiate a connection with the SimulatedBoeBot service and will load entity partner services, such as the drive service that is shown in the directory listbox.

fig13.gif

Figure 13 Drive the Boe-Bot in a Virtual World

The drive service is used to send power to the wheels that control the Boe-Bot. This allows you to move the Boe-Bot around the simulation using either the virtual joystick control or an actual joystick connected to your computer. To begin, you will need to double-click the SimulatedBoeBot item that appears in the listbox. You can then use your mouse to drag the round virtual joystick control located in the top left-hand corner of the Simple Dashboard form.

It may take you a while to get used to using the virtual joystick control (see Figure 14 to see what the simulation should look like). Practice moving the Boe-Bot around and seeing how it reacts when it collides with the box obstacle. You can then go into edit mode, select one of the entities, and adjust some of the properties to see how the entity is affected. Take some time experimenting with the simulation environment to get a feel for how it works.

fig14.gif

Figure 14 Operate a Simulated Boe-Bot in a Virtual World

Building an Entity without a Differential Drive

In this article, I covered how to create a new robot entity named the Boe-Bot. Because the Boe-Bot uses a differential drive system to control the robots wheels, I was able to create an entity type that derived from the DifferentialDriveEntity class. This allowed me to reuse code provided by MSRS to control a robot that uses this type of drive system.

If you wanted to simulate a robot that used a different drive system, you would need to first add a class that represented that drive system. For example, some robots use what is known as a tricycle drive system. In this case, a single front wheel is used to move the robot, and two side wheels connected to a separate motor are used to steer the robot in either direction.

In order to allow for this type of system in the simulated or physical world, you would need to create a class that accounted for this type of drive system. The steps to do this are beyond the scope of this article, but MSRS does allow you to provide for this type of scenario. This type of expandability is part of what makes MSRS so valuable for robotics researchers. MSRS can be expanded to support any type of hardware platform.

Sara Morgan is a 2007 Microsoft MVP for Office Communications Server. Her first book, Building Intelligent .NET Applications, was published in 2005. In addition to co-authoring several Microsoft Training Kits, she recently published Programming Microsoft Robotics Studio. She currently works as a Robotic Software Engineer at CoroWare.com.