leggedrobotics / ocs2

Optimal Control for Switched Systems
https://leggedrobotics.github.io/ocs2
BSD 3-Clause "New" or "Revised" License
874 stars 225 forks source link

How to add constraint on delta u #94

Closed craipy-hub closed 7 months ago

craipy-hub commented 9 months ago

In the centroidal model, Contact force and joint velocity are used as input variable.In optimization, I want to limit the rate of contact force and joint velocity. How should I achieve this?

FenglongSong commented 7 months ago

You can change your problem formulation to put the joint velocities $v_j$ and contact forces $\lambda$ into state vectors and add additional equations in system dynamics to model the change rate of $v_j$ and $\lambda$:

$\dot{v_j}=uv, \dot{\lambda} = u{\lambda}$, where $uv$ and $u{\lambda}$ are used as the inputs to your (augmented) system, which captures the change rate.

It's also nice to have a look at Feedback MPC for Torque-Controlled Legged Robots by R. Grandia et al, which formulate a high-pass filter for the joint velocities and contact forces and penalize the high-frequency part in cost function. This approach degenerates to the former approach under some certain parameters choices.

craipy-hub commented 7 months ago

Thank you very much for your response. I have tried this, but encountered $\dot v_j$ new issue. When I use 'a' as the input, the hard constraint of the contact leg's foot having a velocity of zero turns into a soft constraint, which leads to suboptimal optimization results. Certainly, I will give another try to the second option you mentioned.

FenglongSong commented 7 months ago

Aha, good point. The reason should be that with the new formulation, the end-effector zero-velocity constraint becomes a pure-state equality constraint, which OCS2 doesn't provide good support yet. You can change it as $v{EE} + K a{EE} = 0$, which make it a state-input equality constraint again so that OCS2 can handle nicely through projection method ($K$ is a parameter to be tuned). Refer to (20) in this paper

craipy-hub commented 7 months ago

Yes, I am using the method $K*v{EE} + a{EE} = 0$, and it indeed provides some help.