Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USD deck: parser and plotter improvements #1181

Merged
merged 1 commit into from
Jan 9, 2023
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
12 changes: 9 additions & 3 deletions src/deck/drivers/src/usddeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ TCHAR* f_gets_without_comments (
while (n < len - 1) { /* Read characters until buffer gets filled */
f_read(fp, &c, 1, &rc);
if (rc != 1) {
break;
*p = 0;
return 0; /* When no data read (eof or error), return with error. */
}
if (c == '\n') {
if (isPureComment){
Expand All @@ -441,7 +442,7 @@ TCHAR* f_gets_without_comments (
}
}
*p = 0;
return n ? buff : 0; /* When no data read (eof or error), return with error. */
return buff;
}


Expand Down Expand Up @@ -636,8 +637,13 @@ static void usdLogTask(void* prm)
cfg->numBytes = 0;
while (true) {
line = f_gets_without_comments(readBuffer, sizeof(readBuffer), &logFile);
if (!line || strncmp(line, "on:", 3) == 0)
if (!line || strncmp(line, "on:", 3) == 0) {
break;
}
// skip lines that do not have at least two characters (1 for group, 1 for '.', 1 for name)
if (strlen(line) <= 3) {
continue;
}
char *group = line;
char *name = 0;
for (int i = 0; i < strlen(line); ++i) {
Expand Down
8 changes: 4 additions & 4 deletions tools/usdlog/plot_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ def showAnnotation(data, sel):
start_time = min(start_time, data['timestamp'][0])

# new figure
fig, ax = plt.subplots(len(data_usd.keys()),1,sharex=True)
fig, ax = plt.subplots(len(data_usd.keys()),1,sharex=True,squeeze=False)

for k, (event_name, data) in enumerate(data_usd.items()):
# print(k, event_name)
t = (data['timestamp'] - start_time) / 1000
ax[k].scatter(t, t*0)
ax[k].set_title(event_name)
ax[k,0].scatter(t, t*0)
ax[k,0].set_title(event_name)

print(data.keys())

crs = mplcursors.cursor(ax[k],hover=True)

crs.connect("add", functools.partial(showAnnotation, data))

ax[-1].set_xlabel('Time [s]')
ax[-1,0].set_xlabel('Time [s]')


plt.show()