Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the lqr.py file, replacing the inverse matrix operation with a least squares solution. #259

Merged
merged 6 commits into from
Jul 16, 2023

Conversation

rokeeeto-li
Copy link
Contributor

No description provided.

pypose/module/lqr.py Outdated Show resolved Hide resolved
pypose/module/lqr.py Outdated Show resolved Hide resolved
pypose/module/lqr.py Outdated Show resolved Hide resolved
pypose/module/lqr.py Outdated Show resolved Hide resolved
pypose/module/lqr.py Outdated Show resolved Hide resolved
Comment on lines 348 to 350
K[...,t,:,:] = Kt = -torch.linalg.lstsq(Quu, Qux).solution
k[...,t,:] = kt = -torch.linalg.lstsq(Quu, qu.unsqueeze(-1)).\
solution.squeeze(-1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

from torch.linalg import lstsq

then

K[...,t,:,:] = Kt = -lstsq(Quu, Qux).solution
k[...,t,:] = kt = -lstsq(Quu, qu.unsqueeze(-1)).solution.squeeze(-1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your advice. I've pushed the updated version.

@wang-chen wang-chen merged commit 2a0d20f into pypose:main Jul 16, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants