# Surface gripper support for gpu

**URL:** <https://forums.developer.nvidia.com/t/surface-gripper-support-for-gpu/273761>\
**Category:** Isaac Sim\
**Created:** [November 23, 2023, 3:35am UTC](https://forums.developer.nvidia.com/t/surface-gripper-support-for-gpu/273761 "2023-11-23T03:35:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ensu](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ensu](https://forums.developer.nvidia.com/u/ensu)\
**Post date:** [November 23, 2023, 3:35am UTC](https://forums.developer.nvidia.com/t/surface-gripper-support-for-gpu/273761/1 "2023-11-23T03:35:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![makoto.sato385](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/makoto.sato385/32/260144_2.png) [@makoto.sato385](https://forums.developer.nvidia.com/u/makoto.sato385)\
**Post date:** [November 23, 2023, 10:22am UTC](https://forums.developer.nvidia.com/t/surface-gripper-support-for-gpu/273761/2 "2023-11-23T10:22:47Z")

</div>

Hello!  
I encountered the same issue you mentioned here. [I posted it earlier,](https://forums.developer.nvidia.com/t/how-to-add-surface-gripper/260150/2) 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.

> <https://github.com/NVIDIA-Omniverse/OmniIsaacGymEnvs/blob/8cf773ab6cac0c8e0d55f46d6d7d258e781c6458/omniisaacgymenvs/tasks/ball_balance.py#L123C1-L157C38>

---

<div class="post-metadata">

**Author:** ![ensu](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ensu](https://forums.developer.nvidia.com/u/ensu)\
**Post date:** [November 24, 2023, 9:46am UTC](https://forums.developer.nvidia.com/t/surface-gripper-support-for-gpu/273761/3 "2023-11-24T09:46:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![makoto.sato385](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/makoto.sato385/32/260144_2.png) [@makoto.sato385](https://forums.developer.nvidia.com/u/makoto.sato385)\
**Post date:** [November 24, 2023, 4:01pm UTC](https://forums.developer.nvidia.com/t/surface-gripper-support-for-gpu/273761/4 "2023-11-24T16:01:18Z")

</div>

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.

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![ensu](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ensu](https://forums.developer.nvidia.com/u/ensu)\
**Post date:** [November 26, 2023, 12:56am UTC](https://forums.developer.nvidia.com/t/surface-gripper-support-for-gpu/273761/5 "2023-11-26T00:56:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![makoto.sato385](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/makoto.sato385/32/260144_2.png) [@makoto.sato385](https://forums.developer.nvidia.com/u/makoto.sato385)\
**Post date:** [November 26, 2023, 11:19am UTC](https://forums.developer.nvidia.com/t/surface-gripper-support-for-gpu/273761/6 "2023-11-26T11:19:27Z")

</div>

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.

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![ensu](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ensu](https://forums.developer.nvidia.com/u/ensu)\
**Post date:** [November 26, 2023, 9:40pm UTC](https://forums.developer.nvidia.com/t/surface-gripper-support-for-gpu/273761/7 "2023-11-26T21:40:22Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![makoto.sato385](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/makoto.sato385/32/260144_2.png) [@makoto.sato385](https://forums.developer.nvidia.com/u/makoto.sato385)\
**Post date:** [November 29, 2023, 6:22am UTC](https://forums.developer.nvidia.com/t/surface-gripper-support-for-gpu/273761/8 "2023-11-29T06:22:16Z")

</div>

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.
