Skip to content

Commit 2babf6f

Browse files
authored
Minor fix to frame arrival time check in sai-cli diagnose (#80)
1 parent 74ebd97 commit 2babf6f

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

python/cli/diagnose/diagnose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def addMeasurement(type, t, v):
122122
if measurementType == "gyroscope":
123123
latestGyroTime = t
124124
for f in framesMissingNextGyroTime:
125-
gyroTimeDeltas["next"] = abs(latestGyroTime - gyroTimeDeltas["t"])
125+
f["next"] = abs(latestGyroTime - f["t"])
126126
framesMissingNextGyroTime.clear()
127127

128128
elif barometer is not None:

python/cli/diagnose/sensors.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ def toPercent(value):
234234
"timestamps that don't overlap with IMU")
235235

236236

237-
def analyzeDiscardedFrames(self, start_time, end_time, timestamps):
237+
def analyzeDiscardedFrames(self, startTime, endTime, timestamps):
238238
if len(timestamps) == 0: return
239-
self.images.append(plotDiscardedFrames(start_time, end_time, timestamps))
239+
self.images.append(plotDiscardedFrames(startTime, endTime, timestamps))
240240
self.__addIssue(DiagnosisLevel.WARNING,
241241
f"Found {len(timestamps)} discarded frames. Typically this happens when disk I/O "
242242
f"is too slow and prevents recording frames leading them to be discarded. You can "
@@ -263,7 +263,6 @@ def analyzeArrivalTimes(
263263

264264
total = len(deltaTimes)
265265
if total == 0: return
266-
267266
medianDeltaTime = np.nanmedian(deltaTimes)
268267
warningThreshold = min(.5, medianDeltaTime * 4)
269268
errorThreshold = 1
@@ -299,11 +298,11 @@ def analyzeArrivalTimes(
299298
**plotArgs))
300299

301300
self.__addIssue(DiagnosisLevel.ERROR if maxError > errorThreshold else DiagnosisLevel.WARNING,
302-
f"Found {badDeltaTimes} {dataName} where the neibhgouring gyroscope samples "
301+
f"Found {badDeltaTimes} {dataName} where the neighbouring gyroscope samples "
303302
f"have time difference (expected {medianDeltaTime*SECONDS_TO_MILLISECONDS:.1f}ms) "
304303
f"larger than {warningThreshold*SECONDS_TO_MILLISECONDS:.1f}ms, up to {maxError*SECONDS_TO_MILLISECONDS:.1f}ms. "
305304
f"This indicates that gyroscope and {dataName} for same moment of time are fed "
306-
f"large time appart which may lead to data being dropped and higher latency."
305+
f"large time apart which may lead to data being dropped and higher latency."
307306
)
308307

309308
def analyzeSignalDuplicateValues(
@@ -687,17 +686,17 @@ def diagnoseCamera(data, output):
687686
sensor = data["cameras"]
688687
output["cameras"] = []
689688

690-
start_time = None
691-
end_time = None
689+
startTime = None
690+
endTime = None
692691
for ind in sensor.keys():
693692
camera = sensor[ind]
694693
timestamps = np.array(camera["t"])
695694
deltaTimes = np.array(camera["td"])
696695

697696
if len(timestamps) == 0: continue
698697

699-
if start_time == None or start_time > timestamps[0]: start_time = timestamps[0]
700-
if end_time == None or end_time < timestamps[-1]: end_time = timestamps[-1]
698+
if startTime == None or startTime > timestamps[0]: startTime = timestamps[0]
699+
if endTime == None or endTime < timestamps[-1]: endTime = timestamps[-1]
701700

702701
status = Status()
703702
status.analyzeTimestamps(
@@ -742,7 +741,7 @@ def diagnoseCamera(data, output):
742741

743742
if len(data["discardedFrames"]) > 0:
744743
status = Status()
745-
status.analyzeDiscardedFrames(start_time, end_time, data["discardedFrames"])
744+
status.analyzeDiscardedFrames(startTime, endTime, data["discardedFrames"])
746745
output["discardedFrames"] = {
747746
"diagnosis": status.diagnosis.toString(),
748747
"issues": status.serializeIssues(),

0 commit comments

Comments
 (0)