dronecrew / px4tools

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

'System Identification and Control Design' example running error #30

Open Maelok opened 6 years ago

Maelok commented 6 years ago

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()**