From: Brandon S. <si...@sp...> - 2005-09-15 16:47:04
|
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 si...@sp... |