dronecrew / px4tools

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

Sysid and control design using ulog #26

Open mzahana opened 6 years ago

mzahana commented 6 years ago

Hi @jgoppert

Can ulog files be used in the sysid and control design instead of px4log? If yes, what is the procedure to do it?

Thanks.

jannsta1 commented 6 years ago

Hi @mzahana,

You could try using this repo instead: https://github.com/dronecrew/ulog_tools.

I would also be interested in seeing a best practices procedure for this - e.g. how to set the parameters and if logfiles with particular flight manoeuvres produce better results.

mzahana commented 6 years ago

@jannsta1 Thanks for pointing me out to that repo. I will try it and provide my feedback.

mzahana commented 6 years ago

I am getting the following error.

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

I am using

Any idea how to fix this?

EDIT:

doing conda list | grep scipy gives

scipy                     1.0.0            py36h1de22e9_0    anaconda
mzahana commented 6 years ago

Ok. I got it working by installing an earlier version ofscipy=0.19.1

jannsta1 commented 6 years ago

Glad you got it working @mzahana. Would be interested to know if you do manage to get some good results from the package? By naively running I don't seem to get a particularly good tune, especially in yaw and pitch fails entirely! Planning to play around with the matlab toolbox a bit so I understand the parameters better and then coming back to it.

mzahana commented 6 years ago

Same here. I am not getting good identification of the control gains and I fall back to old set of gains that work much better. I will study more how this can be improved. It also would be good to know what you exactly plan to use (algortihms) to solve this issue.

DanAbara commented 5 years ago

@mzahana and @jannsta1 I have also used the repo suggested on this thread, however I get the following error when I run the module to obtain the sample frequency: KeyError Traceback (most recent call last)

in 6 comb = ut.sysid.prepare_data('log_48.ulg') 7 ----> 8 sf = ut.ulog.sample_frequency(log) ~\.conda\envs\ut_env\lib\site-packages\ulog_tools\_ulog.py in sample_frequency(data) 28 def sample_frequency(data): 29 """Compute sampling frequency""" ---> 30 return 1.0e6 / np.diff(data['f_timestamp']).mean() KeyError: 'f_timestamp' I have scipy=0.19 so that is probably not the problem. Any suggestions would be greatly appreciated. I struggled with the px4tools and got stuck so decided to try the ulog_tools repo. Thanks in advance.
DanAbara commented 5 years ago

Update: @mzahana and @jannsta1 So I sorted it out and its all working now. I have another question though, how can I export data to csv. For instance, if I use the prepare_data module in the '_sysid.py' file, I obtain a data structure which holds the re-sampled input/output data in a tabular form. I plan to export this to a csv and perform identification in matlab, to see how that goes, but I have little or no idea how to do that. I'm quite new to python, just learning the ropes. Any advice to ease my struggle will be helpful.

Thank you.

jannsta1 commented 5 years ago

From what I remember it's a pandas data frame which has a built in to_csv() method. I think there are also libraries that convert .ulg files directly into MATLAB data structures.

DanAbara commented 5 years ago

@jannsta1 if i understand correctly, you're saying the output data structure of the resampled data is a pandas data frame with a built in to_csv() method (don't know what that means though I'll look it up), so that means there should be some way to open it as a csv or convert it to csv etc right? Thanks by the way for responding.

Update: So I managed to get it sorted as well. Thank you very much @jannsta1. Best wishes.

DanAbara commented 5 years ago

@jgoppert , @jannsta1 and @mzahana have to trouble you guys again. I have a question about the sysid process in the ulog_tools package.

Why is the output signal (angular velocity) differentiated to get accelerations before the sys id?

Why is the signal not used directly?

Thank you