With the EntityNameSprite, we can display a text in the simulation window attached to our robots. The name is painted on a texture with a textureWidth and Height. We can set the font name and size. Finally we'll specify the Pose(location) of the display and the size in the simulator.
Using the EntityNameSprite from the Visual Simulation Engine
- Start a simulation with a robot with a camera (for instance a Pioneer 3DX)
- Go to Edit mode (Mode menu, choose edit)
- Entity Menu -> New...
- Choose EntityNameSprite, and as a parent the "P3DXMotorBase"
- Set the (font) family to "Verdana"
- Fontsize to "36"
- Set Height and Width (e.g. 0.1 height and 0.6 width) for the simulated display
- textureHeight and textureWidth (e.g. 100 and 600)
- Set Initial Pos (0,1,0) is 1 meter above the parent
- Pivot Y-axis or Center to make the view visible while turning the robot
- Press "OK" and choose "Mode -> Run"
Using the EntityNameSprite from code
EntityNameSprite nameSprite = new EntityNameSprite(0.6f, 0.1f, 600, 100, SpritePivotType.Center, new Vector3(0, 1.0f, 0), "Verdana", 36);
nameSprite.State.Name = "myNameSprite";
Troubleshooting and tips
Only partial text is displayed: reduce font size or increase texture size.
Keep the ratio between texture height/width and height/width the same for the best result.
The "Pose" in the simulation "Entity -> New" screen is global, not relative to the robot. Move the robot to 0,0,0 and then insert for precise location.
back
Posted
01-08-2008 15:56
by
Erik Oppedijk