Expose NT entry change time in PhotonLib (#562)

Adds target change timestamp to PhotonPipelineResult

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
This commit is contained in:
Noah
2022-11-07 11:09:55 -07:00
committed by GitHub
parent b408a58e9e
commit 7dd1719fbd
5 changed files with 49 additions and 2 deletions

View File

@@ -102,9 +102,14 @@ public class PhotonCamera {
// Populate packet and create result.
packet.setData(rawBytesEntry.getRaw(new byte[] {}));
if (packet.getSize() < 1) return ret;
ret.createFromPacket(packet);
// Set the timestamp of the result.
// getLatestChange returns in microseconds so we divide by 1e6 to convert to seconds.
ret.setTimestampSeconds((rawBytesEntry.getLastChange() / 1e6) - ret.getLatencyMillis() / 1e3);
// Return result.
return ret;
}