Usage of Timer.getTimestamp() and Timer.getFPGATimestamp()


I saw this change in advantageKit, and I don’t really understand it. What’s the difference between Timer.getTimestamp() and Timer.getFPGATimestamp()? When should I use each one?
thx in advance.

2 Likes

It might be a thing where the older one (“real time stamp”) is the time stamp from the robot while it’s operating using the FPGA and the newer one times based off of a real world clock like the time on your computer

This page provides more detail about how timestamps work in AdvantageKit:

1 Like

At a fundamental level…

Each line of code takes some time to execute.

Each periodic loop starts at a certain time.

Calling getFPGATimestamp() on a specific line of code will return loop start time, plus whatever time has elapsed running code up to that point.

Generally, when logging signal values, you record both the value of the signal, and the time at which it had that value.

For time, have a choice - do you want the timestamp to reflect the time the loop started? Or do you want it to reflect the time you called the log() method?

AdvantageScope’s docs explain why there is an opinionated decision made there.

3 Likes

Note that Timer.getTimestamp/RobotController.getTime only return a “latched” timestamp when using AdvantageKit (or if the user has otherwise configured the timestamp source); otherwise they return the FPGA timestamp.

2 Likes