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.
If you have not already done so, now would be a good time to download and install the MSRS toolkit available at go. This includes the full version of MSRS 1. 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. 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.
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. 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.
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.
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. 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. 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.
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.
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. This will bring up the New Entity dialog box see Figure 3. This means you can add a new Create robot to your simulation by simply using the New Entity dialog box. MSRS offers more than one way to create and work with simulations. 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. After adding the references, you will need to add the following namespace declarations to the implementation class file:. To understand what code is needed for your simulation, you should first examine the simulation tutorials provided with MSRS. For example, the basic simulation environment is the same as the SimulationTutorial1 project.
If you open the SimulationTutorial1 project using Visual Studio , 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:.
The Start method is where you add code to define your simulation environment. 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. 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.
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.
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. This means the MSRS installation includes the basic services used to operate the Boe-Bot's drive system and built-in contact sensors.
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. 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. 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. 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. 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. The files associated with this mesh are included with the downloadable. To follow along with the article, download the.
SoftImage is capable of exporting the image to the. Not all packages are capable of doing this. For example, SolidWorks see solidworks.
Unfortunately, SolidWorks is not capable of exporting to the. 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. MSRS offers a command-line tool that is capable of converting an.
I won't spend any time on assembly because the Boe-Bot manual explains that topic thoroughly. It is possible that your computer does not have a serial port. In any case, after the initial tests and program load you'll use the Bluetooth module to drive the robot, which allows it a broader range of motion.
You'll also need some standard AA-size batteries to power the robot see the sidebar " Avoid Using Rechargeable Batteries ". There are several models available. The more expensive adapters have a longer range. This model is specifically featured in the electronic setup manual for the eb Bluetooth module. You may need to refer to this manual if you have trouble communicating with the Bluetooth module. Working with Microsoft Robotics Studio Figure 1.
If you are not familiar with Robotics Studio, you may want to refer to my earlier article " An Introduction to Programming with Microsoft Robotics Studio. That document walks you through the additional steps required to get your robot working with the Bluetooth module and Robotics Studio.
When assembled, the Boe-Bot should look like Figure 1. Instead, you must download them from the Parallax web site. The downloaded zip file contains four files with a. You use this program to verify that the Boe-Bot's lights turn on and off and that it can travel a short distance, rotate left and right, and then move backwards again. Performing this test successfully ensures that the Boe-Bot is functioning properly and that you did not mix up the motor cables. Next Page.
Other Articles by this Author. Acceptable Use Policy. Advertiser Disclosure:. Close Icon. Thanks for your registration, follow us on our social networks to keep up-to-date.
Google Plus. Devx Feed. Site Logo Site Logo. Search Submit Advertiser Disclosure. Research Center. Web Dev. Open Source.
0コメント