Finding the Player delay

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Finding the Player delay

Brandon Sights
How can I read the time between when data was sent to the server and
when it was read by the client.

I see that when using the C++ Client Library, there is the option to use
the class

ClientProxy (PlayerClient *pc, unsigned short req_device, unsigned short
req_index, unsigned char req_access= 'c')

, which has the public attributes senttime and receivedtime.  However, I
do not understand how I can use this to explicitly read these times for
each device that I am reading data from. If my proxy object were the
SonarProxy  with the name "sp", could I then access these by using
sp.senttime and sp.receivedtime since the PlayerClient is friends with
ClientProxy, or do I need to first instantiate a new object of type
ClientProxy?


An example would be best, especially if you can add it to the example
for the C++ Client Library:


int main(int argc, char *argv[])
{
  PlayerClient robot("localhost");
  SonarProxy sp(&robot,0,'r');
  PositionProxy pp(&robot,0,'w');

  double newturnrate,newspeed;

  for(int i=0;i<1000;i++)  
  {
    if(robot.Read())
      exit(1);

    // print out sonars for fun
    sp.Print();

    // do simple collision avoidance
    if((sp.ranges[0] + sp.ranges[1]) <
       (sp.ranges[6] + sp.ranges[7]))
      newturnrate = DTOR(-20); // turn 20 degrees per second
    else
      newturnrate = DTOR(20);

    if(sp.ranges[3] < 0.500)
      newspeed = 0;
    else
      newspeed = 0.100;

    // command the motors
    pp.SetSpeed(newspeed,newturnrate);
  }
}

Thanks for your help.

Sincerely,
Brandon Sights
[hidden email]






-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Playerstage-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding the Player delay

Brian Gerkey

On Sep 15, 2005, at 9:46 AM, Brandon Sights wrote:

> How can I read the time between when data was sent to the server and
> when it was read by the client.
>
> ClientProxy (PlayerClient *pc, unsigned short req_device, unsigned
> short
> req_index, unsigned char req_access= 'c')
>
> , which has the public attributes senttime and receivedtime.

senttime is the time at which the latest message was sent by the server.
receivedtime is when your client received it.
A third field, timestamp, is a time attached by the driver that
generated data.  This time is the best estimate of when the phenomenon
occurred (e.g., when the laser scan was taken).

All proxy classes (e.g., SonarProxy) inherit from ClientProxy, so you
can access all three times directly.  For example, given a SonarProxy
sp, you can read sp.timestamp.  The time fields are filled in by the
PlayerClient object when it processes incoming data (this happens when
you call PlayerClient::Read).

        brian.



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Playerstage-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-users