Hello,
I've got a client written using the latest javaclient SVN connecting
to a Player server (version 2.0.4) that all it does is try and read
localized hypothesis and print the resulting pose's Xs, Ys & angles.
However it doesn't act as expected. Using Stage for my sim, no matter
where I put my robot the X value ALWAYS reads "1.4E-45", but the Y
value seems to be correct. In addition the angle (using getPa() )
seems to return the X value instead of the angle (seems odd!). Not
only that, but for some reason my calls to "isDataReady" always fail
after one success...
I've implemented a similar client in c++ for reference to check to see
if was a problem with my socket/server/etc and it seems to work just
fine (the c++ code is also found below)
PS I'm new to Player's javaclient implementation so if I did something
stupid cut me some slack ;-)
Jeff
---------------------------------------- java source
---------------------------------------------
import javaclient2.*;
import javaclient2.structures.PlayerConstants;
import javaclient2.structures.PlayerPose;
import javaclient2.structures.localize.PlayerLocalizeHypoth;
public class TestClient {
public static void main(String[] args)
{
PlayerClient robot = new PlayerClient("localhost", 6665);
LocalizeInterface loc = robot.requestInterfaceLocalize(0,
PlayerConstants.PLAYER_OPEN_MODE);
PlayerPose pose = new PlayerPose();
for(;;) {
robot.readAll();
if(loc.isDataReady()) {
System.out.println("cnt: " + loc.getData().getHypoths_count());
for(PlayerLocalizeHypoth hyp : loc.getData().getHypoths()) {
pose = hyp.getMean();
System.out.println(pose.getPx() + ", " + pose.getPy() +
", " + pose.getPa());
}
}
}
}
}
---------------------------------------- java output
---------------------------------------------
Jul 22, 2009 1:52:10 PM javaclient2.PlayerClient <init>
INFO:
Player v.2.0.4
selected devices [localhost:6665]:
6665:simulation:0 (stage)
6665:map:0 (stage)
6665:localize:0 (fakelocalize)
6665:position2d:0 (stage)
6665:bumper:0 (stage)
6665:laser:0 (stage)
6665:position2d:1 (vfh)
cnt: 1
1.4E-45, 3.3517683, -2.51375
... stops here ...
---------------------------------------- c++ source
---------------------------------------------
#include <iostream>
#include <libplayerc++/playerc++.h>
int main(int argc, char *argv[])
{
using namespace PlayerCc;
PlayerClient robot("localhost");
LocalizeProxy locProx(&robot,0);
player_localize_hypoth_t hyp;
player_pose_t pose;
for(;;) {
robot.Read();
if(locProx.GetNumHypoths() > 0) { // since i'm using fakelocalize
driver I only get 1 hypothesis
hyp = locProx.GetHypoth(0);
pose = hyp.mean;
std::cout << pose.px << " " << pose.py << " " << pose.pa << std::endl;
}
}
}
---------------------------------------- c++ source
---------------------------------------------
-2.51375, 3.3517683, 2.7775
-2.51375, 3.3517683, 2.7775
-2.51375, 3.3517683, 2.7775
-2.51375, 3.3517683, 2.7775
-2.51375, 3.3517683, 2.7775
-2.51375, 3.3517683, 2.7775
-2.51375, 3.3517683, 2.7775
... keeps going ...
|