Surface gripper support for gpu

Hi,

I wonder whether the surface gripper supports the GPU now. I want to run the surface gripper for several environments for reinforcement learning. I get the error of "gripper didn’t close successfully”.

Thank you.

Hello!
I encountered the same issue you mentioned here. I posted it earlier, and the response from the moderator was, ‘Yes, you can implement the surface gripper on GPU.’ However, as I was unable to accomplish that, I utilized the PhysX API and implemented the same functionality as shown below.

1 Like

Thank you so much for your information! I have another question. Do you know how to remove the fix joint between the suction and objects when I want to “release” the objects? Thank you.

I think you can do this by rewriting the name in <> and the relative position of the gripper to the specific object in the code below.

def add_anchor(self, object_name):
    self._stage = get_current_stage()
    object_prim_path = f"/World/envs/env_0/{object_name}/{object_name}"
    fixed_joint_path = f"/World/envs/env_0/<robot>/<hand_link>/fixed_joint"

    # fix the object to hand
    anchor_pos = Gf.Vec3d([0.0, 0.0, 0.06])
    self.fix_to_hand(self._stage, fixed_joint_path, object_prim_path, anchor_pos, object_name, '<hand_link>')

def fix_to_hand(self, stage, joint_path, prim_path, anchor_pos, object_name, hand_name):
    # D6 fixed joint
    FixedJoint = UsdPhysics.FixedJoint.Define(stage, joint_path)
    FixedJoint.CreateBody0Rel().SetTargets([f"/World/envs/env_0/<robot>/{hand_name}"])
    FixedJoint.CreateBody1Rel().SetTargets([prim_path])
    FixedJoint.CreateLocalPos0Attr().Set(Gf.Vec3f(anchor_pos))
    FixedJoint.CreateLocalRot0Attr().Set(Gf.Quatf(1.0, Gf.Vec3f(0, 0, 0)))
    FixedJoint.CreateLocalPos1Attr().Set(Gf.Vec3f(0, 0, 0))
    FixedJoint.CreateLocalRot1Attr().Set(Gf.Quatf(1.0, Gf.Vec3f(0, 0, 0)))

def remove_anchor(self):
    fixed_joint_path = f"/World/envs/env_0/<robot>/<hand_link>/fixed_joint"
    is_valid = is_prim_path_valid(fixed_joint_path)
    if is_valid:
        delete_prim(fixed_joint_path)
1 Like

Thank you for your solution. Have you gotten the error of “Cannot remove ancestral prim”? I got the error when I tried to remove the prime in the second, and third… environments.

The code I attached above only performs add_anchor and remove_anchor for env_0. If you modify it as follows, it should probably work.

def add_anchor(self, object_name):
    self._stage = get_current_stage()
    for i in range(self._num_envs):
        object_prim_path = f"/World/envs/env_{i}/{object_name}/{object_name}"
        fixed_joint_path = f"/World/envs/env_{i}/<robot>/<hand_link>/fixed_joint"

        # fix the object to hand
        anchor_pos = Gf.Vec3d([0.0, 0.0, 0.06])
        self.fix_to_hand(self._stage, fixed_joint_path, object_prim_path, anchor_pos, i, object_name, '<hand_link>')

def fix_to_hand(self, stage, joint_path, prim_path, anchor_pos, env_id, object_name, hand_name):
    # D6 fixed joint
    FixedJoint = UsdPhysics.FixedJoint.Define(stage, joint_path)
    FixedJoint.CreateBody0Rel().SetTargets([f"/World/envs/env_{env_id}/<robot>/{hand_name}"])
    FixedJoint.CreateBody1Rel().SetTargets([prim_path])
    FixedJoint.CreateLocalPos0Attr().Set(Gf.Vec3f(anchor_pos))
    FixedJoint.CreateLocalRot0Attr().Set(Gf.Quatf(1.0, Gf.Vec3f(0, 0, 0)))
    FixedJoint.CreateLocalPos1Attr().Set(Gf.Vec3f(0, 0, 0))
    FixedJoint.CreateLocalRot1Attr().Set(Gf.Quatf(1.0, Gf.Vec3f(0, 0, 0)))

def remove_anchor(self):
    for i in range(self._num_envs):
        fixed_joint_path = f"/World/envs/env_{i}/<robot>/<hand_link>/fixed_joint"
        is_valid = is_prim_path_valid(fixed_joint_path)
        if is_valid:
            delete_prim(fixed_joint_path)

Thank you so much for the advice. In fact, I have implemented a similar structure for the environment and gotten the error of “Cannot remove ancestral prim”.

Sorry, I don’t know how to fix that error.
One possible cause is that you are calling this function in the wrong place and have specified a prim_path that has already been deleted. Or you may not have specified the correct prim_path.