You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug in create_statefbk_iosystem, option refgain #1189
Matrix D_lqr is not correctly constructed if integral action is used in 'refgain' form. The line:
D_lqr = np.hstack([Kf, -K])
should read:
D_lqr = np.hstack([Kf, -K[:, :sys_nstates]])
as K[:, sys_nstates:] is already used in C_lqr, D_lqr is too wide.
Thanks for the post! I'll look into this, but if you can also post some code that generates the error, that would be helpful (and we can add it to the unit tests).
This is my code with modified function. bug.py
Replacing by the library version throws error:
Traceback (most recent call last):
File "<string>", line 17, in __PYTHON_EL_eval
File "/home/fikar/miro/doc/pedagog/tar2/course_2_tar2/exercises/week_02/python/bug.py", line 54, in <module>
ctrl, sys_cl = ct.create_statefbk_iosystem(sys_ol_full, KK, Kr, integral_action=C, feedfwd_pattern='refgain')
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fikar/miniconda3/lib/python3.13/site-packages/control/statefbk.py", line 1011, in create_statefbk_iosystem
ctrl = ss(
A_lqr, B_lqr, C_lqr, D_lqr, dt=sys.dt, name=name,
inputs=inputs, outputs=outputs, states=states)
File "/home/fikar/miniconda3/lib/python3.13/site-packages/control/statesp.py", line 1745, in ss
sys = StateSpace(*args, **kwargs)
File "/home/fikar/miniconda3/lib/python3.13/site-packages/control/statesp.py", line 272, in __init__
_check_shape(D, self.noutputs, self.ninputs, name="D")
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fikar/miniconda3/lib/python3.13/site-packages/control/mateqn.py", line 645, in _check_shape
raise ControlDimension(
f"Incompatible dimensions of {name} matrix; "
f"expected ({n}, {m}) but found {M.shape}")
control.exception.ControlDimension: Incompatible dimensions of D matrix; expected (1, 4) but found (1, 5)
>>>
Activity
murrayrm commentedon Dec 20, 2025
Thanks for the post! I'll look into this, but if you can also post some code that generates the error, that would be helpful (and we can add it to the unit tests).
miroslavfikar commentedon Dec 20, 2025
This is my code with modified function.
bug.py
Replacing by the library version throws error:
murrayrm commentedon Dec 21, 2025
Thanks. Extracting the code that generates the error to have everything in one place: