'gym.get_actor_dof_states' returns the same tuple regardless of flags

Hi,

I have been playing around with the simulator and found that the function gym.get_actor_dof_states(Env, Actor, Flag) returns the same tuple even if you only want a single value (either position or velocity).
According to the documentation you can specify a flag to retrieve only the position, velocity, or both.

param3 (int) – flags for the state to obtain, can be velocities ([isaacgym.gymapi.STATE_VEL]), positions([isaacgym.gymapi.STATE_POS]) or both ([isaacgym.gymapi.STATE_ALL])

Code to reproduce the behaviour in example/kuka_bin.py:

kuka_joint_list = ['iiwa7_joint_1', 'iiwa7_joint_2', 'iiwa7_joint_3', 'iiwa7_joint_4', 'iiwa7_joint_5', 'iiwa7_joint_6', 'iiwa7_joint_7']
dof_states = gym.get_actor_dof_states(envs[i], kuka_handles[i], gymapi.STATE_POS)
vel_states = gym.get_actor_dof_states(envs[i], kuka_handles[i], gymapi.STATE_VEL)
all_states = gym.get_actor_dof_states(envs[i], kuka_handles[i], gymapi.STATE_ALL)
for j in range(len(kuka_joint_list)):
    print(f'{kuka_joint_list[j]} position: {dof_states[j]}, velocity: {vel_states[j]}, all: {all_states[j]}')
print('================')

It is not a big problem, but just wanted to report and hear if this is a known issue.

Kind regards,
Lars

Hi Lars,

Passing in the Flag parameter to gym.get_actor_dof_states specifies which state (i.e. position, velocity, or both) should be updated in gym’s internal DOF state buffer. If isaacgym.gymapi.STATE_POS is passed in, only the position data will be updated, similarly with isaacgym.gymapi.STATE_VEL. However, the state buffer’s dimension will not change with different flags, but some data in the buffer may be stale depending on the flag passed in.

In the code snippet you provided, the final result that gets printed is actually after the STATE_ALL update has completed, which is why you would see the same results from each call. You can try verifying this by calling dof_states = gym.get_actor_dof_states(envs[i], kuka_handles[i], gymapi.STATE_POS).copy(), then all_states = gym.get_actor_dof_states(envs[i], kuka_handles[i], gymapi.STATE_ALL), or first calling vel_states = gym.get_actor_dof_states(envs[i], kuka_handles[i], gymapi.STATE_VEL).copy(), then all_states = gym.get_actor_dof_states(envs[i], kuka_handles[i], gymapi.STATE_ALL) to verify the results.

Thanks,
Kelly

1 Like

Hi Kelly

gym.get_actor_dof_states specifies which state (i.e. position, velocity, or both) should be updated in gym’s internal DOF state buffer

That makes perfect sense, I think the wording “flags for the state to obtain” in the documentation confused me on what the function actually does. The explanation here makes it more understandable, thanks.