Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Timers don't start (http://www.chiefdelphi.com/forums/showthread.php?t=126087)

TPackard 08-02-2014 19:27

Timers don't start
 
Our team has been having trouble with the WPILib Timer class, since the Get() method always returns 0.

Code:

void Fenrir::AutonomousInit() {
    timer.Start();
}

void Fenrir::AutonomousPeriodic() {
    std::printf("%f\n", timer.Get());
}

timer is an instance variable of Fenrir, which is our main robot class that inherits from IterativeRobot. When we run the above code, it constantly prints 0 and never changes. We've also tried using the HasPeriodPassed() and GetFPGATimestamp() methods, but they don't work either. What could the problem be?

Thanks in advance!

bob.wolff68 09-02-2014 15:31

Re: Timers don't start
 
This seems odd to me. But the one missing item would be timer.Reset() in AutonomousInit() ... OH and another thing comes to mind... put a printf in AutonomousInit() to ensure you've really gotten in there. If you never get the .Start....then you'll always get zero.

bob

Quote:

Originally Posted by TPackard (Post 1339804)
Our team has been having trouble with the WPILib Timer class, since the Get() method always returns 0.

Code:

void Fenrir::AutonomousInit() {
    timer.Start();
}

void Fenrir::AutonomousPeriodic() {
    std::printf("%f\n", timer.Get());
}

timer is an instance variable of Fenrir, which is our main robot class that inherits from IterativeRobot. When we run the above code, it constantly prints 0 and never changes. We've also tried using the HasPeriodPassed() and GetFPGATimestamp() methods, but they don't work either. What could the problem be?

Thanks in advance!



All times are GMT -5. The time now is 12:48.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi