On 04/28/2011 07:24 AM, Abqori Aula wrote:
Hi all,

I wanted to use SetPose2d to set robot's position to a certain position I desire.
I made a cpp code that could run multiple robot model through the use of calling the robot's port, ./code -p 6665, ./code -p 6666, and so on.
After reading the mailing-list archive I finally udnerstand how to use SetPose2d:
sp.SetPose2d( (char *)string("robot1").c_str(),x,y, (o- DTOR(90)));

My question is: how should I call the robot's name without typing it one-by-one in SetPose2d? Or is there another way?
Because I want to make the cpp code 'universal'.
So that if I run each robot by calling its port number, for example port 6668 belongs to robot3
the function SetPose2d will reposition robot model "robot3", and so on.

Hence I don't have to retype this part of the code
(char *)string("robot3").c_str()

So later it might be looks like this:
string robot = getRobotName(); 
sp.SetPose2d( (char *)string(robot).c_str(),x,y, (o- DTOR(90)));

I hope I made myself clear enough because I'm not English :)
Thank you very much.

As far as I know there isn't a way to ask for a list of model names via the simulation interface.  You could:

1. Add the robot model name as a command line parameter

2. Hard-code the robot names and corresponding ports in the program somewhere, and look up the appropriate name based on the port you supplied on the command line

3. Modify Player and Stage to support passing a list of model names through the simulation interface.