Hey all,
I am trying to port the uuv_gazebo_plugins from Gazebo to Isaac. These plugins allow to simulate ROVs, and USVs in Gazebo, and I’d like to do the same in Isaac. I ported all the code from c++ to python, and I need to write some function to do the following:
- Apply Forces
- Apply Torques
To apply forces there are at least two methods:
- Using dynamic_control_ one can use apply_body_force. The issue with this method is that it only applies a force at the center of the object, and I could not figure out how to apply the force at specific position relative to that object.
- The other method is
apply_force_at_pos
from the Physx python bindings. This one works as expected.
Then to apply torques I could not find any methods to do it. I think IsaacGym has ones, I know Physx has an apply torque function, and actually quite a lot more of apply force functions.
Are there any methods to apply torques available in Isaac? If I have to use my own it’s a lot of calculations…
def AddRelativeTorque(PhysXIFace, prim_path, torque, dist=100):
torque_norm = np.linalg.norm(torque)
torque_normalized = torque/torque_norm
# Projects torque to world frame
transform = PhysXIFace.get_rigidbody_transformation(prim_path)
R = Quaternion2RotationMatrix(transform['quaternion'])
torque_normalized = np.matmul(R,torque_normalized)
# Make virtual vector
idx = np.argmin(torque)
v = np.zeros([3])
v[idx] = 1.0
# Get two orthogonal vectors to the torque vector
w = np.cross(torque_normalized, v)
w21 = np.cross(torque_normalized, w)
w22 = -w21
f1_dir = np.cross(torque_normalized,w21)
f2_dir = -np.cross(torque_normalized,w22)
p1 = w21 * dist
p2 = w22 * dist
# Apply forces at the position of the object
PhysXIFace.apply_force_at_pos(prim_path,f1_dir*torque_norm/2,p1 + np.array(transform['position']))
PhysXIFace.apply_force_at_pos(prim_path,f2_dir*torque_norm/2,p2 + np.array(transform['position']))
Thanks in advance,
Best,
Antoine