Go to Post just a gentle reminder not to limit yourself to just one viewpoint - every problem can and should be examined from different angles - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 24-02-2016, 14:10
PhilBot's Avatar
PhilBot PhilBot is offline
Get a life? This IS my life!
AKA: Phil Malone
FRC #1629 (GaCo: The Garrett Coalition)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Maryland
Posts: 747
PhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond repute
getMatchTime docs not correct

Measuring time in autonomous should be easy.

This is my first year using Java for FRC and it surprised me that it wasn't the case.

1: The sample "Getting Started" code uses loop counters to measure time... Really?

2: The description for the Timer class is simply wrong... it would lead you to believe that getMatchTime returns elapsed seconds... but it doesn't , it returns the countdown clock... which is extremely counter intuitive.

Plus, it only returns a valid time when running in "Practice" mode on the Driver Station. Nothing in pure Auto or Teleop modes.

The library getMatchTime() comment reads:

* This returns the time since the enable
* signal sent from the Driver Station At the beginning of autonomous, the
* time is reset to 0.0 seconds At the beginning of teleop, the time is reset
* to +15.0 seconds If the robot is disabled, this returns 0.0 seconds

I had to ultimately display the returned time on the dashboard to see why my code wasn't working. In Auto it starts at 15 and counts down.

So, it would appear that if I want a generic timer that I can reset to zero in each mode, I need to use getFPGATimestamp() to get a hardware time, and great my own "ElapsedTime class to be able to tell how long I've been running.

Simple enough now I know I need to do it, but really.......
Not making it easy for beginners.
__________________
Phil Malone
Garrett Engineering And Robotics Society (GEARS) founder.
http://www.GEARSinc.org

FRC1629 Mentor, FTC2818 Coach, FTC4240 Mentor, FLL NeXTGEN Mentor
Reply With Quote
  #2   Spotlight this post!  
Unread 24-02-2016, 14:47
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: getMatchTime docs not correct

You don't even need to call getFPGATimestamp() to get time. Java has the generic System.currentTimeInMillis() that is platform independent. The only reason you want to call getFPGATimestamp() is if you want a resolution higher than milliseconds. If you just want to get game elapsed time, you can just call System.currentTimeInMillis() at the beginning of the game as the start timestamp and you can calculate elapse time by subtracting start time from current time. We don't depend on WPILib to provide elapsed time. Our framework has a runPeriodic(double elapsedTime) method that gets called periodically and elapsed time is a parameter in this call.
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 24-02-2016, 14:59
PhilBot's Avatar
PhilBot PhilBot is offline
Get a life? This IS my life!
AKA: Phil Malone
FRC #1629 (GaCo: The Garrett Coalition)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Maryland
Posts: 747
PhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond repute
Re: getMatchTime docs not correct

Hi

Thanks... Useful information.

Hey... don't I know you from the FTC forums

Philbot.
__________________
Phil Malone
Garrett Engineering And Robotics Society (GEARS) founder.
http://www.GEARSinc.org

FRC1629 Mentor, FTC2818 Coach, FTC4240 Mentor, FLL NeXTGEN Mentor
Reply With Quote
  #4   Spotlight this post!  
Unread 24-02-2016, 15:21
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: getMatchTime docs not correct

Have you looked at the hasPeriodPassed method of Timer?
Reply With Quote
  #5   Spotlight this post!  
Unread 24-02-2016, 18:15
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: getMatchTime docs not correct

Quote:
Originally Posted by PhilBot View Post
Hi

Thanks... Useful information.

Hey... don't I know you from the FTC forums

Philbot.
Yeah, nice to see you over here too.
__________________
Reply With Quote
  #6   Spotlight this post!  
Unread 24-02-2016, 18:25
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: getMatchTime docs not correct

The Timer class actually wraps the DriverStation.getMatchTime() which has this documentation

Quote:
/**
* Return the approximate match time The FMS does not send an official match
* time to the robots, but does send an approximate match time. The value will
* count down the time remaining in the current period (auto or teleop).
* Warning: This is not an official time (so it cannot be used to dispute ref
* calls or guarantee that a function will trigger before the match ends) The
* Practice Match function of the DS approximates the behaviour seen on the
* field.
*$
* @return Time remaining in current match period (auto or teleop) in seconds
*/
This might've been inverted this year on the DS side but it wasn't inverted in the Timer class
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
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 22:16.

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