Farama-Foundation / Gymnasium-Robotics

A collection of robotics simulation environments for reinforcement learning
https://robotics.farama.org/
MIT License
485 stars 79 forks source link

[Question] How to get the absolute position and velocities in the global coordinate system #173

Closed dchen48 closed 10 months ago

dchen48 commented 10 months ago

I am working on multi-agent reacher with 2 links. How can I get the absolute position and velocities in the global coordinate system? Thank you for the help.

Kallinteris-Andreas commented 10 months ago
env.single_agent_env.unwrapped.data.qpos
env.single_agent_env.unwrapped.data.qvel

You can check the doc pages of single agent gymnasium environments, https://gymnasium.farama.org/main/environments/mujoco/reacher/

dchen48 commented 10 months ago

Thanks a lot for the quick reply. It seems that env.single_agent_env.unwrapped.data.qpos returns an array of 4 elements. What does each of them represent?

Can you please help me verify:

  1. env.single_agent_env.unwrapped.data.body("fingertip").cvel[3:] return the absolute velocity of the fingertip in the global coordinate system.
  2. env.single_agent_env.unwrapped.data.body("fingertip")..xpos return the absolute position of the fingertip in the global coordinate system.

Your help is greatly appreciated.

Kallinteris-Andreas commented 10 months ago
  1. what do you mean by "velocity in the global coordinate system" do you mean "Cartesian velocity" if so you will need to use the second part of cvel (more on https://mujoco.readthedocs.io/en/latest/APIreference/APItypes.html?highlight=cvel#mjdata)
  2. yup looks good
dchen48 commented 10 months ago

Thanks for the help. Yes, I mean "Cartesian velocity", and now I understand how to get it.