Confused by objtype and objid in mj_objectVelocity

Discussion in 'Simulation' started by Yang Ding, Feb 21, 2020.

  1. Edit: I realize that the local coordinates have z-axis along the axis of the cylinder. So everything makes sences now.


    I am trying to add some passive body forces but got stuck with mj_objectVelocity. Has anyone used this function?
    It is defined like this:
    void mj_objectVelocity(const mjModel* m,const mjData* d,int objtype,int objid, mjtNum* res,int flg_local);

    What confuses me is that objtype,objid are only mentioned in struct _mjvGeom. I tried something like following for the sample case (mjmodel.xml )

    mjtNum bvel[6];
    for( int i=0; i<m->nbody; i++ )
    {
    mj_objectVelocity(m,d, mjOBJ_GEOM, i,bvel, 1);

    }
    The velocities for the hello.xml look right but I got velocities wrong for the three-link swimmer case (mjmodel.xml). It looks the first component (supposed to be rotation in x from the hello.xml experiment) is not zero.

    0, 0, 0, 0, 0
    -0.04311, 0, 2.51665e-19, 1.85247e-19, 0.0737903, -0.0328749
    -0.0431113, 0, 0, -5.98552e-19, 0.00173612, 0.0571557
    -0.10259, 0, 7.11859e-19, -1.62824e-19, 0.00369297, 0.0252176
     
    Last edited: Feb 22, 2020