Closed mpowelson closed 4 years ago
Hi @mpowelson. Thanks a lot for the PR! Out of sheer curiosity, how did you manage to find this? Do you have some piece of code that is failing without this change?
We are using osqp-eigen in trajopt_ros and our matrices are row major. I don't remember the symptoms, but something was going wrong and when I debugged it, I saw the matrix was the wrong size.
Thanks for the explanation! I tried to investigate a little more the issue. Actually, when developing we mainly focused on "Compressed Sparse-Column" (CSC) as this is what osqp
is expecting (https://github.com/oxfordcontrol/osqp/blob/master/include/types.h#L21-L29l). I guess that by passing a "Compressed Sparse-Row" (CSR) the net effect is that the matrix may result transposed.
On the Eigen side, it is possible to pass from CSR to CSC with a simple assignment. Probably it is safer to save the input matrix into a CSC to avoid this kind of problem. I tried to implement this in https://github.com/robotology/osqp-eigen/pull/57. @mpowelson can you try to check that out to see if it solves your problem?
Yes, it seems like that solves it. I'll close this.
Changes createOsqpSparseMatrix to iterate to eigenSparseMatrix.outerSize() instead of cols().