dronecrew / px4tools

PX4 flight analysis tools.
BSD 3-Clause "New" or "Revised" License
84 stars 48 forks source link

Question: Plotting #17

Closed TarekTaha closed 7 years ago

TarekTaha commented 7 years ago

I am trying to use px4tools to generate some plots and analyse data. If I convert the examples in the ipynb files into a python script, then I get no output, and no plots. The only way I can generate plots is by doing the following:

#!/usr/bin/env python
import os
import pandas
import unittest
import inspect
from px4tools.analysis import *
from px4tools.mapping import *
from px4tools.ulog import * 
import px4tools.logsysid
import control
import json
import pylab as pl

pl.rcParams['figure.figsize'] = (15,5)

data = process_data(pandas.read_csv('15-9-30-11_44_47-kabir-crash.csv'))

px4tools.statistics(data[10:100], ['GPS_VelN', 'GPS_VelE', 'GPS_VelD','IMU1_AccX', 'IMU1_AccY', 'IMU1_AccZ', 'SENS_BaroAlt'], plot=True)
data = process_lpe_health(data)
data = project_lat_lon(data)
plt.show()
statistics(data, ['LPOS_VX'], plot=True)
plt.show()
data = process_lpe_health(data)
plt.show()
plot_modes(data)
plt.show()
find_meas_period(data['LPOS_VX'])
plt.show()
plot_control_loops(data)
plt.show()
plot_position_loops(data)
plt.show()
plot_velocity_loops(data)
plt.show()
plot_attitude_rate_loops(data)
plt.show()
plot_attitude_loops(data)
plt.show()
plot_faults(data)
plt.show()
pos_analysis(data)
plt.show()

Is this the correct way to display the plots ? I couldn't find any other way !

jgoppert commented 7 years ago

Each ipython cell basically calls plt.figure (), runs the cell, then calls plt.show (), so you could just call plt.figure() before each new plot command and plt show () at the end. If you are trying to use it for log analysis I would recommend trying Jupyter and ipython notebooks. That is the work flow I use.

TarekTaha commented 7 years ago

Thank you @jgoppert for your reply.

Excuse my ignorance, I've never used ipython or Jupyter netbooks, so I have no idea how to run these scripts, can you please tell me how to run these scripts.

jgoppert commented 7 years ago

Follow along here: https://github.com/dronecrew/px4tools#using-anaconda-recommended