From: Radu B. R. <ru...@in...> - 2005-08-19 08:27:01
|
Hellos, fly roadto wrote: > Hi all, > I am sorry to send two more repearted messages to the server (e.g. > "questions about using java code with simulator" and "how to use the > simulator with java code"). Becasue i sent this thread the day before > yesterday, but couldn't see any new one from the mailing list. So im > so fool to send two more. Could the administrator cancel the two more > ones please? > and i have one more question. when i ran the code as follow: > PlayerClient player = new PlayerClient("localhost",6665); > PositionInterface post = player.requestInterfacePosition(0, > 'r'); //a, r or w > SimulationInterface simulation = > player.requestInterfaceSimulation(0, 'r'); > player.runThreaded(-1, -1); > //now loop this stuff... > player.readAll(); You don't need to call player.readAll() if you run the Javaclient in threaded mode. > //update the global data so every behaviour can access it > > simulation.set2DPose("pioneer", 1000, 1000, 0); > simulation.get2DPose("pioneer"); > > int currentX = simulation.getSimulationPose2D().getX(); > int currentY = simulation.getSimulationPose2D().getY(); > int currentYaw = simulation.getSimulationPose2D().getTheta(); > > System.out.println("Position (" + currentX + "/"+ currentY + > ") Angle " + > "is " + currentYaw + " "); > and the result is like this: > [PlayerClient] : Got response for device 4(stage) with access: r > [PlayerClient] : Got response for device 31(stage) with access: r > Exception in thread "main" java.lang.NullPointerException > at robotsimulation.Test1.main(Test1.java:36) > [Simulation] : Handling NAR of size = 0 > > it seems the currentX, Y, Yaw don't get any return value from > getSimulationPose2D(). but i want to get the value of pose of the > robot in the simulator. any one get ideas? You need to check isPose2DReady() in a loop before reading the new pose with getSimulationPose2D(). Example: while (!isPose2DReady ()); PlayerSimulationPose2D pose = getSimulationPose2D (); System.out.println ("Position (" + pose.getX () + "/"+ pose.getY () + ") Angle is " + pose.getTheta () + " "); > thanks very much You're welcome. Don't hesitate to send your questions here in case you encounter more problems. > > Jun > Cheers, Radu. -- | Radu Bogdan Rusu | http://www.rbrusu.com | Intelligent Autonomous Systems Group | Technische Universitaet Muenchen |