Closed lrchit closed 1 month ago
Hi,
I've worked on something similar about 2 years ago. Since you are using $x = [q, \nu]$ as states, the zero end-effector velocity constraint $v_{EE}=0$ is a pure-state equality constraint. OCS2 cannot handle pure-state equality constraint in its SQP solver (in DDP solver I don't know), at least this was the case 2 years ago. You can check again if there is any update (although I doubt it).
Therefore, if you want to do whole-body NMPC using OCS2, you can formulate acceleration-level end-effector constraints (check this paper: https://arxiv.org/pdf/2203.07429). This is a state-input equality constraint and OCS2 can handle it pretty well.
You should not use penalty methods to deal with equality constraints, which is pretty bad numerically :(
Another small tip: by my experience the gradient computation takes more than 50% of the computation time in each SQP iteration. You can consider using analytic derivative in Pinocchio, which is faster.
Hope this will be helpful!
Best, Fenglong
Hi,
I've worked on something similar about 2 years ago. Since you are using x=[q,ν] as states, the zero end-effector velocity constraint vEE=0 is a pure-state equality constraint. OCS2 cannot handle pure-state equality constraint in its SQP solver (in DDP solver I don't know), at least this was the case 2 years ago. You can check again if there is any update (although I doubt it).
Therefore, if you want to do whole-body NMPC using OCS2, you can formulate acceleration-level end-effector constraints (check this paper: https://arxiv.org/pdf/2203.07429). This is a state-input equality constraint and OCS2 can handle it pretty well.
You should not use penalty methods to deal with equality constraints, which is pretty bad numerically :(
Another small tip: by my experience the gradient computation takes more than 50% of the computation time in each SQP iteration. You can consider using analytic derivative in Pinocchio, which is faster.
Hope this will be helpful!
Best, Fenglong
Hi,
Thanks for your reply, it helps a lot. I will go and learn about the things you mentioned!
Best, Ruochen
Hi, I'm trying to do mpc on quadruped with full body model, where the states are generalized coordinate q and v, and the inputs are ground reaction force and joint torque. I use your cppad interface to make full body dynamics and constraints, and find something weird. The "zero velocity constraint" of supporting feet is always violated (they slide) whatever the robot is standing and troting, and sometimes it crash directly: Screencast with the constraint observer:
My constraint is defined as below: ZeroVelocityConstraintCppAd.h:
ZeroVelocityConstraintCppAd.cpp:
And my dynamics is that:
The source code that could run is here: https://github.com/lrchit/ocs2_whole_body_mpc.git. And I changed
fun.optimize();
in your CppAdInterface.cpp tofun.optimize("no_compare_op");
so that the codegen of dynamics is allowed. Can anyone tell me what's wrong with it and how to fix this problem? I've also tried penalty, barrier function and augment Lagrangian, but the results are almost the same. Is there some extra things needed to do to deal with state constraint?