lsw9021 / MASS

Apache License 2.0
574 stars 106 forks source link

Forward projection in PD control (GetSPDForces) #20

Open koonyook opened 4 years ago

koonyook commented 4 years ago

I'm comparing equation 10 in the paper and the function GetSPDForces in Character.cpp. I've found that p_diff is from a comparison between the p_desired and the linear estimation of q to the next time step (q + dqdt). I also assume that the term v_diff - dtmKv.cwiseProduct(ddq) is using a forward projection of dq to the next time step (*dq + ddqdt). This projection seems to cause some significant complication to the calculation of ddq**.

Main question: These forward projection of q and dq are uncommon in PD control. Is there any specific reason not to use just q and dq of the current time step without the projection?

Additional questions: Why *dtmKv.asDiagonal() is needed to calculate M_inv ? Why p_diff+v_diff is used in the calculation of ddq** ?

lsw9021 commented 4 years ago

Hi koonyook, please refer to the paper : https://www.cc.gatech.edu/~turk/my_papers/stable_pd.pdf

Quick answer:

Main reason why we use such kind of implementation is for the stability. Stable pd control enable us to simulate physics with large time step, reducing computational cost for the simulation. It is definitely possible to use other types of controller such as simple pd control, pid control, or some basic position-based control.

koonyook commented 4 years ago

Thank you for your prompt reply.

I've found that implementations in this repository are fundamentally different from the formulas in your SIGGRAPH paper and I'm not sure which one is the better version.

Should the loss_target compare "acceleration at joints" [q_dot_dot_d(u) vs q_dot_dot(a)] like being stated in the paper? or Should the loss_target compare internal force (generalized force generated by muscle) [tau_des vs Jt(Aa+p)] like being implemented in this repository? In the code, it is simply L=JtA and b=Jtp which is not the L and b defined by the paper.

This difference seems to link tightly to the origin of the target of SPD formulation. In the given SPD paper, equations 9 and 10, the SPD formulation is used to target the internal force (generalized force generated by muscle) in the Lagrangian dynamics. Instead, equation 10 in your SIGGRAPH paper seems to target the q_dot_dot (desired acceleration at joints) in the Lagrangian dynamics. Which one is the correct target?

The function GetSPDForces in this repository follows the SPD paper and produce mDesiredTorque which become tau_des later on. tau_des is then compared to Jt(Aa+p) which is just the internal force (and not q_dot_dot).