Skip to content

Commit

Permalink
plots: update mag & baro alt to new topics & keep compatibility with …
Browse files Browse the repository at this point in the history
…old logs

Firmware PR: PX4/PX4-Autopilot#8466
  • Loading branch information
bkueng committed Apr 12, 2018
1 parent 28a3e6b commit afa1bc5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
16 changes: 12 additions & 4 deletions plot_app/configured_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ def generate_plots(ulog, px4_ulog, db_data, vehicle_data, link_to_3d_page):
plots = []
data = ulog.data_list

# COMPATIBILITY support for old logs
if any(elem.name == 'vehicle_air_data' for elem in data):
baro_alt_meter_topic = 'vehicle_air_data'
magnetometer_ga_topic = 'vehicle_magnetometer'
else: # old
baro_alt_meter_topic = 'sensor_combined'
magnetometer_ga_topic = 'sensor_combined'


# initialize flight mode changes
flight_mode_changes = get_flight_mode_changes(ulog)
Expand Down Expand Up @@ -146,7 +154,7 @@ def generate_plots(ulog, px4_ulog, db_data, vehicle_data, link_to_3d_page):
changed_params=changed_params, x_range=x_range)
data_plot.add_graph([lambda data: ('alt', data['alt']*0.001)],
colors8[0:1], ['GPS Altitude'])
data_plot.change_dataset('sensor_combined')
data_plot.change_dataset(baro_alt_meter_topic)
data_plot.add_graph(['baro_alt_meter'], colors8[1:2], ['Barometer Altitude'])
data_plot.change_dataset('vehicle_global_position')
data_plot.add_graph(['alt'], colors8[2:3], ['Fused Altitude Estimation'])
Expand Down Expand Up @@ -334,7 +342,7 @@ def generate_plots(ulog, px4_ulog, db_data, vehicle_data, link_to_3d_page):

if data_plot.finalize() is not None: plots.append(data_plot)

else: # it's an old log
else: # it's an old log (COMPATIBILITY)
data_plot = DataPlot(data, plot_config, 'rc_channels',
title='Raw Radio Control Inputs',
plot_height='small', y_range=Range1d(-1.1, 1.1),
Expand Down Expand Up @@ -445,7 +453,7 @@ def generate_plots(ulog, px4_ulog, db_data, vehicle_data, link_to_3d_page):


# magnetic field strength
data_plot = DataPlot(data, plot_config, 'sensor_combined',
data_plot = DataPlot(data, plot_config, magnetometer_ga_topic,
y_axis_label='[gauss]', title='Raw Magnetic Field Strength',
plot_height='small', changed_params=changed_params,
x_range=x_range)
Expand Down Expand Up @@ -490,7 +498,7 @@ def generate_plots(ulog, px4_ulog, db_data, vehicle_data, link_to_3d_page):


# thrust and magnetic field
data_plot = DataPlot(data, plot_config, 'sensor_combined',
data_plot = DataPlot(data, plot_config, magnetometer_ga_topic,
y_start=0, title='Thrust and Magnetic Field', plot_height='small',
changed_params=changed_params, x_range=x_range)
data_plot.add_graph(
Expand Down
3 changes: 2 additions & 1 deletion plot_app/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ def load_ulog_file(file_name):
'position_setpoint_triplet', 'vehicle_attitude_groundtruth',
'vehicle_local_position_groundtruth', 'vehicle_vision_position',
'vehicle_vision_attitude', 'vehicle_status', 'airspeed',
'manual_control_setpoint', 'rate_ctrl_status']
'manual_control_setpoint', 'rate_ctrl_status',
'vehicle_air_data', 'vehicle_magnetometer']
try:
ulog = ULog(file_name, msg_filter)
except FileNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion testing_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"outputs": [],
"source": [
"# a more complex plot with multiple datasets\n",
"data_plot = DataPlot(data, plot_config, 'sensor_combined', y_start=0, title = 'Thrust and Magnetic Field',\n",
"data_plot = DataPlot(data, plot_config, 'vehicle_magnetometer', y_start=0, title = 'Thrust and Magnetic Field',\n",
" plot_height='normal')\n",
"data_plot.add_graph([lambda data: ('len_mag', \n",
" np.sqrt(data['magnetometer_ga[0]']**2 + data['magnetometer_ga[1]']**2 + data['magnetometer_ga[2]']**2))],\n",
Expand Down

0 comments on commit afa1bc5

Please sign in to comment.