Go to Post I am the Evil Empire of FIRST!!! - Andy Grady [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-02-2014, 19:27
TPackard TPackard is offline
Registered User
FRC #0008
 
Join Date: Feb 2014
Location: Palo Alto
Posts: 4
TPackard is an unknown quantity at this point
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!
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2014, 15:31
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 152
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
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 View Post
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 Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:44.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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