Jacobian for Contact

Discussion in 'Simulation' started by Junhyeok, Aug 4, 2017.

  1. Hi,
    First of all, thank you for maintaining this forum and quick reply!

    I've read through documentation which is about constraint, contact.
    I realized contact constraint is calculated and added into efc_J in mjdata.
    If I would like to know Jacobian only for contact, which part do I need to take apart?
    In other words, in which part is the contact jacobian is saved in efc_J?

    Also, does it follow the notation efc_Jc : nq->[zdot, ydot, xdot] like in reaction force?

    Thank you.
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    Assuming you are using the dense elliptic solver, the Jacobian for contact i starts at

    mjtNum* Jc = d->efc_J + d->contact.efc_address * m->nv;


    This is a matrix with d->contact.dim rows and m->nv columns, in row-major format as all other matrices in MuJoCo. Multiplication by Jc maps from d->qvel to velocity in contact space. The first axis of the contact space is the normal (which you are calling zdot) and the others are the tangents. If dim>3 the contact is generating torques in addition to forces. In that case the translational components come first, followed by the rotational components.

    If you are using the dense pyramidal solver, the number of rows is 2*(dim-1) and the representation of contact space is over-complete. With the sparse solvers, the data is still in d->efc_J but the addressing scheme is different.

    So if you are going to use contact Jacobians (other than to do multiplication which is provided by MuJoCo), better stick to the dense elliptic solver to simplify your life.
     
  3. Thanks for the reply!
    Does dense elliptic solver mean by m->opt.jacobian = 0 and m->opt.cone = 0?
     
  4. Emo Todorov

    Emo Todorov Administrator Staff Member

    m->opt.jacobian = mjJAC_DENSE;

    m->opt.cone = mjCONE_ELLIPTIC;