```python
import sys
if not '..' in sys.path:
    sys.path.insert(0, '..')
import control
import sympy
import numpy as np
import matplotlib.pyplot as plt
import ulog_tools as ut
import ulog_tools.control_opt as opt

%matplotlib inline
%load_ext autoreload
%autoreload 2
```

    The autoreload extension is already loaded. To reload it, use:
      %reload_ext autoreload


# System Identification


```python
log_file = ut.ulog.download_log('http://review.px4.io/download?log=35b27fdb-6a93-427a-b634-72ab45b9609e', '/tmp')
data = ut.sysid.prepare_data(log_file)
res = ut.sysid.attitude_sysid(data)
res
```




    {'pitch': {'model': {'delay': 0.051503721021908873,
       'f_s': 232.99287433805779,
       'fit': 0.57135828183122261,
       'gain': 29.538707721830491,
       'sample_delay': 12},
      't_end': 80,
      't_start': 75},
     'roll': {'model': {'delay': 0.072963604781037569,
       'f_s': 232.99287433805779,
       'fit': 0.80970246292599435,
       'gain': 45.686710321167887,
       'sample_delay': 17},
      't_end': 105,
      't_start': 100},
     'yaw': {'model': {'delay': 0.11159139554746923,
       'f_s': 232.99287433805779,
       'fit': 0.87415539224859207,
       'gain': 41.274521147805387,
       'sample_delay': 26},
      't_end': 5,
      't_start': 0}}



# Continuous Time Optimization


```python
opt.attitude_loop_design(res['roll']['model'], 'ROLL', d)
```


```python
attitude_loop_design(res['pitch']['model'], 'PITCH')
```




    {'MC_PITCHRATE_D': 0.015662896675004697,
     'MC_PITCHRATE_I': 0.48847645640076243,
     'MC_PITCHRATE_P': 0.51104029619426683,
     'MC_PITCH_P': 5.8666514695501988}




```python
attitude_loop_design(res['yaw']['model'], 'YAW')
```




    {'MC_YAWRATE_D': 0.017251069591687748,
     'MC_YAWRATE_I': 0.19498248018478978,
     'MC_YAWRATE_P': 0.18924319337905329,
     'MC_YAW_P': 3.598452484267229}



aa968dd62ad677f36cf9425507b2e8b35e29dbb9
ipynb
Jupyter Notebook
notebooks/old/System ID.ipynb
dronecrew/ulog_tools
65aabdf8c729d8307b6bab2e0897ecf2a222d6bb
BSD-3-Clause
2017-07-07T15:26:45.000Z
2021-01-29T11:00:37.000Z
notebooks/old/System ID.ipynb
dronecrew/ulog_tools
65aabdf8c729d8307b6bab2e0897ecf2a222d6bb
BSD-3-Clause
2017-09-05T18:56:57.000Z
2021-09-12T09:35:19.000Z
notebooks/old/System ID.ipynb
dronecrew/ulog_tools
65aabdf8c729d8307b6bab2e0897ecf2a222d6bb
BSD-3-Clause
2017-07-03T19:48:30.000Z
2021-07-06T14:26:27.000Z
Qwen/Qwen-72B
1. YES
2. YES