How to get starting poses

[2007.02.15]

Introduction
Adding starting poses to the map
Retrieving starting poses


Introduction

A common question when using USARSim is: "where I spawn the robots?". Usually you can find starting positions using the editor or directly in the UT client, with the showdebug console command. This approach isn't difficult, but cannot be automated. You have always to provide starting positions manually to your robot controller. If you change the map you will need to recompile the controller or to change some initialization file. That's why we introduced in our lab the following USARSim command:

GETSTARTPOSES

After connecting to USARSim you can send this command and you'll receive a string with all available starting positions for that map. This way starting positions are a map property and the controller can chose automatically where to start the robots.


Adding starting poses to the map

You have to populate the map with starting poses. Any NavigationPoint will do, however it's much easier to use PlayerStarts because you can see and adjust the orientation in the editor:

Any map must have at least 1 PlayerStart to be a valid map. You can add as many PlayerStarts as you want. Follow these steps to add one:

In the tree view find Actor/NavigationPoint/SmallNavigationPoint/PlayerStart and select it:

Now right click in the 3D map and chose "Add PlayerStart Here":

You have just placed a PlayerStart:

You can select it, move it and rotate it like any other object in the editor (ctrl + left click + drag to move, ctrl + right click + drag to rotate). Pay attention to place it not too high otherwise if you compile the map you'll receive a warning. I placed this PlayerStart in the middle field:

Every PlayerStart defines a starting position and orientation. But, when your controller connects to USARSim, how can you chose between different starting poses? You can assign an identifier to every PlayerStart using the Tag field (double click on the PlayerStart to open the properties window):

This way you can chose standard IDs for every starting pose that will allow you to chose the right one. Now save the map and close the editor. It's not necessary to compile the map because you don't need to create a weighted bot navigation graph.

Retrieving starting poses

Now, when you connect to USARSim, you can send this command before spawning any robot:

GETSTARTPOSES

You will receive a string like this one:

NFO {StartPoses 3} {BlueGoal -2.55,-0.00,-0.19 0.00,-0.03,-0.01 MiddleField 0.01,-0.00,-0.19 0.00,0.00,0.00 YellowGoal 2.57,-0.01,-0.19 0.00,0.00,3.13}

The syntax of this string doesn't follow strictly the USARSim standard. I decided for it only because it's simpler to parse. If you don't like it, it can be changed easily :-)

StartPoses is the number of starting positions available. For every starting position you'll receive it's tag, location and orientation:

BlueGoal -2.55,-0.00,-0.19 0.00,-0.03,-0.01

where BlueGoal is the tag, (-2.55,-0.00,-0.19) is the location and (0.00,-0.03,-0.01) is the orientation.

If there are no starting positions defined (that's bad because a map must have at least 1 PlayerStart), you'll receive:

NFO {StartPoses 0}