Git Product home page Git Product logo

px4tools's Introduction

px4tools

Build Status Coverage Status Documentation Status

Anaconda

Linux: Circle CI OSX: TravisCI Windows: AppVeyor Version: Anaconda-Server Badge Downloads: Anaconda-Server Badge

A log analysis toolbox for the PX4 autopilot written in python.

Features

  • Flight Plotting using standard python libraries.
  • Automatic System Identification from log data.
  • Automatic Control Design from log data.
  • Cross-Platform deployment, testing, and support (Windows/OSX/Linux).
  • Well integrated with Jupyter notebook and Pandas.
  • Natively uses pandas CSV format so easily integrated with all log formats.

Usage

  1. px4log format

    First use the sdlog2_dumpy.py program to convert the px4log to csv:

    wget https://github.com/PX4/Firmware/raw/master/Tools/sdlog2/sdlog2_dump.py
    python sdlog2_dumpy.py your_log.px4log > your_log.csv

    Now start jupyter notebook in the directoy of your_log.csv:

    jupyter notebook
  2. ulog format

    No preprocessing required, see ulog example.

Examples:

  1. Automatic System Identification and Control Design
  2. General Flight Data Plotting
  3. ULOG basic use.
  4. ULOG noise analysis.

Install

Dependencies

  1. See setup.py install_requires

    For pandas, to fix time series plotting memory issue with time delta index you need this branch:

    . conda_env (See instructions below for setting up conda_env script)
    git clone [email protected]:jgoppert/pandas.git
    cd pandas
    git checkout tdi_plot_fix
    python setup.py install

Using Anaconda (Recommended)

  1. Install anaconda

    • Python 3 version recommended
    • Do not select add to path if you use ROS. ROS expects the standard python to be installed. You can create a script to source and add anaconda to your path. This is similar to setup.bash for ROS users.

    ~/bin/conda_env:

    #!/bin/bash
    export PATH=$HOME/anaconda3/bin:$PATH

    Now you can source the script to start using anaconda instead of the sytem python:

    . conda_env
  2. Install px4tools via conda

    conda config --add channels conda-forge
    conda install px4tools jupyter
  3. Upgrading px4tools using pip in conda

    The conda-forge px4tools package usually lags behind master. If you need the latest code, use pip within your conda env.

    . conda_env
    pip install px4tools
  4. Building px4tools form source and installing to conda environment

    If you want to do development and edit some of the source, follow this example:

    . conda_env
    git clone [email protected]:dronecrew/px4tools.git
    cd px4tools
    python setup.py build install

Using PyPi

pip install px4tools jupyter --user

px4tools's People

Contributors

bkueng avatar jgoppert avatar jlecoeur avatar mayanez avatar stifael avatar tsc21 avatar wangwwno1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

px4tools's Issues

Error while executing Log based System Identification and Control Design.ipynb example

I am trying to use the logsysid module in the px4tools on one of the logs that I fetched from Pixhawk, running PX4 stack.

When I run the provided example in ,
https://github.com/dronecrew/px4tools/blob/master/examples/Log%20based%20System%20Identification%20and%20Control%20Design.ipynb

I get the following error

fit quality 88.29 %

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-cf0438594eeb> in <module>()
      1 gains, design_data = px4tools.logsysid.control_design(data[20:80],
----> 2     do_plot=True)
      3 print(json.dumps(gains, indent=4))

/home/abdkadma/anaconda2/lib/python2.7/site-packages/px4tools/logsysid.pyc in control_design(raw_data, do_plot, rolling_mean_window)
    359     K_roll = attitude_control_design(
    360         'roll rate', roll_acc, data.ATTC_Roll,
--> 361         rolling_mean_window=rolling_mean_window, do_plot=do_plot)
    362 
    363     pitch_acc = data.ATT_PitchRate.diff()/dt

/home/abdkadma/anaconda2/lib/python2.7/site-packages/px4tools/logsysid.pyc in attitude_control_design(name, y, u, rolling_mean_window, do_plot, verbose)
    319 
    320     K, G_ol_rate, G_cl_rate = attitude_rate_design(
--> 321         G_ol, K_guess, d_tc, verbose)
    322 
    323     if do_plot:

/home/abdkadma/anaconda2/lib/python2.7/site-packages/px4tools/logsysid.pyc in attitude_rate_design(G, K_guess, d_tc, verbose)
    260     H = control.tf(H_num, H_den)
    261 
--> 262     ss_open = control.tf2ss(G*H)
    263 
    264     if verbose:

/home/abdkadma/anaconda2/lib/python2.7/site-packages/control/matlab.pyc in tf2ss(*args)
    762             raise TypeError("tf2ss(sys): sys must be a TransferFunction \
    763 object.")
--> 764         return _convertToStateSpace(sys)
    765     else:
    766         raise ValueError("Needs 1 or 2 arguments; received %i." % len(args))

/home/abdkadma/anaconda2/lib/python2.7/site-packages/control/statesp.pyc in _convertToStateSpace(sys, **kw)
    665             # I think this will fail if num and den aren't 1-D after
    666             # the squeeze
--> 667             lti_sys = lti(squeeze(sys.num), squeeze(sys.den))
    668             return StateSpace(lti_sys.A, lti_sys.B, lti_sys.C, lti_sys.D,
    669                               sys.dt)

/home/abdkadma/anaconda2/lib/python2.7/site-packages/scipy/signal/ltisys.pyc in __init__(self, *system, **kwargs)
    759         self._den = None
    760 
--> 761         self.num, self.den = normalize(*system)
    762 
    763     def __repr__(self):

/home/abdkadma/anaconda2/lib/python2.7/site-packages/scipy/signal/filter_design.pyc in normalize(b, a)
   1084     if len(b.shape) == 1:
   1085         b = asarray([b], b.dtype.char)
-> 1086     while a[0] == 0.0 and len(a) > 1:
   1087         a = a[1:]
   1088     outb = b * (1.0) / a[0]

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()


What could be the problem?

Readme panda branch not up to date

Hello,
It is not very clear from the 1st point what pandas is usefull for.

The branch you ask to checkout no longer exists.
I think that you should instead prefer using tags that should not vanish anymore.

I tried updating with latest release instead, v0.19.99
Should it be all right ?

Thanks in advance

Use import matplotlib.pylab instead of import pylab

http://stackoverflow.com/questions/32279887/pylab-module-object-has-no-attribute-figure

I was initially unable to use px4tools because the pl namespace was empty, a la http://stackoverflow.com/questions/30880407/pylab-does-not-have-any-attrs/30880734.

This doesn't seem to be a universally solvable problem, so the general consensus I saw via google is to use import matplotlib.pylab as pl instead of import pylab as pl. I worked around this with the upstream px4tools code by having to pip uninstall both pylab and matplotlib, and then pip install matplotlib.

If this is a useful change, it might be helpful to update https://github.com/jgoppert/lpe-analysis/blob/master/15-09-30%20Kabir%20Log.ipynb at the same time.

missing 'TIME_StartTime' field from .ulg logfiles

I'd like to use the systems identification features of this package but my flight logs don't contain the 'TIME_StartTime' field - nor is the field present in the example .ulg file in this package (examples/ulog/22_03_28.ulg) and doesn't seem to be a uorb topic :. not something I can just start logging. TIME_StartTime appears to just be a realtime clock value in microseconds so it should be possible to create this but I was thinking there must be an existing script for this purpose? Or perhaps I am mistaken and I can correct for this error in my logger profile?

Installation error on JupyterHub docker image

I get this error when trying to install px4tools

/srv/jupyterhub# pip2 install px4tools
Collecting px4tools
  Using cached px4tools-0.2.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-I8E3tS/px4tools/setup.py", line 165, in <module>
        setup_package()
      File "/tmp/pip-build-I8E3tS/px4tools/setup.py", line 127, in setup_package
        write_version_py()
      File "/tmp/pip-build-I8E3tS/px4tools/setup.py", line 108, in write_version_py
        FULLVERSION, GIT_REVISION = get_version_info()
      File "/tmp/pip-build-I8E3tS/px4tools/setup.py", line 84, in get_version_info
        raise ImportError(e + "Unable to import git_revision. Try removing "
    TypeError: unsupported operand type(s) for +: 'exceptions.ImportError' and 'str'

This works on my OSX installation, where I am also using Python 2, so it's unclear to me where this problem is coming from.

Numpy depencency for PiPy package

@jgoppert hey I was just trying to build the PX4 Docker base container locally and had some issues installing px4tools:

Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
Installing collected packages: pip
  Found existing installation: pip 8.1.1
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
Successfully installed pip-9.0.1
Collecting setuptools
  Downloading setuptools-32.3.0-py2.py3-none-any.whl (479kB)
Installing collected packages: setuptools
Successfully installed setuptools-32.3.0
Collecting px4tools
  Downloading px4tools-0.6.5.tar.gz
Collecting scipy (from px4tools)
  Downloading scipy-0.18.1-cp27-cp27mu-manylinux1_x86_64.whl (40.3MB)
Collecting numpy (from px4tools)
  Downloading numpy-1.11.3-cp27-cp27mu-manylinux1_x86_64.whl (15.4MB)
Collecting pandas>=0.19.1 (from px4tools)
  Downloading pandas-0.19.2-cp27-cp27mu-manylinux1_x86_64.whl (17.2MB)
Collecting transforms3d (from px4tools)
  Downloading transforms3d-0.3.zip (76kB)
Collecting pyulog (from px4tools)
  Downloading pyulog-0.0.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-zRTJvc/pyulog/setup.py", line 168, in <module>
        setup_package()
      File "/tmp/pip-build-zRTJvc/pyulog/setup.py", line 127, in setup_package
        write_version_py()
      File "/tmp/pip-build-zRTJvc/pyulog/setup.py", line 108, in write_version_py
        FULLVERSION, GIT_REVISION = get_version_info()
      File "/tmp/pip-build-zRTJvc/pyulog/setup.py", line 84, in get_version_info
        raise ImportError(str(e) + " - Unable to import git_revision. Try removing "
    ImportError: No module named numpy - Unable to import git_revision. Try removing pyulog/version.py and the build directory before building.
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-zRTJvc/pyulog/

It seems even though it installs numpy as part of the dependencies it cannot be used in the same "step" as installing it. I needed to install numpy beforehand, maybe you know a way around this :)

Question: Plotting

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 !

System Identification using the log data

As pointed out by @mhkabir I followed this thread to collect the data from the px4log file to perform System Identification of the tricopter. But, I am running into some difficulties and I think the sampling of the inputs I'm giving has something to do with it. I'm using my own MATLAB code following the Output Error Method to perform the system identification. Earlier, I was collecting the data directly from MAVROS and it didn't work out, probably because of the sampling time. In your python script "logsysid.py" I noticed that you resample and then interpolate the data before sysid. Why do you do so? If you could help me, would be a great help!

Thanks
Sid

WARNING: poor sysid fit

Hi @jgoppert

I am using px4log log to do sysid and controls design using px4tools. I tried different log files with different flight lengths, indoors and outdoors, but I always get WARNING: poor sysid fit

I even set log priority to Maximum, but didn't help.

Do you have any clue on what could be the issue?
sysid_logs.zip

Thanks.

module' object has no attribute 'ulog2csv'

I am getting attribute error while reading the file in jupyter notebook.

import px4tools
from px4tools import pandas
import pylab as plt

plt.rcParams['figure.figsize'] = (10, 5)
plt.rcParams['lines.linewidth'] = 3

Works fine but

d = px4tools.read_ulog('mylg.ulg')

AttributeError                            Traceback (most recent call last)
<ipython-input-7-b94e281a6984> in <module>()
----> 1 d = px4tools.read_ulog('mylg.ulg')

/home/yograj/anaconda2/lib/python2.7/site-packages/px4tools/ulog.pyc in read_ulog(ulog_filename, messages, verbose)
    365 
    366     tmp_dir = tempfile.mkdtemp()
--> 367     pyulog.ulog2csv.convert_ulog2csv(
    368         ulog_filename, messages, tmp_dir, ',')
    369     log_name = os.path.splitext(os.path.basename(ulog_filename))[0]

AttributeError: 'module' object has no attribute 'ulog2csv'

Issue with ulog analysis.ipynb

Hi I'm running in the following issue will trying the example.

    365 
    366     tmp_dir = tempfile.mkdtemp()
--> 367     pyulog.ulog2csv.convert_ulog2csv(
    368         ulog_filename, messages, tmp_dir, ',')
    369     log_name = os.path.splitext(os.path.basename(ulog_filename))[0]

AttributeError: module 'pyulog' has no attribute 'ulog2csv'

No documentation for logsysid.py

Hi,

I am interested to know what logsysid.py does?
Does it try to find the a good PID gains given some logs of PX4?
How to use it? is there an example code?

Thanks.

. conda_env doesn't run

I installed anaconda from the link given in the installation instructions. I follow the steps to set the path but when I run . conda_env, I get the following error

-bash: conda_env: No such file or directory

I searched in the /anaconda3/bin/ directory and found that there is no such file. I found conda-env file so I ran . conda-env but I get the following error:

-bash: import: command not found
-bash: import: command not found
from: can't read /var/mail/conda_env.cli.main
-bash: /anaconda3/bin/conda-env: line 10: syntax error near unexpected token (' -bash: /anaconda3/bin/conda-env: line 10: sys.argv[0] = re.sub(r'(-script.pyw?|.exe)?$', '', sys.argv[0])'

Can anyone help me with this?

AttributeError: 'DataFrame' object has no attribute 'TIME_StartTime'

I installed px4tools using conda and everything works fine, except for
px4tools.logsysid.control_design_ulog(data, do_plot=True)
Jupyter notebook returns:

AttributeError Traceback (most recent call last)
in
----> 1 px4tools.logsysid.control_design(data, do_plot=True)

~/anaconda3/lib/python3.6/site-packages/px4tools/logsysid.py in control_design(raw_data, do_plot, rolling_mean_window, verbose)
403 :return: (gain ordered dict, local variables)
404 """
--> 405 data, dt = setup_data(raw_data)
406 d_tc = 1.0 / 125 # nyquist frequency of derivative in PID, (250 Hz/2)
407 K_guess_att = np.matrix([[1.0]]).T

~/anaconda3/lib/python3.6/site-packages/px4tools/logsysid.py in setup_data(df)
25 :return: (df_rs, dt) resample dataframe and period (1 ms)
26 """
---> 27 df = px4tools.get_float_data(df)
28
29 t = pandas.to_timedelta(

~/anaconda3/lib/python3.6/site-packages/px4tools/analysis.py in get_float_data(dataframe)
165 Get float data out of dataframe.
166 """
--> 167 dataframe = dataframe[np.isfinite(dataframe.TIME_StartTime)]
168 float_cols = [isfloatarray(col) for col in dataframe.values.T]
169 return (dataframe.T[float_cols].T).astype(float)

~/.local/lib/python3.6/site-packages/pandas/core/generic.py in getattr(self, name)
5065 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5066 return self[name]
-> 5067 return object.getattribute(self, name)
5068
5069 def setattr(self, name, value):

AttributeError: 'DataFrame' object has no attribute 'TIME_StartTime'

Is there any resolution for this issue ? or how can I see analyze for PID controller?

'System Identification and Control Design' example running error too

When i run the System Identification and Control Design example , in step 3 i got this error. How can i fix it? @jgoppert

/home/user/anaconda3/lib/python3.6/site-packages/control/freqplot.py:153: MatplotlibDeprecationWarning: pyplot.hold is deprecated.
    Future behavior will be consistent with the long-time default:
    plot commands add elements without first clearing the
    Axes and/or Figure.
  plt.hold(True);
/home/user/anaconda3/lib/python3.6/site-packages/matplotlib/__init__.py:805: MatplotlibDeprecationWarning: axes.hold is deprecated. Please remove it from your matplotlibrc and/or style files.
  mplDeprecation)
/home/user/anaconda3/lib/python3.6/site-packages/matplotlib/rcsetup.py:155: MatplotlibDeprecationWarning: axes.hold is deprecated, will be removed in 3.0
  mplDeprecation)
/home/user/anaconda3/lib/python3.6/site-packages/control/freqplot.py:163: MatplotlibDeprecationWarning: pyplot.hold is deprecated.
    Future behavior will be consistent with the long-time default:
    plot commands add elements without first clearing the
    Axes and/or Figure.
  plt.hold(True);
/home/user/anaconda3/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py:106: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
  warnings.warn(message, mplDeprecation, stacklevel=1)

margins (1.6063530208385868, 53.69495402420043, 31.494696420182457, 92.34314850122355)
margins (3.865272625550007, 67.586291048282, 9.166550830029614, 48.26946306098183)
      fun: 234778.47387434263
 hess_inv: <2x2 LbfgsInvHessProduct with dtype=float64>
      jac: array([-1.61817297e+00,  1.64574164e+05])
  message: b'ABNORMAL_TERMINATION_IN_LNSRCH'
     nfev: 351
      nit: 16
   status: 2
  success: False
        x: array([1.88306637e+02, 4.49999996e-02])

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-6-e515a7be8a66> in <module>()
      1 gains, design_data = px4tools.logsysid.control_design(data[20:80],
----> 2     do_plot=True)
      3 print(json.dumps(gains, indent=4))

~/anaconda3/lib/python3.6/site-packages/px4tools/logsysid.py in control_design(raw_data, do_plot, rolling_mean_window, verbose)
    388         'pitch rate', pitch_acc, data.ATTC_Pitch,
    389         rolling_mean_window=rolling_mean_window,
--> 390         do_plot=do_plot, d_tc=d_tc, verbose=verbose)
    391 
    392     K_pitch, G_pitch, G_cl_pitch = pid_design(

~/anaconda3/lib/python3.6/site-packages/px4tools/logsysid.py in attitude_control_design(name, y, u, rolling_mean_window, do_plot, verbose, d_tc)
    327 
    328     G_ol, delay, k = attitude_sysid(
--> 329         y_debiased, u_debiased, verbose)
    330 
    331     K, G_ol_rate, G_cl_rate = pid_design(

~/anaconda3/lib/python3.6/site-packages/px4tools/logsysid.py in attitude_sysid(y_acc, u_mix, verbose)
    228     if verbose:
    229         print('solving for plant model ', end='')
--> 230     k, delay = delay_and_gain_sysid(y_acc, u_mix, verbose)
    231     if verbose:
    232         print('done')

~/anaconda3/lib/python3.6/site-packages/px4tools/logsysid.py in delay_and_gain_sysid(y, u, verbose)
     86     if res['success'] != True:
     87         print(res)
---> 88         raise RuntimeError('optimization failed')
     89     elif verbose:
     90         print(res)

RuntimeError: optimization failed


No Module named control

Hi,

I am trying to run the automatic sysid and control example. When I execute the first block

%load_ext autoreload
%autoreload 2c
import px4tools
import px4tools.logsysid
import pandas
import control
import json
%pylab inline

I get the following error:

/home/abdkadma/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-eb5f1f38bc91> in <module>()
      2 get_ipython().magic(u'autoreload 2c')
      3 import px4tools
----> 4 import px4tools.logsysid
      5 import pandas
      6 import control

/home/abdkadma/anaconda2/lib/python2.7/site-packages/px4tools/logsysid.py in <module>()
      6 
      7 import pandas
----> 8 import control
      9 import scipy.optimize
     10 import scipy.signal

ImportError: No module named control

What could be the issue?

alt_analysis issue

I tried reading data from csv file and use function alt_analysis, but I get an error in the analysis code related to the index of the data. the error message is as follows:

/home/kuri/anaconda3/lib/python3.6/site-packages/px4tools/analysis.py in alt_analysis(data, min_alt, max_alt)
    107         pass
    108     (-1*data.LPSP_Z).plot(legend=True)
--> 109     (data.SENS_BaroAlt - data.SENS_BaroAlt[i0_Baro].values[0]).plot(legend=True)
    110     (data.GPS_Alt - data.GPS_Alt[i0_GPS].values[0]).plot(legend=True)
    111     (-1*data).LPOS_Z.plot(legend=True)
AttributeError: 'numpy.float64' object has no attribute 'values'

I modified alt_analysis function in analysis.py by removing the [i0_GPS] & [i0_Baro] since each of the GPS_Alt, and SENS_BaroAlt is field by itself in the csv file and it is np array that could be accessed using values. Also, printing i0_Baro = data.SENS_BaroAlt.first_valid_index() doesn't return the correct first valid index so I had to find the first correct index. I also modified mapping in the same way since it also complained about the index index 0 is out of bounds for axis 0 with size 0...

The changes that were done could be found in the following links:
analysis.py
mapping.py

After these modifications, the plots were generated,
but I would like to verify these modifications or know if this issue appears to others or did it happen because of the log that was used ??

The 'or' needs to be 'and'

elif 't_vehicle_groundtruth_0__f_q_0_' in df or 't_vehicle_local_position_0__f_x' in df:

When use px4tools, I encountered the error shown as below:

'DataFrame' object has no attribute 't_vehicle_groundtruth_0__f_q_0_'

After tracing the error, I found a bug. In my ulog data I have t_vehicle_local_position_0__f_x but no t_vehicle_groundtruth_0__f_q_0_. But the code under the if statement rely on both of them, the code below shouldn't be executed.

module 'scipy.linalg' has no attribute 'solve_lyapunov'

I am getting the following error when I run the sysid example provided with the px4tools package.

module 'scipy.linalg' has no attribute 'solve_lyapunov'

I am using anaconda3. Tried to update scipy either via conda or pip, but the error persists.

Any hints?

'System Identification and Control Design' example running error

Hi,

After installed this tools according to the instruction, I was trying to run the 'System Identification and Control Design' example but some error occured.

The python version is 2.7 and Anaconda version is also for python2.

Here is result:

**gains, design_data = px4tools.logsysid.control_design(data[20:80], do_plot=True)
print(json.dumps(gains, indent=4))
fit quality 88.08 %


ValueError Traceback (most recent call last)
in ()
----> 1 gains, design_data = px4tools.logsysid.control_design(data[20:80], do_plot=True)
2 print(json.dumps(gains, indent=4))

/home/maelok/anaconda2/lib/python2.7/site-packages/px4tools/logsysid.pyc in control_design(raw_data, do_plot, rolling_mean_window, verbose)
372 'roll rate', roll_acc, data.ATTC_Roll,
373 rolling_mean_window=rolling_mean_window,
--> 374 do_plot=do_plot, verbose=verbose, d_tc=d_tc)
375
376 tf_integrator = control.tf((1), (1, 0))

/home/maelok/anaconda2/lib/python2.7/site-packages/px4tools/logsysid.pyc in attitude_control_design(name, y, u, rolling_mean_window, do_plot, verbose, d_tc)
330
331 K, G_ol_rate, G_cl_rate = pid_design(
--> 332 G_ol, K_guess, d_tc, verbose)
333
334 if do_plot:

/home/maelok/anaconda2/lib/python2.7/site-packages/px4tools/logsysid.pyc in pid_design(G, K_guess, d_tc, verbose, use_P, use_I, use_D)
272 # print('H', H)
273
--> 274 ss_open = control.tf2ss(G*H)
275
276 if verbose:

/home/maelok/anaconda2/lib/python2.7/site-packages/control/matlab.pyc in tf2ss(*args)
762 raise TypeError("tf2ss(sys): sys must be a TransferFunction
763 object.")
--> 764 return _convertToStateSpace(sys)
765 else:
766 raise ValueError("Needs 1 or 2 arguments; received %i." % len(args))

/home/maelok/anaconda2/lib/python2.7/site-packages/control/statesp.pyc in _convertToStateSpace(sys, **kw)
665 # I think this will fail if num and den aren't 1-D after
666 # the squeeze
--> 667 lti_sys = lti(squeeze(sys.num), squeeze(sys.den))
668 return StateSpace(lti_sys.A, lti_sys.B, lti_sys.C, lti_sys.D,
669 sys.dt)

/home/maelok/.local/lib/python2.7/site-packages/scipy/signal/ltisys.pyc in init(self, *system, **kwargs)
760 self._den = None
761
--> 762 self.num, self.den = normalize(*system)
763
764 def repr(self):

/home/maelok/.local/lib/python2.7/site-packages/scipy/signal/filter_design.pyc in normalize(b, a)
1434
1435 # Trim leading zeros in denominator, leave at least one.
-> 1436 den = np.trim_zeros(den, 'f')
1437
1438 # Normalize transfer function

/home/maelok/.local/lib/python2.7/site-packages/numpy/lib/function_base.pyc in trim_zeros(filt, trim)
2244 if 'F' in trim:
2245 for i in filt:
-> 2246 if i != 0.:
2247 break
2248 else:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()**

ValueError: 'timestamp' is both an index level and a column label, which is ambiguous.

Hello,

When i run those codes in Jupyter Notebook from here:
d_concat = d.concat(dt=0.01)
d_concat_computed = px4tools.compute_data(d_concat)
px4tools.estimator_analysis(d_concat_computed)

It show me the following error:

ValueError Traceback (most recent call last)
in
----> 1 d_concat = d.concat(dt=0.01)
2 d_concat_computed = px4tools.compute_data(d_concat)
3 px4tools.estimator_analysis(d_concat_computed)

~\anaconda3\lib\site-packages\px4tools\ulog.py in concat(self, topics, on, dt, verbose)
651 print('merging {:s} as of timestamp'.format(topic))
652 df = d[topic]
--> 653 df.sort_values(by='timestamp', inplace=True)
654 m = pd.merge_asof(m, df, 'timestamp')
655 m.index = pd.TimedeltaIndex(m.timestamp * 1e3, unit='ns')

~\anaconda3\lib\site-packages\pandas\core\frame.py in sort_values(self, by, axis, ascending, inplace, kind, na_position, ignore_index)
4925
4926 by = by[0]
-> 4927 k = self._get_label_or_level_values(by, axis=axis)
4928
4929 if isinstance(ascending, (tuple, list)):

~\anaconda3\lib\site-packages\pandas\core\generic.py in _get_label_or_level_values(self, key, axis)
1685
1686 if self._is_label_reference(key, axis=axis):
-> 1687 self._check_label_or_level_ambiguity(key, axis=axis)
1688 values = self.xs(key, axis=other_axes[0])._values
1689 elif self._is_level_reference(key, axis=axis):

~\anaconda3\lib\site-packages\pandas\core\generic.py in _check_label_or_level_ambiguity(self, key, axis)
1645 f"{label_article} {label_type} label, which is ambiguous."
1646 )
-> 1647 raise ValueError(msg)
1648
1649 def _get_label_or_level_values(self, key: str, axis: int = 0) -> np.ndarray:

ValueError: 'timestamp' is both an index level and a column label, which is ambiguous.

Does anyone know What’s the problem?

Thx a lot.

example test error

hi, i got a error when i ran "Log based System Identification and Control Design" in Cell 1.
Well, how can i fix the error? Need help, thx~


KeyError Traceback (most recent call last)
in ()
1 get_ipython().run_line_magic('load_ext', 'autoreload')
2 get_ipython().run_line_magic('autoreload', '2c')
----> 3 import px4tools
4 import px4tools.logsysid
5 import pandas

~/miniconda3/lib/python3.6/site-packages/px4tools/init.py in ()
2
3 try:
----> 4 from .mapping import *
5 except ImportError as ex:
6 print(ex)

~/miniconda3/lib/python3.6/site-packages/px4tools/mapping.py in ()
6
7 from future import print_function
----> 8 from mpl_toolkits.basemap import Basemap
9 import pandas
10

~/miniconda3/lib/python3.6/site-packages/mpl_toolkits/basemap/init.py in ()
144
145 # create dictionary that maps epsg codes to Basemap kwargs.
--> 146 pyproj_datadir = os.environ['PROJ_LIB']
147 epsgf = open(os.path.join(pyproj_datadir,'epsg'))
148 epsg_dict={}

~/miniconda3/lib/python3.6/os.py in getitem(self, key)
667 except KeyError:
668 # raise KeyError with the original key value
--> 669 raise KeyError(key) from None
670 return self.decodevalue(value)
671

KeyError: 'PROJ_LIB'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.