Mitali,
 Hmm, thanks for an interesting problem.
 Here's your solution - you've got one simulation proxy (on port 6665) but your code is trying to connect to a simulation proxy on 6666 (for ghost1) or 6667 (for ghost2).  There is (only) one sim proxy for each simulation.

So you connect to the sim proxy on 6665, and the pos2d proxy on 6666 or 7.  This does require the use of the mclient versions, as shown below.
Regards,
 --kn

ghost1.c

#include <libplayerc/playerc.h>
int main(int argc, const char **argv)
{
    int i;
    playerc_client_t *simclient, *client;
    playerc_mclient_t *mclient;
    playerc_position2d_t *position2d;
    playerc_simulation_t *sim;
    double pacmanX, pacmanY, pacmanA;
    double ghostX, ghostY, ghostA;
    double turn, speed;

    // Create a client and connect it to the server.
    mclient = playerc_mclient_create();
    simclient = playerc_client_create(mclient, "localhost", 6665);
    client = playerc_client_create(mclient, "localhost", 6666);
    if (0 != playerc_client_connect(client) + playerc_client_connect(simclient))
        return -1;

    // Create and subscribe to a position2d device.
    position2d = playerc_position2d_create(client, 0);
    if (playerc_position2d_subscribe(position2d, PLAYER_OPEN_MODE))
        return -1;

    // Create and subscribe to a simulation interface device.
    sim = playerc_simulation_create(simclient, 0);
    if (playerc_simulation_subscribe(sim, PLAYER_OPEN_MODE))
        return -1;

   for (;;)
    {
        // Wait for new data from server
        playerc_mclient_read(mclient,100);
        // Read pacman's & ghost's global pose via simulation interface
        playerc_simulation_get_pose2d(sim, (char *)"pacman", &pacmanX, &pacmanY, &pacmanA);
        printf("pm = (%.0f,%.0f,%.0f)\t",pacmanX,pacmanY,pacmanA);
        playerc_simulation_get_pose2d(sim, (char *)"ghost1", &ghostX, &ghostY, &ghostA);
        printf("g1 = (%.0f,%.0f,%.0f)\t",ghostX,ghostY,ghostA);
        playerc_simulation_get_pose2d(sim, (char *)"ghost2", &ghostX, &ghostY, &ghostA);
        printf("g2 = (%.0f,%.0f,%.0f)\n",ghostX,ghostY,ghostA);

        //run(pacmanX, pacmanY, pacmanA, ghostX, ghostY, &speed, &turn);
        speed = 1;

        playerc_position2d_set_cmd_vel(position2d, speed, 0, 0,1);
            //return -1;

    }

    // Shutdown
    playerc_simulation_unsubscribe(sim);
    playerc_simulation_destroy(sim);
    playerc_position2d_unsubscribe(position2d);
    playerc_position2d_destroy(position2d);
    playerc_client_disconnect(client);
    playerc_client_disconnect(simclient);
    playerc_mclient_destroy(mclient);

    return 0;
}



On Mon, Sep 9, 2013 at 9:06 AM, Mitali Sodhi <mitalisodhi.ec@gmail.com> wrote:
The connection for pacman, ghost1 and ghost2 are in their respective .c files. The main for each of them is as follows:
1. Pacman:

int
main(int argc, const char **argv)
{
int i;
playerc_client_t *client;
double pacmanX, pacmanY, pacmanA;
double ghostX, ghostY, ghostA;
double turn, speed;

// Create a client and connect it to the server.
client = playerc_client_create(NULL, "localhost", 6665);
if (0 != playerc_client_connect(client))
return -1;

// Create and subscribe to a position2d device.
position2d = playerc_position2d_create(client, 0);
if (playerc_position2d_subscribe(position2d, PLAYER_OPEN_MODE))
return -1;

// Create and subscribe to a simulation interface device.
sim = playerc_simulation_create(client, 0);
if (playerc_simulation_subscribe(sim, PLAYER_OPEN_MODE))
return -1;
for (;;)
{
// Wait for new data from server
playerc_client_read(client);
// Read pacman's & ghost's global pose via simulation interface
playerc_simulation_get_pose2d(sim, "pacman", &pacmanX, &pacmanY, &pacmanA);
playerc_simulation_get_pose2d(sim, "ghost1", &ghostX, &ghostY, &ghostA);

run(pacmanX, pacmanY, pacmanA, ghostX, ghostY, &speed, &turn);

playerc_position2d_set_cmd_vel(position2d, speed, 0, 0,1);
//return -1;

}

// Shutdown
playerc_simulation_unsubscribe(sim);
playerc_simulation_destroy(sim);
playerc_position2d_unsubscribe(position2d);
playerc_position2d_destroy(position2d);
playerc_client_disconnect(client);
playerc_client_destroy(client);

return 0;
}

2. Ghost1

client = playerc_client_create(NULL, "localhost", 6666);
if (0 != playerc_client_connect(client))
return -1;

// Create and subscribe to a position2d device.
position2d = playerc_position2d_create(client, 0);
if (playerc_position2d_subscribe(position2d, PLAYER_OPEN_MODE))
return -1;

// Create and subscribe to a simulation interface.
sim = playerc_simulation_create(client,0 );
if (playerc_simulation_subscribe(sim, PLAYER_OPEN_MODE))
return -1;

for (;;)
{
// Wait for new data from server
playerc_client_read(client);

usleep(1000);
// Read pacman's & ghost's global pose via simulation interface
playerc_simulation_get_pose2d(sim, "pacman", &pacmanX, &pacmanY, &pacmanA);
playerc_simulation_get_pose2d(sim, "ghost1", &ghostX, &ghostY, &ghostA);

run(ghostX, ghostY, ghostA, pacmanX, pacmanY, &speed, &turn);

//if(0 != playerc_position2d_set_cmd_vel(position2d, speed, speed, turn,1))
if(0 != playerc_position2d_set_cmd_vel(position2d, 0.5, speed, turn,1))
return -1;

}

// Shutdown
playerc_simulation_unsubscribe(sim);
playerc_simulation_destroy(sim);
playerc_position2d_unsubscribe(position2d);
playerc_position2d_destroy(position2d);
playerc_client_disconnect(client);
playerc_client_destroy(client);

3. Ghost2

// Create a client and connect it to the server.
client = playerc_client_create(NULL, "localhost", 6667);
if (0 != playerc_client_connect(client))
return -1;

// Create and subscribe to a position2d device.
position2d = playerc_position2d_create(client, 0);
if (playerc_position2d_subscribe(position2d, PLAYER_OPEN_MODE))
return -1;

// Create and subscribe to a simulation interface.
sim = playerc_simulation_create(client,0 );
if (playerc_simulation_subscribe(sim, PLAYER_OPEN_MODE))
return -1;

for (;;)
{
// Wait for new data from server
playerc_client_read(client);

// Read pacman's & ghost's global pose via simulation interface
playerc_simulation_get_pose2d(sim, "pacman", &pacmanX, &pacmanY, &pacmanA);
playerc_simulation_get_pose2d(sim, "ghost2", &ghostX, &ghostY, &ghostA);

run(ghostX, ghostY, ghostA, pacmanX, pacmanY, &speed, &turn);

if(0 != playerc_position2d_set_cmd_vel(position2d, speed, speed, turn,1))
return -1;

}

// Shutdown
playerc_simulation_unsubscribe(sim);
playerc_simulation_destroy(sim);
playerc_position2d_unsubscribe(position2d);
playerc_position2d_destroy(position2d);
playerc_client_disconnect(client);
playerc_client_destroy(client);


On Mon, Sep 9, 2013 at 7:32 PM, Mitali Sodhi <mitalisodhi.ec@gmail.com> wrote:
I think my previous message is not getting published. So, here is my world file:

resolution 0.02

#include "pioneer.inc"
include "irobot.inc"
include "map.inc"
include "sick.inc"

interval_sim 100  # simulation timestep in milliseconds
interval_real 100  # real-time interval between simulation updates in milliseconds 

paused 1

# configure the GUI window
window
(
  size [ 700.000 524.000 ] # in pixels
  scale 30.000             # pixels per meter
  show_data 1              # 1=on 0=off
)

# load an environment bitmap
floorplan
  name "cave"
  size [16.000 16.000 0.600]
  bitmap "game-area.png"
)

#pioneer2dx
define roomba-mod roomba
(
size [2.0 2.0 1]
bitmap "pacman.png"
)


roomba-mod
(
name "pacman"
color "yellow"
pose [ -6.0 -6.0 0 0 ] 
)

roomba-mod
(
name "ghost1"
color "red"
pose [ 0.0 6.0 0 0 ] 
)

roomba-mod
(
name "ghost2"
color "red"
pose [ 6.0 -6.0 0 0 ] 
)


On Mon, Sep 9, 2013 at 7:23 PM, Mitali Sodhi <mitalisodhi.ec@gmail.com> wrote:
Thanks for the reply. 
Here is the attached code. Kindly look into it.


On Mon, Sep 9, 2013 at 5:57 PM, Rich Mattes <jpgr87@gmail.com> wrote:
On 09/09/2013 01:46 AM, Mitali Sodhi wrote:
Thanks for the reply. That was a typing error.

Here is my .cfg file. 

# Desc: Player sample configuration file for controlling Stage devices
# Author:  Richard Vaughan
# Date: 1 December 2004

# CVS: $Id: simple.cfg,v 1.35 2008-01-15 01:25:42 rtv Exp $


# load the Stage plugin simulation driver

driver
(   
  name "stage"
  provides [ "simulation:0"]
  plugin "stageplugin"
  worldfile "pacman.world"  
)

# Create a Stage driver and attach position2d interfaces 
# to the model "robot1"

driver
  name "stage"
  provides [ "6665:position2d:0" ]
  model "pacman" 
)


driver
  name "stage"
  provides ["6666:position2d:0" ]
  model "ghost1" 
)

driver
  name "stage"
  provides ["6667:position2d:0" ]
  model "ghost2" 
)


I am still getting the same error.




The "playerc error : got NACK from request" output isn't really an error, it just means that playerc sent a request message that the underlying driver didn't understand.  I think there are a couple of requests, like position2d_geometry, that stage's position2d driver doesn't implement.  That's not a big deal.

However, in order to know what's going on with your client programs, we'd have to see the code you're using to initialize playerc and connect to the Player server.  It would also be good if you shared your Stage world file so we can make sure there's no errors in how the ghost robots are declared.

Rich

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Playerstage-users mailing list
Playerstage-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-users





------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Playerstage-users mailing list
Playerstage-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-users




--
Kevin Nickels <knickels@trinity.edu>
http://www.trinity.edu/knickels 210-999-7543
Associate Professor, Engineering Science, Trinity University
139 Oakmont Ct (Engineering House), Rm 203, San Antonio TX 78212-7200