Hello everyone,

I have problems using Graphics2dProxy on PLayer 3.0.2/Stage 4.1.1. 

This is the context of my program: I have two robots and two land marks in a world (first world), and I want to see in other world (It's a different stage window, second world), where the first robot is in the coordinates center (0,0), all things that are around it (second robot and landmarks).

I get no errors but I can't see in the second world that I am typing in the .cc file using Graphics2dProxy, in this case just is a square (It's a simple test).

Could someone help me?

Thank you in advance.


This is my code:

-----------------------------------------------------------------------------------------
First World  .cfg

# load the Stage plugin simulation driver
driver
(
  name "stage"
  provides [ "simulation:0" ]
  plugin "stageplugin"

  # load the named file into the simulator
  worldfile "simple.world"
)

driver
(
  name "stage"
  provides ["graphics2d:0"]
  model "rink"
)

# Create a Stage driver and attach position2d and laser interfaces 
# to the model "nx1"
driver
  name "stage"
  provides [ "odometry::6668:position2d:0" "6668:ranger:0" "6668:blobfinder:0"]
  model "nx1" 
  alwayson 1
)

# Create a Stage driver and attach position2d and laser interfaces 
# to the model "nx2"
driver
  name "stage"
  provides [ "odometry::6672:position2d:0" "6672:ranger:0" "6672:blobfinder:0"]
  model "nx2" 
  alwayson 1
)


-----------------------------------------------------------------------------------------
First World  simple.world

include "incs/map.inc"
include "incs/pioneer.inc"
include "incs/intruder.inc"




# configure the GUI window
window
(
  size [ 700 688 ]
  

  scale 70.738


  # GUI options
  show_data 0
  show_flags 1
  show_blocks 1
  show_clock 1
  show_footprints 0
  show_grid 1
  show_trailarrows 0
  show_trailrise 0
  show_trailfast 0
  show_occupancy 0
  pcam_on 0
  screenshots 0
)

# load an environment bitmap
floorplan
(
   bitmap "bitmaps/rink.png"
   size [20.000 20.000 0.400]
   name "rink"
)

pioneer2dx
(  
  # can refer to the robot by this name
  name "nx1"
  color "red"
  pose [ -1.000 5.000 0.000 0.000 ] 

# draw a nose on the robot so we can see which way it points
  gui_nose 1

  nxbots_eyes()
)

pioneer2dx
(  
  # can refer to the robot by this name
  name "nx2"
  color "blue"
  pose [ -1.000 2.000 0.000 25.000 ] 

# draw a nose on the robot so we can see which way it points
  gui_nose 1

  nxbots_eyes()
)

#create an intruder
intruder
(
name "int1"
color "green"
pose [3.000 2.000 0.000 0.000]
)

#create an intruder
intruder
(
name "int2"
color "yellow"
# color "blue"
pose [3.000 6.000 0.000 0.000]
)

#create an intruder
intruder
(
name "int3"
color "red"
pose [13.394 -4.606 0.000 0.000]
)


-----------------------------------------------------------------------------------------
Second World  .cfg

# load the Stage plugin simulation driver
driver
(
  name "stage"
  provides ["6700:simulation:0"]
  plugin "stageplugin"

  # load the named file into the simulator
  worldfile "robot1.world"
)


driver
(
  name "stage"
  provides ["6700:graphics2d:0"]
  model "rink"
)

-----------------------------------------------------------------------------------------
Second World  robot1.world

include "../incs/map.inc"
include "../incs/pioneer.inc"
include "../incs/intruder.inc"


# configure the GUI window
window
(
  size [ 700 688 ]
  
  # camera options
#  center [ -50.0 0.0 ]
#  rotate [ 0.000 0.000 ]
  scale 70.738

  # perspective camera options
#  pcam_loc [ 0 -4 2 ]
#  pcam_angle [ 70 0 ]

  # GUI options
  show_data 0
  show_flags 1
  show_blocks 1
  show_clock 1
  show_footprints 0
  show_grid 1
  show_trailarrows 0
  show_trailrise 0
  show_trailfast 0
  show_occupancy 0
  pcam_on 0
  screenshots 0
)

# load an environment bitmap
floorplan
(
   bitmap "../bitmaps/rink.png"
   size [20.000 20.000 0.400]
   name "rink"
)


pioneer2dx
(  
  # can refer to the robot by this name
  name "nx1"
  color "red"
  pose [ 0.000 0.000 0.000 0.000 ] 

# draw a nose on the robot so we can see which way it points
  gui_nose 1

  nxbots_eyes()
)


-----------------------------------------------------------------------------------------
.cc File


#include <iostream>
#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <fstream>
#include <stdlib.h>
#include "libplayerc/playerc.h"
#include <libplayerc++/playerc++.h>
#include "libplayerc++/clientproxy.h"
#include "libplayerc++/playerclient.h"


#define PI 3.1415926535897932384626

  using namespace PlayerCc;
  using namespace std;



int main(int argc, char *argv[])
{
PlayerClient sim1("localhost",6700);
// PlayerClient sim2("localhost",6702);

PlayerClient robot1("localhost",6668);
PlayerClient robot2("localhost",6672);
// PlayerClient simul("localhost",6665);

// SimulationProxy sp(&simul,0);

// simul.SetDataMode(PLAYER_DATAMODE_PULL);
// simul.SetReplaceRule(true,5,-1,-1);


BlobfinderProxy bfp1(&robot1,0);
RangerProxy sonarp1(&robot1,0);
Position2dProxy pp1(&robot1,0);
Graphics2dProxy gp1(&sim1,0);


robot1.SetDataMode(PLAYER_DATAMODE_PULL);
robot1.SetReplaceRule(true,5,-1,-1);
sim1.SetDataMode(PLAYER_DATAMODE_PULL);
sim1.SetReplaceRule(true,5,-1,-1);

BlobfinderProxy bfp2(&robot2,0);
RangerProxy sonarp2(&robot2,0);  
Position2dProxy pp2(&robot2,0);
// Graphics2dProxy gp2(&sim2,0);

robot2.SetDataMode(PLAYER_DATAMODE_PULL);
robot2.SetReplaceRule(true,5,-1,-1);
// sim2.SetDataMode(PLAYER_DATAMODE_PULL);
// sim2.SetReplaceRule(true,5,-1,-1); 


for(;;)
 {
///*

// read from proxies  robot1
robot1.Read();  

// read from proxies  robot2
robot2.Read();  

player_point_2d_t pts[4];

player_point_2d_t pt1;
player_point_2d_t pt2;
player_point_2d_t pt3;
player_point_2d_t pt4;

pt1.px = 2;
pt1.py = 0;
pt2.px = 3;
pt2.py = 0;
pt3.px = 3;
pt3.py = 1;
pt4.px = 2;
pt4.py = 1;

pts[0] = pt1;
pts[1] = pt2;
pts[2] = pt3;
pts[3] = pt4;
 


player_color_t  miColor;
miColor.red = 255;
miColor.blue = 255;
miColor.green = 0;


gp1.DrawPolygon(pts,4,true,miColor);
//*/
 }

}




William Díaz Castro
Student of Electronic Engineering
Universidad del Valle
Santiago de Cali - Colombia
correo:  williamdc5@hotmail.com