How to simulate planar grasping

Discussion in 'Simulation' started by yongxf, Nov 29, 2016.

  1. Hi there,

    I try to simulate a grasping of planar object using pretty simple two finger hand (4DOF total).
    I want the hand to overcome the gravity uncertainty of the object.

    My current thought is to constrain the motion of the object on a vertical plane. And all hinge joints of the hand are perpendicular to this plane. In this way, the hand could only give force along this plane, and the object motion is also along this plane.

    However, I am not sure how to setup the object joint to constrain the object motion, I didn't see any joint can constrain object motion to a plane. The "slide" joint gives a 1D translation dof only.

    Is there any way to realize this plane constraint? Or is there any smarter way to mimic planar grasping?



    Thanks!
    Best regards,
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    MuJoCo's primitive joint types can be composed in order to construct more elaborate joints. Unlike other simulators, this does not require creating dummy bodies; instead you simply define multiple joints within the same body.

    To model a body that can slide and rotate within a 2D plane, you need to define three joints within that body: two slides with orthogonal axes within the plane, and one hinge with axis normal to the plane.
     
  3. Thanks, it works beautifully.

    Best regards,
     
  4. By the way, I need to use Inertia matrix of the fingers to do computation. The hand and the object is shown in figure:
    [​IMG]

    I use the following code to get the inertia matrix of the hand:

    Code:
    mjtNum* dense_M = mj_stackAlloc(d, m->nv*m->nv);
        mjtNum* M_hand = mj_stackAlloc(d, (m->nv - 3)*(m->nv - 3));
        mj_fullM(m, dense_M, d->qM);
        cout << "dense M" << endl;
        mju_printMat(dense_M, m->nv, m->nv);
        extract_submatrix(M_hand, dense_M, 0, m->nv - 4, 0, m->nv - 4, m->nv, m->nv); //checked correct, get hand inertia
        cout << "Inertia of the hand:" << endl;
        mju_printMat(M_hand, 4, 4);

    The dense M is shown by the following matrix.

    0.00049321 0.00002304 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
    0.00002304 0.00041791 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
    0.00000000 0.00000000 0.00049321 0.00002304 0.00000000 0.00000000 0.00000000
    0.00000000 0.00000000 0.00002304 0.00041791 0.00000000 0.00000000 0.00000000
    0.00000000 0.00000000 0.00000000 0.00000000 0.43944000 0.00000000 -0.03073280
    0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.43944000 -0.00000004
    0.00000000 0.00000000 0.00000000 0.00000000 -0.03073280 -0.00000004 0.00338313


    I think the first two row/col of dense M is the finger inertia. My question is: where is the origin of the inertia computation? Does Mujoco know the kinematic relation of two links when computing Inertia?
    I compute the finger inertia by setting origin on the first joint of the finger. The result is quite different with above.

    Similarly, I can calculate the object inertia, when I compare with above, it also gives me a different value.

    When I change the hinge position on the object, the dense_M would also change, especially, the object inertia matrix would becomes diagonal if hinge joint is placed at the COM of the object at the beginning of the simulation, but still they have a huge gap (my computation result is always smaller than dense_M).




    Thanks a lot!
    Best regards,
     
    Last edited: Nov 30, 2016
  5. Emo Todorov

    Emo Todorov Administrator Staff Member

    The inertia matrix is a fairly abstract entity. It can be thought of as the metric over the configuration manifold (used to define dot-products between velocity vectors) or as the linear mapping from acceleration to force when velocity=0. Which element of M means what depends on the model.

    Each body has an inertial frame, which by default coincides with the body frame for free bodies. So if you have a simulation with multiple free bodies assuming no joints connecting them, M would have 6-by-6 blocks on the diagonal containing the body inertias expressed in global coordinates. Once you start adding joints however (other than free joints) things get more complicated.