From: Skuld <tan...@ho...> - 2009-04-10 13:25:41
|
What is your version of JavaClient? I don't work a lot on JavaClient, but I know that you have to call (directly or not) a function whose name is Read() (PlayerClient in the c++ native library), in order to retrieve data from Player/Stage, to fill up fields of your structure, and then you can reach data by functions like getRanges(). So your first call of getRanges, "lsri.getData().getRanges();", can't fill these fields. It's useless. Maybe you have to call readAll() (of the class PlayerClient in javaClient) if you're not in threaded mode, or call runThreaded(0,0) if you implemented the Runnable interface. Those functions will call an equivalent of Read. I guess that "isDataReady" doesn't ask a reading from Player/Stage, but only check if, in the most recent data retrieved, there is data about laser. But you still have to retrieve it. If it doesn't work, check your "robot" creation. Maybe it's your nullpointer error' source. Do you know the name of the function which cause the error? kevinl wrote: > > Hi all, > I don't know how to use the laserInterface, so I run the following code > for a try: > lsri = robot.requestInterfaceLaser (0, PlayerConstants.PLAYER_OPEN_MODE); > while(lsri.isDataReady()); > lnum=lsri.getData().getRanges_count(); > lsri.getData().getRanges(); > ldata=lsri.getData().getRanges(); > > I get the error of "NullPointerException". Could you advise me on how to > use the laserInterface? And I am confused with the method "public void > readData(PlayerMsgHdr header)" , how can I get a PlayerMsgHdr variable? > > Thanks a lot, > kevin. > > -- View this message in context: http://www.nabble.com/Problems-with-laserinterface-tp22986701p22987951.html Sent from the java-player-users mailing list archive at Nabble.com. |