mit-biomimetics / Cheetah-Software

MIT License
2.62k stars 929 forks source link

Question on the feedfoward torque and contact detection #55

Open zeroAska opened 4 years ago

zeroAska commented 4 years ago

Hi, I'm looking forward to estimating the foot contacts of MiniCheetah. I'm thinking about if it is possible to use the feedback term of motor positions to detect a contact, as shown in

   // estimate torque
    datas[leg].tauEstimate =
        legTorque +
        commands[leg].kpJoint * (commands[leg].qDes - datas[leg].q) +
        commands[leg].kdJoint * (commands[leg].qdDes - datas[leg].qd);

in LegController::updateCommand.

My question is that, is the feedforward term, legTorque always zero? If not, how is it computed? Does it have different values when the foot is in the air and the food is touching the ground? The code related to legTorque is

    // tauFF
    Vec3<T> legTorque = commands[leg].tauFeedForward;

    // forceFF
    Vec3<T> footForce = commands[leg].forceFeedForward;

    // cartesian PD
    footForce +=
        commands[leg].kpCartesian * (commands[leg].pDes - datas[leg].p);
    footForce +=
        commands[leg].kdCartesian * (commands[leg].vDes - datas[leg].v);

    // Torque
    legTorque += datas[leg].J.transpose() * footForce;
HariP19 commented 4 years ago

is the feedforward term, legTorque always zero?

No. The legTorque contains the input joint torque for all the actuators of a given leg, so it cannot be zero.

If not, how is it computed?

The controller is responsible for generating the appropriate leg torques for a specified action. One simple example, you can checkout the FSM_Standup where the input torque is calculated based on desired foot position. Here, the desired foot positions is calculated based on the interpolation of pDes[2](Z-axis of foot). And based on the error between the current foot position and desired foot position the required footForce is calculated. Finally, a Jacobian transformation of footForce gives you the required joint torques of each actuator of a leg.

Does it have different values when the foot is in the air and the food is touching the ground?

As stated earlier, these are commands and it's values are determined by the controller. The foot being in air/ground doesn't directly affect it's value.