MSDN Magazine - June 2008 - (Page 68) 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); 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 } Service template. Therefore, you will need to add references to the assemblies listed in Figure 5. After adding the references, you will need to add the following namespace declarations to the implementation class file: using using using using using Microsoft.Robotics.Simulation; Microsoft.Robotics.Simulation.Engine; engineproxy = Microsoft.Robotics.Simulation.Engine.Proxy; Microsoft.Robotics.Simulation.Physics; Microsoft.Robotics.PhysicalModel; 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. 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 builtin contact sensors. While MSRS includes the platform services for the Boe-Bot, it does not actually include a Boe-Bot entity type. To create a new entity type for the Boe-Bot, I need to add a class that derives from the DifferentialDriveEntity. By deriving from To understand what code is needed for your simulation, you the DifferentialDriveEntity class, I’m able to reuse code that deshould first examine the simulation tutorials provided with MSRS. fines how the Boe-Bot should behave when it is moving through The samples provided in the \samples\simulation tutorials directory a simulation. The code used to create the BoeBot entity type is from the MSRS installation correspond to the simulations available shown in Figure 8. from the MSRS installed menu. For example, the basic simulation The constructor for the BoeBot class is used to set values for sevenvironment is the same as the SimulationTutorial1 project. eral variables defined in the DifferentialDriveEntity class. For exIf you open the SimulationTutorial1 project using Visual Studio ample, the Mass is set with a value of 0.454, which represents the 2005, you can view the code used to create the basic simulation en- mass in kilograms. Additionally, the Boe-Bot chassis is defined in vironment. The first thing to notice is the Start method, which is terms of the width, length, and height. These measurements were called automatically when a service is started: obtained by weighing the actual robot and measuring it using a protected override void Start() metric tape measure. { base.Start(); The position of the Boe-Bot is defined through a set of coordi// Orient sim camera view point nates that are passed in when the entity is created. These coordiSetupCamera(); // Add objects (entities) in our simulated world nates represent the X, Y, and Z axis points. The MSRS simulation PopulateWorld(); engine uses a right-handed coordinate system, } which affects the direction toward which the The Start method is where you add code to Z axis points. define your simulation environment. For the The BoeBot constructor also defines the SimulationTutorial1 project, this involves setposition of the chassis and the wheels within ting up the camera and populating the simulathe entity. The DifferentialDriveSystem class tion scene with entity objects. makes the assumption that your robot will In addition to the main camera, the basic simhave two main wheels and a small rear wheel ulation environment contains entities used to that is mostly used for balancing. Power will represent the sky, ground, box, and world globe. be assigned to the left and right motors, which The code to insert the world globe, or textured control the main wheels. The difference between sphere, is listed in Figure 6. the power levels assigned to each wheel deterThe first line of code in the AddTexturedSphere mines whether it moves forward, backward, method creates an instance of the SingleShapeleft, or right. This is the same method used to Entity. This type represents an entity with a single drive the physical robot. geometric shape, such as a sphere, and it is useful What makes the simulation so attractive is when you need to add an entity with a very simple Figure 7 Boe-Bot by Parallax 68 msdn magazine Robotics Studio Creating an Entity Class http://parallax.com
Table of Contents Feed for the Digital Edition of MSDN Magazine - June 2008 MSDN Magazine - June 2008 Contents Toolbox CLR Inside Out Cutting Edge Patterns In Practice SAAS Concurrency Robotics Form Filler GUI Library Service Station Foundations Windows With C++ Concurrent Affairs Going Places { End Bracket } MSDN Magazine - June 2008 MSDN Magazine - June 2008 - Contents (Page Cover1) MSDN Magazine - June 2008 - Contents (Page Cover2) MSDN Magazine - June 2008 - Contents (Page 1) MSDN Magazine - June 2008 - Contents (Page 2) MSDN Magazine - June 2008 - Contents (Page 3) MSDN Magazine - June 2008 - Contents (Page 4) MSDN Magazine - June 2008 - Contents (Page 5) MSDN Magazine - June 2008 - Contents (Page 6) MSDN Magazine - June 2008 - Contents (Page 7) MSDN Magazine - June 2008 - Contents (Page 8) MSDN Magazine - June 2008 - Contents (Page 9) MSDN Magazine - June 2008 - Contents (Page 10) MSDN Magazine - June 2008 - Toolbox (Page 11) MSDN Magazine - June 2008 - Toolbox (Page 12) MSDN Magazine - June 2008 - Toolbox (Page 13) MSDN Magazine - June 2008 - Toolbox (Page 14) MSDN Magazine - June 2008 - CLR Inside Out (Page 15) MSDN Magazine - June 2008 - CLR Inside Out (Page 16) MSDN Magazine - June 2008 - CLR Inside Out (Page 17) MSDN Magazine - June 2008 - CLR Inside Out (Page 18) MSDN Magazine - June 2008 - CLR Inside Out (Page 19) MSDN Magazine - June 2008 - CLR Inside Out (Page 20) MSDN Magazine - June 2008 - CLR Inside Out (Page 21) MSDN Magazine - June 2008 - CLR Inside Out (Page 22) MSDN Magazine - June 2008 - CLR Inside Out (Page 23) MSDN Magazine - June 2008 - CLR Inside Out (Page 24) MSDN Magazine - June 2008 - Cutting Edge (Page 25) MSDN Magazine - June 2008 - Cutting Edge (Page 26) MSDN Magazine - June 2008 - Cutting Edge (Page 27) MSDN Magazine - June 2008 - Cutting Edge (Page 28) MSDN Magazine - June 2008 - Cutting Edge (Page 29) MSDN Magazine - June 2008 - Cutting Edge (Page 30) MSDN Magazine - June 2008 - Cutting Edge (Page 31) MSDN Magazine - June 2008 - Cutting Edge (Page 32) MSDN Magazine - June 2008 - Cutting Edge (Page 33) MSDN Magazine - June 2008 - Cutting Edge (Page 34) MSDN Magazine - June 2008 - Cutting Edge (Page 35) MSDN Magazine - June 2008 - Cutting Edge (Page 36) MSDN Magazine - June 2008 - Patterns In Practice (Page 37) MSDN Magazine - June 2008 - Patterns In Practice (Page 38) MSDN Magazine - June 2008 - Patterns In Practice (Page 39) MSDN Magazine - June 2008 - Patterns In Practice (Page 40) MSDN Magazine - June 2008 - Patterns In Practice (Page 41) MSDN Magazine - June 2008 - Patterns In Practice (Page 42) MSDN Magazine - June 2008 - Patterns In Practice (Page 43) MSDN Magazine - June 2008 - SAAS (Page 44) MSDN Magazine - June 2008 - SAAS (Page 45) MSDN Magazine - June 2008 - SAAS (Page 46) MSDN Magazine - June 2008 - SAAS (Page 47) MSDN Magazine - June 2008 - SAAS (Page 48) MSDN Magazine - June 2008 - SAAS (Page 49) MSDN Magazine - June 2008 - SAAS (Page 50) MSDN Magazine - June 2008 - SAAS (Page 51) MSDN Magazine - June 2008 - SAAS (Page 52) MSDN Magazine - June 2008 - SAAS (Page 53) MSDN Magazine - June 2008 - Concurrency (Page 54) MSDN Magazine - June 2008 - Concurrency (Page 55) MSDN Magazine - June 2008 - Concurrency (Page 56) MSDN Magazine - June 2008 - Concurrency (Page 57) MSDN Magazine - June 2008 - Concurrency (Page 58) MSDN Magazine - June 2008 - Concurrency (Page 59) MSDN Magazine - June 2008 - Concurrency (Page 60) MSDN Magazine - June 2008 - Concurrency (Page 61) MSDN Magazine - June 2008 - Concurrency (Page 62) MSDN Magazine - June 2008 - Concurrency (Page 63) MSDN Magazine - June 2008 - Robotics (Page 64) MSDN Magazine - June 2008 - Robotics (Page 65) MSDN Magazine - June 2008 - Robotics (Page 66) MSDN Magazine - June 2008 - Robotics (Page 67) MSDN Magazine - June 2008 - Robotics (Page 68) MSDN Magazine - June 2008 - Robotics (Page 69) MSDN Magazine - June 2008 - Robotics (Page 70) MSDN Magazine - June 2008 - Robotics (Page 71) MSDN Magazine - June 2008 - Robotics (Page 72) MSDN Magazine - June 2008 - Robotics (Page 73) MSDN Magazine - June 2008 - Robotics (Page 74) MSDN Magazine - June 2008 - Robotics (Page 75) MSDN Magazine - June 2008 - Robotics (Page 76) MSDN Magazine - June 2008 - Robotics (Page 77) MSDN Magazine - June 2008 - Robotics (Page 78) MSDN Magazine - June 2008 - Form Filler (Page 79) MSDN Magazine - June 2008 - Form Filler (Page 80) MSDN Magazine - June 2008 - Form Filler (Page 81) MSDN Magazine - June 2008 - Form Filler (Page 82) MSDN Magazine - June 2008 - Form Filler (Page 83) MSDN Magazine - June 2008 - Form Filler (Page 84) MSDN Magazine - June 2008 - Form Filler (Page 85) MSDN Magazine - June 2008 - GUI Library (Page 86) MSDN Magazine - June 2008 - GUI Library (Page 87) MSDN Magazine - June 2008 - GUI Library (Page 88) MSDN Magazine - June 2008 - GUI Library (Page 89) MSDN Magazine - June 2008 - GUI Library (Page 90) MSDN Magazine - June 2008 - GUI Library (Page 91) MSDN Magazine - June 2008 - GUI Library (Page 92) MSDN Magazine - June 2008 - GUI Library (Page 93) MSDN Magazine - June 2008 - GUI Library (Page 94) MSDN Magazine - June 2008 - GUI Library (Page 95) MSDN Magazine - June 2008 - GUI Library (Page 96) MSDN Magazine - June 2008 - Service Station (Page 97) MSDN Magazine - June 2008 - Service Station (Page 98) MSDN Magazine - June 2008 - Service Station (Page 99) MSDN Magazine - June 2008 - Service Station (Page 100) MSDN Magazine - June 2008 - Service Station (Page 101) MSDN Magazine - June 2008 - Service Station (Page 102) MSDN Magazine - June 2008 - Service Station (Page 103) MSDN Magazine - June 2008 - Service Station (Page 104) MSDN Magazine - June 2008 - Foundations (Page 105) MSDN Magazine - June 2008 - Foundations (Page 106) MSDN Magazine - June 2008 - Foundations (Page 107) MSDN Magazine - June 2008 - Foundations (Page 108) MSDN Magazine - June 2008 - Foundations (Page 109) MSDN Magazine - June 2008 - Foundations (Page 110) MSDN Magazine - June 2008 - Foundations (Page 111) MSDN Magazine - June 2008 - Foundations (Page 112) MSDN Magazine - June 2008 - Windows With C++ (Page 113) MSDN Magazine - June 2008 - Windows With C++ (Page 114) MSDN Magazine - June 2008 - Windows With C++ (Page 115) MSDN Magazine - June 2008 - Windows With C++ (Page 116) MSDN Magazine - June 2008 - Windows With C++ (Page 117) MSDN Magazine - June 2008 - Windows With C++ (Page 118) MSDN Magazine - June 2008 - Concurrent Affairs (Page 119) MSDN Magazine - June 2008 - Concurrent Affairs (Page 120) MSDN Magazine - June 2008 - Concurrent Affairs (Page 121) MSDN Magazine - June 2008 - Concurrent Affairs (Page 122) MSDN Magazine - June 2008 - Concurrent Affairs (Page 123) MSDN Magazine - June 2008 - Concurrent Affairs (Page 124) MSDN Magazine - June 2008 - Concurrent Affairs (Page 125) MSDN Magazine - June 2008 - Concurrent Affairs (Page 126) MSDN Magazine - June 2008 - Going Places (Page 127) MSDN Magazine - June 2008 - Going Places (Page 128) MSDN Magazine - June 2008 - Going Places (Page 129) MSDN Magazine - June 2008 - Going Places (Page 130) MSDN Magazine - June 2008 - Going Places (Page 131) MSDN Magazine - June 2008 - { End Bracket } (Page 132) MSDN Magazine - June 2008 - { End Bracket } (Page Cover3) MSDN Magazine - June 2008 - { End Bracket } (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.