Does d->cfrc_ext give [torque; force] or opposite?

Discussion in 'Simulation' started by yongxf, Aug 28, 2016.

  1. I want to lift a box using a four finger hand. During simulation, I try to calculate the net force on the object by grasp map. Also, to verify my calculation, I output the net force directly from simulation by:

    Code:
    F_act_detected = d->cfrc_ext + object_id * 6;
    mju_printMat(F_act_detected, 6, 1);
    Force computed from my calculation is:
    Code:
    0.06799811
    -0.08003456
    5.08306248 (lifting task mainly uses force in z direction)
    0.00772085
    0.02087569
    0.00000096
    Force output directly from simulation is:
    Code:
    0.00767248
    0.02091389
    0.00007935
    0.06282921
    -0.08281304
    5.08320069 (it's strange that the corresponding force is on the 6th element)
    It can be seen that roughly they are the same, except the order: seems d->cfrc_ext gives torque first, then force. Is that true?

    Also, another question is about d->cvel. I notice it contains [3D rot; 3D tran]. What's the specific meaning of "3D rot"? Does it mean the angular velocity? or Euler angle rate?

    Code:
    mjtNum*   cvel;                 // com-based velocity [3D rot; 3D tran]     (nbody x 6)
    Thanks and have a wonderful day!
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    Yes, this is a potentially confusing aspect of the design. The 6D spatial vectors that start with "c" have their rotational component first, followed by the translational component. This is based on Featherstone's notes on spatial algebra; ideally I would rewrite all the formulas to change the order. Maybe some day. In the meantime, you need to change the order manually.

    Keep in mind also that the "c" vectors are subtree-com-based. If you want them with respect to a coordinate frame centered at the body (or world - your choice), use the functions mj_objectVelocity and mj_objectAcceleration. These functions perform the necessary coordinate transformation and also change the order so that translation comes first.

    In cvel, the rotational velocity is a 3D vector whose length is the speed of rotation in rad/s, and whose direction is the axis of rotation.
     
  3. Emo Todorov

    Emo Todorov Administrator Staff Member

    The complete Programming Guide for MuJoCo was just posted on the website. See the section on Coordinate Frames, it has extra information about this.
     
  4. Thanks for your reply and excellent documentation! Now I am be able to understand more about it.

    Best regards