Log in

View Full Version : Windriver Timing the fast loops, Timer.h?


wt200999
08-01-2009, 23:59
Is it okay to use the timer class in windriver for quick times. I am trying to get the time between the fast loops, but I am not sure how to achieve this. I see in the IterativeRobot.cpp that they implement a timer, maybe instead of creating my own I can get something from that one. This is how I had first though of using it with its own timer (it would start in the constructor):


void Robot::AutonomousContinuous()
{
Timer->Stop();
m_class.Process(Timer->Get());
Timer->Reset();
Timer->Start();
}


Or maybe there is a better way of doing this? I want to make sure that I am getting an accurate time if that's possible.

Jlulian
09-01-2009, 00:19
You could use the timer class, but in the same header as that is defined is the "GetTime()" function, which is used internally in the class, and is simpler to work with.

Using it would look something like this:

void Robot::AutonomousContinuous()
{
double timeChange = GetTime() - lastTime
//Time dependent Code..
lastTime = GetTime();
}

(this code snippet assumes you've got a lastTime variable in your class)