question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Return type of eigenvalues from lqr and lqe not consistent

See original GitHub issue

This came up while pytestifying statefbk_test.py (#438)

lqr() will always return E as (nstates, ) array https://github.com/python-control/python-control/blob/d3142ff24c7af5e2c0843fd16d0e1be82b322bb9/control/statefbk.py#L444-L446

lqe() returns _ssmatrix(E) which is a (nstates, ) array or (1, nstates) matrix depending on config.defaults.use_numpy_matrix() https://github.com/python-control/python-control/blob/d3142ff24c7af5e2c0843fd16d0e1be82b322bb9/control/statefbk.py#L290

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
murrayrmcommented, Dec 24, 2020

I’d like to clean this up before 0.8.4 release, but there are a few issues that could break users’ code:

  • lqr returns _ssmatrix(K), _ssmatrix(S), E, for which the first return value is the gain matrix (2D array or matrix, depending on config settings), the second return value is the solution to the Riccati equation (2D array or matrix), and the third value is a 1D array (list of closed loop eigenvalues).
  • lqe returns _ssmatrix(K), _ssmatrix(S), _ssmatrix(E), which forces the third argument to be a 2D array.
  • care and dare return _ssmatrix(X), w[:n], _ssmatrix(G), for which the first return value is the solution to the Riccati equation (2D array or matrix), the second return value is a list of eigenvalues (1D array), and the third argument is the gain matrix (2D array or matrix).

I think we should make the following change in 0.8.4:

  • Change return values for lqe to match lqr

This will require an updated unit test (as noted above) and could break some users’ code. But the fix to user code is simple (convert to 2D array) and so I think it is OK for 0.8.4.

I think we might want to consider whether to make changes to care and dare in 0.9.0:

  • We can leave things the same with the argument that care and dare are returning solutions to the Riccati equation as their primary usage => that solution should be first. The lqr and lqe functions call care or dare, but are returning controllers as their primary usage => OK for the order to be different.

  • We can change the order of the return values for care and dare to match lqr and lqe.

My current feeling is that we leave care and dare alone. Thoughts?

0reactions
murrayrmcommented, Dec 26, 2020

Fixed in #477.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inverted Pendulum: State-Space Methods for Controller Design
Another option is to use the lqr command which returns the optimal controller gain assuming a linear plant, quadratic cost function, and reference...
Read more >
Lecture 4 Continuous time linear quadratic regulator
Pss can be found by (numerically) integrating the Riccati differential equation, or by direct methods. • for t not close to horizon T,...
Read more >
Suboptimal LQR-based spacecraft full motion control
This work introduces a real time suboptimal control algorithm for six-degree-of-freedom spacecraft maneuvering based on a ...
Read more >
LINEAR QUADRATIC GAUSSIAN - Dr. Gregory L. Plett
1. Rewrite cost and system in terms of the estimator states and dynamics ➠ Can access these. 2. Design a stochastic LQR.
Read more >
Linear-Quadratic Regulator (LQR) design - MATLAB lqr
Find the gain matrix K using lqr . Since N is not specified, lqr sets N to 0. [K,S,P] = ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found