mj_jac function

Discussion in 'Simulation' started by Junhyeok, Jul 14, 2017.

  1. Hello,
    I am playing with the example code which is simulate.cpp.
    After I mj_step, I would like to get jacobian of body with mj_jacBody(m, d, jacp, jacr, 1), and it returns

    Bus error: 10

    code looks like in simulate.cpp in main function.
    render(window);
    mjtNum * jacp;
    mjtNum * jacr;
    mj_jacBody(m, d, jacp, jacr, 1);
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    Did you allocate jacp and jacr? They must point to user-supplied memory buffers of size 3*nv*sizeof(mjtNum).
     
  3. Thanks for the reply!
    I should have allocate first.
    I am also comparing the CoM velocity of each links by printing out data->cvel and J_com*qdot and I found little difference between them.
    I get j_com from mj_jacBodyCom.
    Is it supposed to be?
     
  4. Emo Todorov

    Emo Todorov Administrator Staff Member

    cvel is a 6D spatial velocity vector that has somewhat unusual meaning; read Featherstone's notes on spatial algebra if you are interested. J_com*qvel is what you need.