legged_gym icon indicating copy to clipboard operation
legged_gym copied to clipboard

How to get the coordinates of the robot's toe end position?

Open wuyukun-tong opened this issue 2 years ago • 1 comments

Hi, How to get the coordinates of the robot's toe end position? Thanks!

wuyukun-tong avatar Dec 02 '22 03:12 wuyukun-tong

Hi, We can generate a list of feet indices:

for name in feet_name:
          idx = gym.find_asset_rigid_body_index(robot_asset, name)
          feet_index.append(idx) 

Then we can acquire rigid body states and wrap them for later use

_rb_states = gym.acquire_rigid_body_state_tensor(sim)
rb_states = gymtorch.wrap_tensor(_rb_states)
rigid_body_state = rb_states.view(num_envs,-1, 13) #[num_envs,num_bodies,13]

When we wish to get the required data:

gym.refresh_rigid_body_state_tensor(sim)
feet_vel = rigid_body_state[:,feet_index,7:10]
feet_pos = rigid_body_state[:,feet_index,0:3]

Note that the acquired data is with respect to the environment frame.

TextZip avatar Feb 14 '23 12:02 TextZip