cmower / optas

OpTaS: An optimization-based task specification library for trajectory optimization and model predictive control.
https://cmower.github.io/optas/
Other
107 stars 14 forks source link

Issue with OSQP interface #7

Closed cmower closed 1 year ago

cmower commented 2 years ago

Some solutions for a QP problem are perfectly fine using CasADiSovler with IPOPT, but the solutions using OSQPSolver are wrong.

cmower commented 2 years ago

I can't re-create what ever the problem was and OSQPSolver seems to produce expected solutions. Closing, but will reopen if the problem comes up again.

cmower commented 1 year ago

There seems to be an issue in the OSQP interface. See the example in optas_ros, here. When using OSQP, the controller does something quite weird.

cmower commented 1 year ago

The issue seems to be in the constraint specification, i.e. how constraints were passed from OpTaS to OSQP. OpTaS represents linear constraints as follows:

k = Mx + c >= 0
a = Ax + b == 0

whereas OSQP represents linear constraints using:

l <= Qx <= u

Note, in the OSQP documentation they use A instead of Q here - I change it here so it doesn't conflict with the A in the OpTaS constraint notation above.

The equivalence between these constraints is as follows:

    [  M  ]
Q = [  A  ]
    [ -A  ]

    [ -c  ]
l = [ -b  ]
    [  b  ]

u = infty

However, before the fix, the constraints were being passed as

 Q = [  M  ]
     [  A  ]

l = [ -c  ]
    [ -b  ]

u = infty

which is clearly incorrect. Only part of the equality constraints were specified.

I think we can now consider this issue resolved.