Re: Running simulation > 10Hz
Rich Mattes <[email protected]>
| Newsgroups | gmane.science.robotics.playerstage |
|---|---|
| Message-ID | <CAKxHMOKdt46v=Y9dgGo1FKNtcK8kZ4XyJcTx+CbZox1_H4Vx2Q@mail.gmail.com> |
On Tue, Apr 23, 2013 at 4:15 AM, ulle <[email protected]> wrote: > The push mode did the trick! > Thank you, Rich. I really appreciate it. > > I use Read() instead of ReadIfWaiting(). Using the latter it reads the same > data like crazy before getting fresh data while Read() is called four or > five times in my case before fresh data is available. I guess > ReadIfWaiting() should read if there is a message in the queue, but I get > the same data over and over again. Do I need to somehow remove data from > the > server after I have read it? > > Thanks again, > /U > > ReadIfWaiting() is a non-blocking read; it checks to see if the client has received any new information from the server since the last read. If it hasn't, the call comes back without doing anything. Read() blocks until at least one message is read from the Player server. You don't constantly receive the same data over again; you can think of the client libraries as buffers. Each client proxy stores the data from the latest message it has received from the Player server. Calls to Read() don't necessarily update every client proxy, as your client may not have received a new message since the last call to Read(). So those clients will continue to store the same data after a call to Read(). One way to check if a particular client proxy got a new message is by using the IsFresh()/NotFresh() set of calls in the PlayerC++ library. Each time that Read() *does* update a particular client, it sets that client's "Fresh" flag to true. After a call to read, you can check each of your proxies for the Fresh flag to see if there has been an update. Then you can call NotFresh() to reset the fresh flag and signify that the data is stale/you've already done something with it. The example program I sent in this thread uses this method to only print each message's timestamp once. Rich ------------------------------------------------------------------------------ Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only SaaS-based application performance monitoring service that delivers powerful full stack analytics. Optimize and monitor your browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr _______________________________________________ Playerstage-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/playerstage-developers