|
WorldController allows to create, move, animate and delete object dynamically, that is during the simulation.
Before using any WorldController command, you must create it in the map. Open a connection with the USARSim server and send the same command you use to create any other robot:
INIT {ClassName USARBot.WorldController} {Name WC} {Location x,y,z}
where x,y,z is any location in the map, typically near the ceiling. The WorldController is not visible by other robots and does not collide, so it does not interfere with the simulation. Its presence in the map is identified by a cube mesh:
All WorldController commands start with:
CONTROL {Type commandType}...
where Type is... the command type :-)
You can create static objects in the world. Static means that they are not subject to physics. These static objects must have a script that subclasses from WCObject and references a StaticMesh with a collision primitive. This means that if you want to create some kind of object, you have first to create a script for it. The WorldController already comes with a collection of objects that should be suficcient to create simple worlds.
To create the object you send this command to the WorldController:
CONTROL {Type Create} {ClassName class} {Name name} {Location x,y,z} {Rotation x,y,z}
where ClassName is the script name, Name is an unique identifier for that object, Location is the x,y,z creation point, in meters, and Rotation x,y,z are angles in radians.
Example:
When you disconnect, the WorldController will be destroyed like any other robot. All the objects created with the WorldController will be destroyed if cleanOnClose configuration variable is set to true. If it's set to false then all the objects will remain in the world. You can set this variable in the [USARBot.WorldController] section of USARBot.ini file. You can, for example, set it to false and use the WorldController only to spawn objects in the map. Then you disconnect the WorldController and continue to use the dynamically created map. You can always connect, later, another WorldController, remove all the objects (see Killing Objects) and create new ones.
Optional Values:
Location and Rotation are optional. If not specified they will default to (0,0,0).
Important:
The Name string will be used to reference the object by all the other WorldController commands. So it must be an unique value. The controller will not accept create commands without a name or with a duplicate name.
P2DXDummy. It has collision primitives so it can collide with robots and is seen by robot sensors (like laser). |
If you want to remove an object from the world use this command:
CONTROL {Type Kill} {Name name}
where Name is the object name you assigned to it in the creation process. This command is valid only for objects owned by the currently active WorldController. You cannot delete objects created by another WorldController. There is, however, a command that removes all the WCObjects in the map:
CONTROL {Type KillAll}
This is the only command that does not accept a Name as parameter. It will delete all the WCObjects that are in the map. It can be used, for example, to clean the map created by another WorldController.
Examples:
CONTROL {Type Kill} {Name P2DX}
CONTROL {Type KillAll}
The WorldController allows to move created objects and robots. Command syntax is:
CONTROL {Type AbsMove} {Name name} {Location x,y,z} {Rotation x,y,z}
if you want to make an absolute movement, or:
CONTROL {Type RelMove} {Name name} {Location x,y,z} {Rotation x,y,z}
if you want to make a relative movement.
Name references the object, or robot name, you want to move.
Examples:
If you have a robot named "RobotA" in the map, you can use these commands to move it. Example:
You can also move robots that were created before the WorldController.
Optional Values:
Location and Rotation are optional. If not specified they will default to:
Important:
Robot movement is limited. You cannot rotate it, you can only translate it (it will maintain rotation). Moreover, if you translate it by a value lower than 1m it will not move exactly to the desired location but will stop earlier. Only in a client/server simulation the movement will be almost precise with distances lower than 1m (thanks to replication iterations). Rotation can be implemented, and I actually did it, however it's very unreliable in client only mode. That's why I excluded it from the code.
This video shows how it's possible to interact with robots (and other Karma objects):
You can set a rotation speed for an object with the following command:
CONTROL {Type Rotate} {Name name} {Speed x,y,z}
Where Name is the object name you assigned to it in the creation process and Speed is its angular speed in rad/s. To stop the rotation set speed to 0,0,0.
It is possible to assign waypoints to an object and have it to move along them. In the following image you can see the assigned waypoints (the red dots) to an object that has the shape of the P2DX robot. When the object will receive the movement command it will move following the red path (red arrows).
Video examples:
You can put these waypoints anywhere in the 3D space, add them while the object is moving, delete them or replace the whole waypoints set at once.
Important: you can use waypoints only with already created objects.
The main command to set waypoints is:
CONTROL {Type SetWP} {Name name} {Speed s} {Time t} {Move <true/false>} {Autoalign <true/false>} {Show <true/false>} {Loop <true/false>} {ResetOnClear <true/false>} {WP x,y,z;x,y,z;...}
Only Name is really required, all the other parameters are optional. With this command you set the internal state used by the WorldController to move the objects. That means that you can use a parameter in one command and later another parameter in another command without loosing the first setting you made. Let's see what all the parameters do:
Examples (I assume that an object named "A" was already created with the creation command):
CONTROL {Type SetWP} {Name A} {WP 0,0,0; 1,1,-1; 1,2,-1} //assigns 3 waypoints to the object A
CONTROL {Type SetWP} {Name A} {Show true} {Autoalign true} //shows the waypoints and enables the autoalignement
CONTROL {Type SetWP} {Name A} {Speed 1} {Move true} //move the object at speed 1m/s
CONTROL {Type SetWP} {Name A} {Loop true} //enables the looped mode
All those commands may be given with a single string:
CONTROL {Type SetWP} {Name A} {Show true} {Autoalign true} {Speed 1} {Move true} {Loop true} {WP 0,0,0; 1,1,-1; 1,2,-1}
so you are completely free to set what you want when you want. You can for example start with not looped movement and later activate the looped mode. You can modify any parameter at any time.
Optional Values:
Speed, Time, Move, Autoalign, Show, Loop, ResetOnClear andWP are all optional values.
The command to add new waypoints to the existing ones is:
CONTROL {Type AddWP} {Name name} {WP x,y,z;x,y,z;...}
where WP is a list of new waypoint coordinates that will be added at the end of the curent ones.
If you want to completely remove waypoints for an object, use this command:
CONTROL {Type ClearWP} {Name name}
If the ResetOnClear parameter was set to true then the object position and rotation will be reset to the starting position and rotation when the object was created. If false then the object will maintain the current position and orientation. It means that the object will freeze wherever it is.
These are the objects that you get with WorldController:
You can also use these objects as regular static meshes when building a world in Unreal Editor.
I will use Z for height, Y for width, X for depth and T for thickness. I use these names because width is along Y axis, depth along X and height along (-) Z.
Panel You can use panels to make walls. It allows to make a maze, rooms, corridors etc. Z: 1m - X: 1m - T: 2cm. ClassName = USARModels.Panel1m1m |
Panel L Use L panels alone or in conjunction with regular panels to define walls. Z: 1m - X: 1m - Y: 1m - T: 2cm. ClassName = USARModels.PanelL1m1m |
Box You can use boxes with panels to make walls. Z: 1m - X: 1m - Y: 1m. ClassName = USARModels.Box1m |
Ramps The 2 ramps provided here are a replica of RoboCup Rescue real ramps. Y: 1m - X: 1m - 10°. ClassName = USARModels.Ramp1m1m10d |
Tables These tables are a replica of tables used in the RoboCup Rescue real arena. Z: 0.5m - Y: 1m - X: 1m. ClassName = USARModels.Table1m1m05m |
Stairs With this stair you can climb on the 1m height table. You can combine more stairs to reach higher destinations. For example you can put a stair in (0,0,0) and another one in (1.25,0,-1) to create a 2m height stair. Z: 1m - X: 1.25m - Y: 1m. ClassName = USARModels.Stairs1m |
StepField You can use these blocks to make random step fields. Z: 5cm - Y: 10cm - X: 10cm. ClassName = USARModels.Step5c |
Pillar These are general purpose objects. Use them to make random obstacles, to create pillars in a room etc. Z: 0.5m - Y: 10cm - X: 10cm. ClassName = USARModels.Pillar10c05m |
WoodFrame General purpose wood frames. You can use panles, ramps, tables, steps, stairs and these frames to completely replicate the real rescue arena. Z: 16cm - Y: 1m - X: 1m. ClassName = USARModels.WoodFrame1m1m |
If you need the static mesh and texture libraries that include the above meshes, you can download them here:
WorldControllerSM.7z