ocs2 icon indicating copy to clipboard operation
ocs2 copied to clipboard

Question on deriving some of the partial derivatives between ocs2 state and pinocchio state

Open zzhou387 opened this issue 3 years ago • 0 comments

Hi ocs2 team.

Thanks for open sourcing your repo. This is extremely helpful to the legged community! When reading the ocs2_centroidal_model, there are some parts that I cannot figure out by myself and hopefully can get some help from you guys. It's briefly discussed in #15 but more information will be helpful.

In CentroidalModelPinocchioMapping.cpp, to create a mapping between the ocs2 state and pinocchio state, we need to get all the partial derivatives, but I'm not quite how you determine some of them. If we write down the centroidal dynamics as: image

If we write the centroidal dynamics as an implicit function: image The differential is then: image

Then if I understand correctly, ocs2 state $x$ and control $u$, pinocchio position $q$ and velocity $v$ are defined as: image To goal is to find the following jacobians: image

By following the implicit differential theorem, some of the terms make sense, for example, if we wish to compute the partial $\frac{\partial{\dot{q}}_b}{\partial{q}_b}$, set $\text{d} {q}_b = {I}$, and all other differentials, except $\text{d} {\dot{q}}_b$, to ${0}$, and solve for $\text{d} {\dot{q}}_b$. The resulting expression is the desired analytical partial derivative. image similarly, image

However, if we try to derive this one $\frac{\partial {\dot{q}}_j}{\partial {\bar{h}}_G}$: image It is not clear what the analytical expression for $\frac{\partial {\dot{q}}_j}{\partial {\bar{h}}_G}$ is from the above equation. However, it's clear that $\frac{\partial {\dot{q}}_j}{\partial {\bar{h}}_G} \neq {0}$. Similarly, the entire bottom row block of $\frac{\partial {v}}{\partial {x}}$ shouldn't be ${0}$, but left as ${0}$ here

If we try another partial derivative, $\frac{\partial {q}_b}{\partial {q}_j}$: image

Or $\frac{\partial {q}_j}{\partial {q}_b}$: image Again, similar to $\frac{\partial {\dot{q}}_j}{\partial {\bar{h}}_G}$, it's not clear what the analytical expression should be for $\frac{\partial {q}_j}{\partial {q}_b}$ given the relation derived in above equation.

Is there anything I was missing in deriving these partial derivatives?

Thanks a lot in advance.

zzhou387 avatar Oct 01 '22 06:10 zzhou387