using mocaps for position tracking

Discussion in 'Simulation' started by Chris Richards, Feb 7, 2018.

  1. Hello,
    I'm trying to model a frog jump. I have verified my inverse model by comparing simulated versus experimentally estimated torques and ground reaction forces which match well enough for me. Now I'm trying to run the model forward given some manipulations that are not possible with real frogs. For example, I'm trying to "glue" the feet to the ground during takeoff (long story). I'm trying to do this using a connect constraint with mocaps fixed to the floor. It works for the left foot and not for the right. I'm testing it with a static pose without gravity. When I start the simulation, I expect both feet to smoothly meet the mocap markers which are placed just slightly away from the initial positions of the feet. When neither constraint is active, the model is static, of course. When the left is active, the left foot moves smoothly to meet the left mocap. However when the right is active, the right foot launches upwards and the sim goes unstable. I can't figure out what the problem is, can you please help?

    My code is attached (sorry for the complexity - I've tried to simplify it for the purposes of this post).

    Additionally, my qpos vector is {0,0,0,1,0,0,0,0.716293251,0.682313488,-0.146192622,0,0.876964771,-0.331004815,0.348379968,0,0.417639072,-0.861260062,0.289497343,0,0.300015247,0.852844447,0.427372439,0,0.438411775,-0.742221931,-0.506854734,0,0,0.676858473,-0.725506049,0.124513376,0,0.300015247,0.852844447,0.427372439,0,0.417639072,-0.861260062,0.289497343,0,0.876964771,-0.331004815,0.348379968,0}


    Thanks for your time,
    Chris
     

    Attached Files:

  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    The equality constraints are supposed to be satisfied in the initial model configuration. When you define constraints in your model, MuJoCo attempts to connect the mocap body to a point within the frame of the foot which is very far from the actual foot. This results in a weird simulation. The solution is to design the frog in a configuration where both feet are on the ground.
     
  3. Hi,
    Thank you for the reply. I'm sorry I overlooked the response and just noticed now.

    This explains what is going on, but I am still confused because I set qpos initially such that each foot is on the ground. However, you said "designing the frog in a configuration", what does that mean? Does the frog posture have to be set somehow in the XML as the null pose by setting the pose of each body? In my current model, the null pose (i.e. all qpos quats = [1, 0, 0, 0]) means all of the body segments are stacked vertically from the floor. Should I instead design the XML such that when all quats for qpos = [1, 0, 0, 0], the model instead has the correct "frog-like" posture as the "null" pose by explicitly defining the pose of each body? Or can I use my model as-is and simply set the initial pose prior to mjstep (or via the keyframes feature like below?).

    mju_copy(d->qpos, m->key_qpos, m->nq*keyframenumber);

    Sorry for all the questions.
    Best,
    Chris