MyoHub / myoconverter

A tool to convert opensim 4.0+ MSK models into MuJoCo format with optimized muscle kinematics and kinetics
Apache License 2.0
67 stars 5 forks source link

Generic Amputation Model Creation Assistance #26

Closed YusseffRuiz closed 1 year ago

YusseffRuiz commented 1 year ago

Hello, I'm creating a new myosuite Model from the Open Sim GenericAmputation Model. I removed upper limbs muscles and kept with similar quantity of muscles than the lowerLimb existing model. However, I'm having issues getting the actuator on the transtibial prosthetic leg. The only thing i'm wondering is if there is any option to analyse if the created model was correct by appearing in a static stand up stance. Or if we need to code the muscles to be rigid.

Other question, is there any difference in the XML model for creating a elastic tendon or a rigid actuator? (motor like)

aikkala commented 1 year ago

Right now there is no other way to confirm the validity of a converted model, other than the reports generated during different parts of the conversion process. You can visually check whether the anatomy looks correct by opening the converted model in mujoco simulator, but the kinematics and dynamics are difficult to check.

Regarding the other question, having a muscle actuator defined to act on a tendon does make a difference, AFAIK, because the muscle generates passive forces when inactive.

YusseffRuiz commented 1 year ago

Thanks for the information. I managed to convert the Amputation model from OpenSim to Mujoco/MyoSim. However I'm having the following issues:

There are no errors in conversion, however I see that the initial simulation state, when attempting to run any environment with the Done flag, as comparing the height of the knees with the height of the ankles starts in ending state.

I found the problem, it is because the model starts:

  1. the body starts in the middle of the floor.
  2. The Fibula and tibia (bones of the lower leg) appear at the same place as the Femur.
  3. When I "Load the Key" it aligns with the initial position I described in the XML mujoco File, and looks perfectly fine, however, i believe that in myosuite, it doesn't load that initial position and starts with the bones of the leg at the same place everyone.

Do you know why could this be happening? or how to solve this problem?

I tried the same with the example model "gait2354" and it appears the same issue, so I believe you had to run into solving this previously.

I'm attaching the images as described in the 3 bullet points.

  1. Model when opening in mujoco Screenshot from 2023-11-17 15-23-11
  2. Model when moving pelvis_ty Screenshot from 2023-11-17 15-23-00
  3. Model after the "Load Key" screenshot

Just as a note, in Mujoco, it appears a warning: WARNING: Nan, Inf or huge value in QACC at DOF 0. The simulation is unstable. Time = 0.2000.

aikkala commented 1 year ago

The behaviour you describe (model being inside floor when loaded in simulator) is known and kind of intended. We convert the OpenSim models along with their default values for joints/degrees of freedom, which are then saved as a keyframe, and the intention is that you should always load the keyframe before running any simulations.

Whether there is an option to initialise a model to a keyframe in MyoSuite, that I don't know. Perhaps @Vittorio-Caggiano could help with this?

Vittorio-Caggiano commented 1 year ago

@YusseffRuiz you can set up a keyframe and use it to initialize the model in myosuite. We typically do it for locomotion (see here). If you want help to integrate your model in myosuite, you can contribute your model to myo_sim and we can help you to integrate it in myosuite.

YusseffRuiz commented 1 year ago

Thanks @Vittorio-Caggiano I will contribute over there. Thanks, I was unable to find the "load keyframe" function. I will write to you an email to understand how to contribute.

Regarding the model i will test it and close this issue, thanks!

YusseffRuiz commented 1 year ago

setting up a keyframe did not work on myosuite locomotion environment. Proceeding with the issue in the myo_sim repository as a contributor.