Skip to content

Commit

Permalink
Plot IMU and wheel measurement intervals.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamshapiro0 committed Oct 5, 2023
1 parent b37a46e commit 28fb08f
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions python/fusion_engine_client/analysis/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ def _extract_data(measurement_type):
titles = ['%s Speed (Signed)' % speed_type, 'Gear/Direction']
else:
titles = ['%s Speed (Unsigned)' % speed_type, 'Gear/Direction']
titles.append('Measurement Interval')

if wheel_data is not None:
titles[0] += f'<br>Messages: {wheel_measurement_type.__name__}'
Expand All @@ -1461,9 +1462,12 @@ def _extract_data(measurement_type):
else:
figure['layout']['yaxis1'].update(title="Speed (m/s)")

figure['layout']['yaxis%d' % (len(titles))].update(title="Gear/Direction",
ticktext=['%s (%d)' % (e.name, e.value) for e in GearType],
tickvals=[e.value for e in GearType])
gear_y_axis = len(titles) - 1
interval_y_axis = len(titles)
figure['layout']['yaxis%d' % gear_y_axis].update(title="Gear/Direction",
ticktext=['%s (%d)' % (e.name, e.value) for e in GearType],
tickvals=[e.value for e in GearType])
figure['layout']['yaxis%d' % interval_y_axis].update(title="Interval (sec)")

# Check if the data has P1 time available. If not, we'll plot in the original source time.
#
Expand Down Expand Up @@ -1638,7 +1642,13 @@ def _plot_wheel_data(data, time_source, is_raw=False, show_gear=False, style=Non
figure.add_trace(go.Scattergl(x=time, y=wheel_data.gear[idx], text=text,
name='Gear (Wheel Data)', hoverlabel={'namelength': -1},
mode='markers', marker={'color': 'red'}),
3 if type == 'tick' else 2, 1)
gear_y_axis, 1)

name = "Wheel Interval" + name_suffix
color = 'blue' if is_raw else 'red'
figure.add_trace(go.Scattergl(x=time[1:], y=np.diff(time), name=name, hoverlabel={'namelength': -1},
mode='markers', marker={'color': color}),
interval_y_axis, 1)

# Plot the wheel speed data. If we have both corrected and uncorrected (raw) data, plot them both.
_plot_wheel_data(wheel_data, wheel_time_source, is_raw=wheel_measurement_type == raw_wheel_measurement_type,
Expand Down Expand Up @@ -1679,7 +1689,13 @@ def _plot_vehicle_data(data, time_source, is_raw=False, show_gear=False, style=N
figure.add_trace(go.Scattergl(x=time, y=data.gear[idx], text=text,
name='Gear (Vehicle Data)', hoverlabel={'namelength': -1},
mode='markers', marker={'color': 'orange'}),
3 if type == 'tick' else 2, 1)
gear_y_axis, 1)

name = "Vehicle Interval" + name_suffix
color = 'blue' if is_raw else 'red'
figure.add_trace(go.Scattergl(x=time[1:], y=np.diff(time), name=name, hoverlabel={'namelength': -1},
mode='markers', marker={'color': color}),
interval_y_axis, 1)

# Plot the vehicle speed data. If we have both corrected and uncorrected (raw) data, plot them both.
_plot_vehicle_data(vehicle_data, vehicle_time_source,
Expand Down Expand Up @@ -1732,14 +1748,16 @@ def _plot_imu_data(self, message_cls, filename, figure_title):
titles = [t + ' (Uncorrected)' for t in titles]
else:
titles = [t + ' (Corrected)' for t in titles]
titles.append('Measurement Interval')

figure = make_subplots(rows=2, cols=1, print_grid=False, shared_xaxes=True, subplot_titles=titles)
figure = make_subplots(rows=len(titles), cols=1, print_grid=False, shared_xaxes=True, subplot_titles=titles)

figure['layout'].update(showlegend=True, modebar_add=['v1hovermode'])
figure['layout']['xaxis1'].update(title=self.p1_time_label, showticklabels=True)
figure['layout']['xaxis2'].update(title=self.p1_time_label, showticklabels=True)
for i in range(3):
figure['layout']['xaxis%d' % (i + 1)].update(title=self.p1_time_label, showticklabels=True)
figure['layout']['yaxis1'].update(title="Acceleration (m/s^2)")
figure['layout']['yaxis2'].update(title="Rotation Rate (rad/s)")
figure['layout']['yaxis3'].update(title="Interval (sec)")

figure.add_trace(go.Scattergl(x=time, y=data.accel_mps2[0, :], name='X', legendgroup='x',
mode='lines', line={'color': 'red'}),
Expand All @@ -1761,6 +1779,10 @@ def _plot_imu_data(self, message_cls, filename, figure_title):
showlegend=False, mode='lines', line={'color': 'blue'}),
2, 1)

figure.add_trace(go.Scattergl(x=time[1:], y=np.diff(time), name='Interval', hoverlabel={'namelength': -1},
mode='markers', marker={'color': 'red'}),
3, 1)

self._add_figure(name=filename, figure=figure, title=figure_title)

def plot_heading_measurements(self):
Expand Down

0 comments on commit 28fb08f

Please sign in to comment.