|
From: Radu B. R. <ru...@cs...> - 2005-11-28 07:47:55
|
Hey Shane,
- runThreaded () calls read () automatically, as can be seen in this
snippet of code (3rd line of run ()):
/**
* Start a threaded copy of Javaclient.
* @param millis number of miliseconds to sleep between calls
* @param nanos number of nanoseconds to sleep between calls
*/
public void runThreaded (long millis, int nanos) {
if (isThreaded) {
System.err.println ("[PlayerClient] : A second call for
runThreaded, ignoring!");
return;
}
this.millis = millis;
this.nanos = nanos;
isThreaded = true;
this.start ();
}
/**
* Start the Javaclient thread. Ran automatically from runThreaded ().
*/
public void run () {
try {
while (isThreaded) {
while (read () != PLAYER_MSGTYPE_SYNCH && isThreaded);
if (millis < 0)
Thread.yield ();
else
if (nanos <= 0)
Thread.sleep (millis);
else
Thread.sleep (millis, nanos);
}
} catch (Exception e) { e.printStackTrace (); }
}
- setNotThreaded () just sets isThreaded to false, so you have to call
readAll () manually:
/**
* Change the mode Javaclient runs to non-threaded.
*/
public void setNotThreaded() {
isThreaded = false;
}
/**
* Read the Player server replies in non-threaded mode.
*/
public void readAll () {
if (isThreaded) return;
while (read () != PLAYER_MSGTYPE_SYNCH);
}
If you send me your piece of code, I can have a quick look at it
probably today or tomorrow (not THAT busy today :) and send you a
corrected version back. Who knows, maybe we discovered another bug in
FiducialInterface (I haven't really used it).
What I normally do is ... connect to Player, request the interfaces,
then start the client in threaded mode, and then I control the robot in
an infinite while loop (with the appropriate sleep of course). Can you
check the examples that I just uploaded to the Javaclient web page
please, and see if they can help?
Cheers,
Radu.
Shane Hoversten wrote:
> Hey all -
>
> I've been confused for awhile about reading data using javaclient. If
> I do a runThreaded() do I ever need to explicitly readData()? So far,
> w/respect to sensors, things have mostly "just worked." But now I'm
> having these goofy intermittent problems (w/ fiducials again, of
> course) where sometimes I get meaningful rotation readings, and
> sometimes I get nothing. There seems to be no rhyme or reason to how
> this is working, and of course considering the series of problems I've
> had with fiducials it could be just more of the same bugs that crop up
> w/ 1.3.5. But it strikes me that it could be something more fundamental.
>
> So - can someone give me a quick explanation of how and when to read
> interface data?
>
> Thanks,
>
> Shane
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Java-player-users mailing list
> Jav...@li...
> https://lists.sourceforge.net/lists/listinfo/java-player-users
--
| Radu Bogdan Rusu | http://rbrusu.com/
| http://www9.cs.tum.edu/people/rusu/
| Intelligent Autonomous Systems
| Technische Universitaet Muenchen
|