onguntoglu / pyadrc

Active Disturbance Rejection Control for Python
MIT License
31 stars 11 forks source link

quadcopter_basic.ipynb #29

Open shclift opened 1 year ago

shclift commented 1 year ago

Description

  1. Need to change t_settle to w_cl for more recent pyadrc versions.
  2. The disturbance rejection example seems to have problems for versions > 0.3.0

What I Did

Ran the Jupyter notebook for the different releases. With 0.3.0 I get this:

image

With 0.3.1 and more recent versions I get this:

image

Am I doing something wrong?

shclift commented 1 year ago

I think I found the problem:

...

self._update_eso(y, u) # <<< Wrong place for this?

    if self.inc_form is False:
        u = (self.Kp / self.b0) * r - self.w.T @ self.xhat
        u = self._limiter(u)
    else:  # self.inc_form is True:
        delta_r = r - self.rkm1
        delta_u = ((self.Kp / self.b0) * delta_r
                   - self.w.T @ self.xhat_delta)
        u = delta_u

        self.rkm1 = r

    self._update_eso(y, u)

...

Seems to work with the ESO update moved after the calculation of u - same as 0.3.0.

s03311251 commented 10 months ago

Were you referring to these lines? I also experience a similar problem with the latest version (0.4.1). https://github.com/onguntoglu/pyadrc/blob/06291221f2ecc0732ac4718dfc062614d1c523d8/docs/notebooks/quadcopter_basic.ipynb#L101-L103

The jyputer notebook is not execuable anymore, because t_settle was, but no longer is the input parameter of constructor. Previous version: https://github.com/onguntoglu/pyadrc/blob/78806774f11aec9dee9f62fad237c7a1c238e0de/pyadrc/pyadrc.py#L71-L80 Current version: https://github.com/onguntoglu/pyadrc/blob/06291221f2ecc0732ac4718dfc062614d1c523d8/pyadrc/pyadrc.py#L87-L97

now t_settle = 4 / w_cl, hence I think the lines should be changed as following:

  "adrc = pyadrc.StateSpace(order=2, delta=delta,\n", 
  "                         b0=1/0.028, w_cl=4/0.5, k_eso=10)" 
 ] 
s03311251 commented 10 months ago

An off-topic comment, if you're updating the file, could you please update this line too? There's a typo in \frac https://github.com/onguntoglu/pyadrc/blob/06291221f2ecc0732ac4718dfc062614d1c523d8/docs/notebooks/quadcopter_basic.ipynb#L201 It would be clearer if it is expressed as $b_0 = \frac{1}{2} \frac{1}{0.028}$