Joint pos, vel, acc difference when applying muscle force in two different ways #2311
Unanswered
Yingfan99327
asked this question in
Asking for Help
Replies: 1 comment 4 replies
-
I think you are using the lengths and velocities from the previous timestep. You need to understand the difference between the |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Intro
Hi!
I am a graduate student working on human robot interactions, I use MuJoCo for my research.
My setup
I used mujoco, especially the muscle tendon model supported in mujoco for my research and I found some problems I am not clear about. So, I ask for help from the community.
My question
Generally speaking, the problem I encounted in my experiment is that the joint pos, velocity, acceleration results are different when I applying muscle actuation force in different ways.
What I aim to do is that I want to bypass the way of calculating muscle force in mujoco and implement the way of calculating muscle actuation force with my own implementation. For the first step, I checked Mujoco's way of calculating muscle force in the document as well as in the source code of engine_forward.c. Then, I reproduced the Mujoco's way of calculating muscle force in Python and I used this as the ctrl signal by adjusting the actuator from tendon to motor in the model file.
The model file I pasted below is the reference model file consisting of a single muscle and a single joint with the actuator defined as shown below.
For the reference model, I used the way of calculating muscle actuation force in mujoco by defining the ctrl singal as the muscle excitation signal and write a simple for-loop as below:
So, I use the reference model to collect the actuator_length, actuator_velocity, act_dot, act, actuator_force, qfrc_actuator, qpos, qvel, qacc data to check whether my own implementation of caculating muscle force is correct or not.
Then, I implemented the way of calculating muscle force with Python. And I modified the model file in only one place which is that I changed the actuator as
For the data of gainprm, biasprm, lengthrange of this muscle, I extracted them and fed them for calculation in the codes. So, with this model, the ctrl signal will be the actuation_force calculated with my Python implementation and the for loop is shown as below,
Then, I record the actuator_force, qfrc_actuator, qpos, qvel, qacc data and compared them with the data collected from the reference model to check my Python codes of calculating the muscle force is the same as that in mujoco. So, this is basic the experiment set-up.
First, I am sure that the implementation of Func_calc_muscle_force is correct, I compared the some intermediate results by calling the mju_muscleGain and mju_muscleBias function to reduce the artifact error and I am pretty sure that my implementation is correct. But, what I found is that, for the first two loops, namely, ctrl=0.0, ctrl=0.1, the results matched, while after the third loop, the results have slight difference that
First, I checked the actuation force, qfrc_actuator etc, they match. The qpos, qvel, qacc after the second loop, they also match, which means that the caculation is correct after the first two loops. Things went wrong in the third loop and the weird thing is that, you can see, the qacc is the same, while the qvel and qpos are different. The integrator I used in both model files is "implicitfast" which is recommended in the document for muscle-tendon.
And it could be easily observed that, if I used the actuation force calculated on my own as the data.ctrl, the qvel and qpos is integrated in the "Euler" way, I checked with calculator by hand. And it could be observed that the way of calculating qpos, qvel are different if I used the way of actutating a tendon built in mujoco.
Then, I compared the results if I used different integrators in the two model files with Euler, implicit, implicitfast, RK4, and I found that
So, based on the experiment set-up and experiment results as I show above, I guess there would be something wrong with my way of using the actuation force to actuate a tendon and then move the joint because it seems the "implicitfast" integrators didn't work and it just did the integration in "Euler" way.
I don't know what I missed when I implemented the model and I hope to get some feedback from you about the problems I met and whether it is correct to calculate the muslce force in the way I described. I also hope to get some advice on what I need to pay attention to if I hope to get the same results as those calculated with the internal muscle dynamics function in mujoco.
I really like and enjoying using mujoco and I am very happy each time I know more and deeped about it.
Really appreciate your help and wishing you all the best.
Minimal model and/or code that explain my question
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions