Skip to content

Commit 0cf4834

Browse files
committed
Fix units bug for getLoopStartTime. now returns microseconds.
Signed-off-by: Mike Stitt <[email protected]>
1 parent 9e27f0a commit 0cf4834

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

subprojects/robotpy-wpilib/wpilib/timedrobotpy.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def __init__(self, period: wpimath.units.seconds = kDefaultPeriod) -> None:
131131

132132
self._startTimeUs = _getFPGATime()
133133
self._callbacks = _OrderedList()
134-
self.loopStartTimeUs = 0
134+
self._loopStartTimeUs = 0
135135
self.addPeriodic(self._loopFunc, period=self._periodS)
136136

137137
self._notifier, status = initializeNotifier()
@@ -183,7 +183,7 @@ def startCompetition(self) -> None:
183183
# See the API for waitForNotifierAlarm
184184
break
185185

186-
self.loopStartTimeUs = _getFPGATime()
186+
self._loopStartTimeUs = _getFPGATime()
187187
self._runCallbackAndReschedule(callback, currentTimeUs)
188188

189189
# Process all other callbacks that are ready to run
@@ -204,22 +204,20 @@ def endCompetition(self) -> None:
204204
"""
205205
stopNotifier(self._notifier)
206206

207-
def getLoopStartTime(self) -> wpimath.units.seconds:
207+
def getLoopStartTime(self) -> microsecondsAsInt:
208208
"""
209-
todo was def getLoopStartTime(self) -> int: (Microseconds)
210-
todo this show be wpimath.units.seconds
211-
Return the system clock time in seconds (todo was microseconds)
209+
Return the system clock time in microseconds
212210
for the start of the current
213-
periodic loop. This is in the same time base as Timer.GetFPGATimestamp(),
211+
periodic loop. This is in the same time base as Timer.getFPGATimestamp(),
214212
but is stable through a loop. It is updated at the beginning of every
215213
periodic callback (including the normal periodic loop).
216214
217-
:returns: Robot running time in seconds (todo was microseconds),
215+
:returns: Robot running time in microseconds,
218216
as of the start of the current
219217
periodic function.
220218
"""
221219

222-
return self.loopStartTimeUs / 1e6 # units are seconds
220+
return self._loopStartTimeUs
223221

224222
def addPeriodic(
225223
self,

0 commit comments

Comments
 (0)