|
From: Vitalijs K. <vit...@gm...> - 2012-04-23 13:14:36
|
Hi!
I think your code never gets actual position of your robot. I'm not sure
that robot.readAll(); actually reads all the data, perhaps it reads only
the data which is ready. And at the certain time posi is not ready yet.
Try something like follows:
PlayerClient robot = new PlayerClient("localhost", 6669);
Position2DInterface posi = robot.requestInterfacePosition2D(0, 1);
robot.runThreaded(-1, -1); // this allows to fetch data from the robot in
async mode
posi.setSpeed(1, 0);
Thread.sleep(5000);
posi.setSpeed(0, 0);
while (true) {
// infinite loop waiting for the data
if(posi.isDataReady()) {
System.out.println("ready");
break;
} else {
System.out.println("waiting");
Thread.sleep(1000);
}
}
System.out.println(posi.getX());
System.out.println(posi.getY());
System.out.println(posi.getYaw());
2012/4/22 kristjan.liiva1 <kri...@gm...>
> Hi,
>
> Could anyone help me out with some basics. I've been researching for some
> time and still don't fully undestand it.
> I'm trying to get the exact position for my robot. For that I'm using a
> position2d interface which has a parameters:
> localization "gps"
> localization_origin [0 0 0 0]
> I'm using code:
> PlayerClient robot = new PlayerClient("localhost", 6669);
> Position2DInterface posi = robot.requestInterfacePosition2D(0, 1);
> posi.setSpeed(1, 0);
> Thread.sleep(5000);
> posi.setSpeed(0, 0);
> robot.readAll();
> while(posi.isDataReady() == false){
> if(posi.isDataReady()) {
> System.out.println("ready");
> break;
> }
> Thread.sleep(1000);
> System.out.println("waiting");
> }
> System.out.println(posi.getX());
> System.out.println(posi.getY());
> System.out.println(posi.getYaw());
> And posi.getX() always returns -5 (starting point of the robot). What am I
> doing wrong?
>
> The other thing is that, if I use "odom" instead of "gps" then it
> sometimes returns results which differ from each other by a factor of 2.
>
>
>
> ------------------------------------------------------------------------------
> For Developers, A Lot Can Happen In A Second.
> Boundary is the first to Know...and Tell You.
> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
> http://p.sf.net/sfu/Boundary-d2dvs2
> _______________________________________________
> Java-player-users mailing list
> Jav...@li...
> https://lists.sourceforge.net/lists/listinfo/java-player-users
>
>
--
Vitālijs
|