Hi there,
I would like to use apply_forces_and_torques_at_pos to control an RL agent.
However, I am getting unexpected behavior out of the API.
Say I have a RigidBodyPrimView and I want to apply N forces at different positions. In this case, I tried to apply 8 forces. Also, for the sake of this example, I disabled gravity to figure out what was happening.
In this experiment, I apply forces as shown below:
print("forces", A[0:8])
print("Positions", O[0:8])
print("Indices", I[0:8])
self._platforms.base.apply_forces_and_torques_at_pos(forces=A, positions=O, indices=I, is_global=False)
The values inside the tensors are the following:
forces tensor([[ 0.7071, 0.7071, 0.0000],
[-0.7071, -0.7071, 0.0000],
[ 0.0000, 0.0000, 0.0000],
[ 0.0000, 0.0000, 0.0000],
[ 0.0000, 0.0000, 0.0000],
[ 0.0000, 0.0000, 0.0000],
[ 0.0000, 0.0000, 0.0000],
[ 0.0000, 0.0000, 0.0000]], device='cuda:0')
Positions tensor([[ 0.3536, 0.3536, 0.0000],
[ 0.3536, 0.3536, 0.0000],
[-0.3536, 0.3536, 0.0000],
[-0.3536, 0.3536, 0.0000],
[-0.3536, -0.3536, 0.0000],
[-0.3536, -0.3536, 0.0000],
[ 0.3536, -0.3536, 0.0000],
[ 0.3536, -0.3536, 0.0000]], device='cuda:0')
Indices tensor([0, 0, 0, 0, 0, 0, 0, 0], device='cuda:0')
From what I understand, this should result in the object not moving at all, the forces are canceling each other’s and are applied at the same position. Yet, the objects are moving.
After some debugging, it seems that providing multiple times the same index leads to some issues where indexes are getting mixed-up.
On the other hand, when applying actions as shown below, only the last action is being applied.
A = A.reshape(self._num_envs, self._num_actions, 3)
I = I.reshape(self._num_envs, self._num_actions)
O = O.reshape(self._num_envs, self._num_actions, 3)
for i in range(self._num_actions):
self._platforms.base.apply_forces_and_torques_at_pos(forces=A[:,i], positions=O[:,i], indices=I[:,i], is_global=False)
Is there any way to solve this problem? I can create N fixed rigid bodies at the root of the object, which I assume would result in the correct behavior, it just seems wrong.
Thanks in advance,
Cheers,
Antoine