Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/cli/diagnose/diagnose.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def addMeasurement(type, t, v):
if measurementType == "gyroscope":
latestGyroTime = t
for f in framesMissingNextGyroTime:
gyroTimeDeltas["next"] = abs(latestGyroTime - gyroTimeDeltas["t"])
f["next"] = abs(latestGyroTime - f["t"])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug was that gyroTimeDeltas doesn't refer to f when there are multiple frames on one line.

framesMissingNextGyroTime.clear()

elif barometer is not None:
Expand Down
19 changes: 9 additions & 10 deletions python/cli/diagnose/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ def toPercent(value):
"timestamps that don't overlap with IMU")


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

total = len(deltaTimes)
if total == 0: return

medianDeltaTime = np.nanmedian(deltaTimes)
warningThreshold = min(.5, medianDeltaTime * 4)
errorThreshold = 1
Expand Down Expand Up @@ -299,11 +298,11 @@ def analyzeArrivalTimes(
**plotArgs))

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

def analyzeSignalDuplicateValues(
Expand Down Expand Up @@ -687,17 +686,17 @@ def diagnoseCamera(data, output):
sensor = data["cameras"]
output["cameras"] = []

start_time = None
end_time = None
startTime = None
endTime = None
for ind in sensor.keys():
camera = sensor[ind]
timestamps = np.array(camera["t"])
deltaTimes = np.array(camera["td"])

if len(timestamps) == 0: continue

if start_time == None or start_time > timestamps[0]: start_time = timestamps[0]
if end_time == None or end_time < timestamps[-1]: end_time = timestamps[-1]
if startTime == None or startTime > timestamps[0]: startTime = timestamps[0]
if endTime == None or endTime < timestamps[-1]: endTime = timestamps[-1]

status = Status()
status.analyzeTimestamps(
Expand Down Expand Up @@ -742,7 +741,7 @@ def diagnoseCamera(data, output):

if len(data["discardedFrames"]) > 0:
status = Status()
status.analyzeDiscardedFrames(start_time, end_time, data["discardedFrames"])
status.analyzeDiscardedFrames(startTime, endTime, data["discardedFrames"])
output["discardedFrames"] = {
"diagnosis": status.diagnosis.toString(),
"issues": status.serializeIssues(),
Expand Down