How to calculate inverse dynamics in Mujoco #2600
-
IntroHi! I am a undergrad student at HeFei university of technology, I use MuJoCo for my research on robot inverse dynamics. My setupMujoco 3.3.0 python Ubuntu20.04 My questionHello everyone, I’m using MuJoCo to solve the inverse dynamics of a robot. I input a trajectory to the robot and output the joint torques. I used three methods to compute the torques: data.actuator_force and data.qfrc_inverse.copy() give the same result, but the manually calculated dense_M @ data.qacc + data.qfrc_bias shows significant differences from the first two. According to the inverse dynamics formula, it should be: Minimal model and/or code that explain my questionimport time def scroll_callback(window, xoffset, yoffset): global cam joint_q = loaded_data["joint_q"] model = mujoco.MjModel.from_xml_path('/home/madoka/software/mujoco/mujoco-3.3.0/mujoco_menagerie-main/universal_robots_ur10e/scene.xml') mujoco.mj_resetData(model, data)data.qpos[:6] = joint_q[0,:] print("All bodies in the model:") if not glfw.init(): window = glfw.create_window(1200, 900, 'UR10 Arm Control', None, None) fixed_timestep = model.opt.timestep end_effector_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_BODY, 'wrist_3_link') cam = mujoco.MjvCamera() mujoco_q = np.zeros((joint_q.shape[0],6)) for i in range(model.njnt): while not glfw.window_should_close(window) and current_time-start_time < 10:
glfw.terminate() Confirmations
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, I am a MuJoCo user. I hope this helps you.
I have written a program while cutting down a lot of clutter. You can update your code based on the following:
No collisions are happening/external forces are applied to the robot in this code; you can include the corresponding terms to further expand the verification, e.g., see this. |
Beta Was this translation helpful? Give feedback.
Hi, I am a MuJoCo user. I hope this helps you.
I have written a program while cutting down a lot of clutter. You can update your code based on the following:
The LHS and RHS of the equation of motion are evaluated at an instance. The LHS and RHS are in reference to this equation.