leggedrobotics / legged_gym

Isaac Gym Environments for Legged Robots
Other
1.23k stars 354 forks source link

[Question] How to obtain the position of AnyMal #38

Closed dibbla closed 1 year ago

dibbla commented 1 year ago

Hi!

I've been using this environment and I want to get the position/location of the AnyMal as the ground truth.

I checked #31 and used: _rb_states = gym.acquire_rigid_body_state_tensor(sim) to get all the information of the current scene. However, I can hardly get the name of each rigid body (and the return also contains the information of obstacles) so I don't know how to locate my robot.

Do you have any idea? Thanks!

E-Mans-Application commented 1 year ago

Hi,

have you tried 'self.root_states'?

The names of the rigid bodies are in "body_names" (legged_robot.py line 649)

dibbla commented 1 year ago

Hi,

have you tried 'self.root_states'?

The names of the rigid bodies are in "body_names" (legged_robot.py line 649)

Hi @E-Mans-Application

Thank you! I haven't tried it and I'll take a look.

dibbla commented 1 year ago

Hi,

have you tried 'self.root_states'?

The names of the rigid bodies are in "body_names" (legged_robot.py line 649)

Hi @E-Mans-Application

Thanks!

It works. However, I found something wierd. If I use self.gym.acquire_rigid_body_state_tensor(self.sim) to acquire rigid bodies' states, it returned a tensor with shape [60, 13], but if I use self.root_states, it will return a [12, 13] tensor. Some of the return values are overlapped, but the latter one obviously provide much more things. In addtion, self.body_names actually returns a 17-length list. There is a mutual mismatch (all in AnyMal environment with 2 walls and 1 pillar as obstacles). Do you have any idea about how to align the names and these states?

E-Mans-Application commented 1 year ago

Hi,

The body state tensor has shape [num_envs * num_bodies, 13]. The overlapping is expected, because the tensor contains the state of all the 17 body parts, including the root.

You have to turn the tensor into shape [num_envs, num_bodies, 13] (look at how "self.dof_pos" or "self.dof_vel" are defined).

However, if you have 12 robots and 17 bodies per robot, your body state tensor should have shape [204, 13], not [60, 13]. Maybe this comes from your using walls and pillars. I've never used them, but I guess they have their own rigid bodies, mixed with those of the robots.