this email is related to a thread with subject "How do I make the for
loop wait?" from 2003-11-18.
Within a control control loop like this:
1)- I would like to make sure that the loop is done each 0.023 seconds,
because I will be receiving a new scan from the laser each 0.023 seconds
(37.5 Hz), and I don't want the loop to be executed until NEW laser_data
In order to assure this, I have a function that uses "gettimeofday" to
wait before "PlayerClient::Read" until the 0.023 secs are completed.
Now I would like to make sure that the laser scan I access after waiting
is a NEW laser scan, and not the same one that was read in the last
Can I solve the problem if I switch to "request mode" in the laser
proxy? How do I do this? Can this be done by using
PlayerClient::SetDataMode? If so, which mode shall I use:
Will this affect the access mode of all the proxies I set on this
client, the LaserProxy and the PositionProxy?
2)- In an homologous way, if I wanted the loop to be done in 0.1
seconds, and the LaserProxy was still running at 37.5Hz(0.027s), I would
have to discard some laser scans so that each time I read the LaserProxy
I read the LATEST laser_data, and not the NEXT after my last access to
Should I use the same data mode as in the previous case?
All in all, I think my problem is that I don't understand very well this
thing about the data modes in the documentation.
From: john sweeney <sweeney@...>
Re: [Playerstage-developers] How do I make the for loop wait?
at least two ways to do this.
1) keep track of time in your for loop, read the laser data every
but only act after 1.5 seconds have passed. do a "man gettimeofday"
for more info.
2) set the read mode on the PlayerClient on the laser proxy to be
request mode, where it will always get the latest data. That way you
can sleep at the end of your loop, but when you do perform a
PlayerClient::Read(), you get the latest data only (you have to call
PlayerClient::RequestData() prior to calling Read() in this case).
is discussed in the manual, somewhere, I"m pretty sure.
BTW, this email more properly belongs on the "users" email list, not