google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
7.77k stars 771 forks source link

Question about inverse kinematics in Mocaps in Mujoco #1811

Closed Yingfan99327 closed 3 days ago

Yingfan99327 commented 1 month ago

Hi,

I'm a student and I'm trying to use MuJoCo for robot simulation

I'm looking for help with inverse kinematics in mujoco.

After reading some relevant issues and blogs about how mujoco handles inverse kinematics in mujoco, I have several questions as follows,

1) I read some projects on using Mocap body to solve the inverse kinematics problem. For instance, if you define a panda robot as a mocap body ("you could also weld end effectors to mocap bodies, or use other equality constraints to implicitly define the kinematic chain with relation to a reference") and using the APIs provided with mocap such as set_mocap_pos, you can let the agent follow the desired posture. So, does it mean that some inverse kinematics algorithms (I guess maybe some numerical algorithms) have been implemented inside these mocap functions?

2) Based on my first question, could the policy learned with mocap-based Cartesian motion be generalized to the real-world robot that should solve IK, namely, whether it could match the robot I use in real experiment? For example, if I'd like to realize a joint-space admittance controller or impedance controller of a 7-dof panda robot in mujoco, I need to solve the inverse kinematics of the robot arm and then input the solved qpos into the controllers, so can I use the joint position results calculated by using Mocap function as the input to the controller and then solve the joint torque or it's better that I build the KDL chain of the robot and implemented the inverse kinematics algorithms on my own to calculate the joint positions, which path is better?

3) Because "set_mocap_pos" function seems the API to help me do "inverse kinematics" in mujoco, does it mean that if I use mocap-based method, the actuator type I defined for my robot in xml file must be "position-type" actuator? If I hope to drive the robot directly with joint torque, namely, I define the robot with "motor"-type actuator, does it mean that in this case I cannot use Mocap-based method and I need to write my own inverse kinematics and thereafter to calculate the joint torque to control my motor-type robot in simulation?

4) For the actuator type, would it be possible to define both position-type and motor-type actuators for a robot, namely, the robot could both receive joint pos commands or joint torque commands in simulation? I just need to choose what kind of control signals I use in data.ctrl.

Sorry for my so many "rookie" questions about mujoco and really appreciate that if you could answer them. Thanks very much for your time and help.

Wishing you all the best.

yuvaltassa commented 1 month ago

@kevinzakka did a bunch of work on this and might be best positioned to reply