Skip to content

Commit 0b9ab46

Browse files
kaatrasaoseiskar
authored andcommitted
sai-cli diagnose: Plot vio outputs if they are available
1 parent b802646 commit 0b9ab46

File tree

3 files changed

+290
-14
lines changed

3 files changed

+290
-14
lines changed

python/cli/diagnose/diagnose.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,18 @@ def generateReport(args):
4242
'gyroscope': {"v": [], "t": [], "td": []},
4343
'magnetometer': {"v": [], "t": [], "td": []},
4444
'barometer': {"v": [], "t": [], "td": []},
45-
'gnss': {"v": [], "t": [], "td": []},
4645
'cpu': {"v": [], "t": [], "td": [], "processes": {}},
46+
'gnss': {
47+
"t": [],
48+
"td": [],
49+
"position": [], # ENU
50+
"altitude": [] # WGS-84
51+
},
52+
'vio': {"t": [], "td": [], "status": [], "position": [], "global": {
53+
"position": [], # ENU
54+
"velocity": [], # ENU
55+
"altitude": [] # WGS-84
56+
}},
4757
'cameras': {}
4858
}
4959

@@ -74,6 +84,7 @@ def addMeasurement(type, t, v):
7484
gnss = measurement.get("gps")
7585
frames = measurement.get("frames")
7686
metrics = measurement.get("systemMetrics")
87+
vioOutput = measurement if "status" in measurement else None
7788
if frames is None and 'frame' in measurement:
7889
frames = [measurement['frame']]
7990
frames[0]['cameraInd'] = 0
@@ -84,14 +95,14 @@ def addMeasurement(type, t, v):
8495
and frames is None
8596
and metrics is None
8697
and barometer is None
87-
and gnss is None): continue
98+
and gnss is None
99+
and vioOutput is None): continue
88100

89101
if startTime is None:
90102
startTime = time
91103
if args.zero:
92104
timeOffset = startTime
93105

94-
95106
if (args.skip is not None and time - startTime < args.skip) or (args.max is not None and time - startTime > args.max):
96107
nSkipped += 1
97108
continue
@@ -105,8 +116,14 @@ def addMeasurement(type, t, v):
105116
elif barometer is not None:
106117
addMeasurement("barometer", t, barometer["pressureHectopascals"])
107118
elif gnss is not None:
119+
gnssData = data["gnss"]
120+
if len(gnssData["t"]) > 0:
121+
diff = t - gnssData["t"][-1]
122+
gnssData["td"].append(diff)
123+
gnssData["t"].append(t)
108124
enu = gnssConverter.enu(gnss["latitude"], gnss["longitude"], gnss["altitude"])
109-
addMeasurement("gnss", t, [enu["x"], enu["y"], gnss["altitude"]])
125+
gnssData["position"].append([enu[c] for c in "xyz"])
126+
gnssData["altitude"].append(gnss["altitude"])
110127
elif frames is not None:
111128
for f in frames:
112129
if f.get("missingBitmap", False): continue
@@ -125,14 +142,27 @@ def addMeasurement(type, t, v):
125142
for process in metrics['cpu'].get('processes', []):
126143
name = process.get('name')
127144
if not name: continue
128-
129145
count = usedProcessNames.get(name, 0)
130146
usedProcessNames[name] = count + 1
131147
uniqueName = f"{name} {count + 1}" if count else name
132-
133148
processData = data['cpu']["processes"].setdefault(uniqueName, {"v": [], "t": []})
134149
processData['v'].append(process['usagePercent'])
135150
processData['t'].append(t)
151+
elif vioOutput is not None:
152+
vio = data["vio"]
153+
if len(vio["t"]) > 0:
154+
diff = t - vio["t"][-1]
155+
vio["td"].append(diff)
156+
vio["t"].append(t)
157+
vio["status"].append(vioOutput["status"])
158+
vio["position"].append([vioOutput["position"][c] for c in "xyz"])
159+
if "globalPose" in vioOutput:
160+
globalPose = vioOutput["globalPose"]
161+
wgs84 = vioOutput["globalPose"]["coordinates"]
162+
enu = gnssConverter.enu(wgs84["latitude"], wgs84["longitude"], wgs84["altitude"])
163+
vio["global"]["position"].append([enu[c] for c in "xyz"])
164+
vio["global"]["velocity"].append([globalPose["velocity"][c] for c in "xyz"])
165+
vio["global"]["altitude"].append(wgs84["altitude"])
136166

137167
if nSkipped > 0: print(f'Skipped {nSkipped} lines')
138168

@@ -143,6 +173,7 @@ def addMeasurement(type, t, v):
143173
diagnoseBarometer(data, output)
144174
diagnoseGNSS(data, output)
145175
diagnoseCPU(data, output)
176+
diagnoseVIO(data, output)
146177

147178
if os.path.dirname(args.output_html):
148179
os.makedirs(os.path.dirname(args.output_html), exist_ok=True)

python/cli/diagnose/html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def generateHtml(output, outputHtml):
166166
camera["frequency"],
167167
camera["count"])))
168168

169-
SENSOR_NAMES = ["accelerometer", "gyroscope", "magnetometer", "barometer", "GNSS", "CPU"]
169+
SENSOR_NAMES = ["accelerometer", "gyroscope", "magnetometer", "barometer", "GNSS", "CPU", "VIO"]
170170
for sensor in SENSOR_NAMES:
171171
if sensor not in output: continue
172172
kvPairs.append((

0 commit comments

Comments
 (0)