Skip to content

Commit 2ebb2a0

Browse files
authored
[add] add grasp qpos for inspire and fourier hand (#670)
* [add] add grasp qpos for inspire and fourier hand * [fix] fix gripper abs control
1 parent 4b5c5d3 commit 2ebb2a0

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

robosuite/devices/device.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def input2action(self, mirror_actions=False) -> Optional[Dict]:
112112

113113
# Get controller reference
114114
controller = robot.part_controllers[active_arm]
115+
gripper = robot.gripper[active_arm]
115116
gripper_dof = robot.gripper[active_arm].dof
116117

117118
assert controller.name in ["OSC_POSE", "JOINT_POSITION"], "only supporting OSC_POSE and JOINT_POSITION for now"
@@ -163,11 +164,15 @@ def input2action(self, mirror_actions=False) -> Optional[Dict]:
163164
)
164165
ac_dict[f"{active_arm}_abs"] = arm_action["abs"]
165166
ac_dict[f"{active_arm}_delta"] = arm_action["delta"]
166-
ac_dict[f"{active_arm}_gripper"] = np.array([grasp] * gripper_dof)
167+
168+
if hasattr(gripper, "grasp_qpos"):
169+
ac_dict[f"{active_arm}_gripper"] = getattr(gripper, "grasp_qpos")[grasp]
170+
else:
171+
ac_dict[f"{active_arm}_gripper"] = np.array([grasp] * gripper_dof)
167172

168173
# clip actions between -1 and 1
169174
for (k, v) in ac_dict.items():
170-
if "abs" not in k:
175+
if "abs" not in k and "gripper" not in k:
171176
ac_dict[k] = np.clip(v, -1, 1)
172177

173178
return ac_dict

robosuite/models/grippers/fourier_hands.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ def format_action(self, action):
3131
def init_qpos(self):
3232
return np.array([0.0] * 11)
3333

34+
@property
35+
def grasp_qpos(self):
36+
return {
37+
-1: np.array([-1.5, -1.5, -1.5, -1.5, -3, 3]), # open
38+
1: np.array([1.5, 1.5, 1.5, 1.5, 3, 3]), # close
39+
}
40+
3441
@property
3542
def speed(self):
3643
return 0.15
@@ -99,6 +106,13 @@ def format_action(self, action):
99106
def init_qpos(self):
100107
return np.array([0.0] * 11)
101108

109+
@property
110+
def grasp_qpos(self):
111+
return {
112+
-1: np.array([-1.5, -1.5, -1.5, -1.5, -3, 3]), # open
113+
1: np.array([1.5, 1.5, 1.5, 1.5, 3, 3]), # close
114+
}
115+
102116
@property
103117
def speed(self):
104118
return 0.15

robosuite/models/grippers/inspire_hands.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ def format_action(self, action):
3131
def init_qpos(self):
3232
return np.array([0.0] * 12)
3333

34+
@property
35+
def grasp_qpos(self):
36+
return {
37+
-1: np.array([-1.5, -1.5, -1.5, -1.5, -3, 3]), # open
38+
1: np.array([1.5, 1.5, 1.5, 1.5, 3, 3]), # close
39+
}
40+
3441
@property
3542
def speed(self):
3643
return 0.15
@@ -101,6 +108,13 @@ def format_action(self, action):
101108
def init_qpos(self):
102109
return np.array([0.0] * 12)
103110

111+
@property
112+
def grasp_qpos(self):
113+
return {
114+
-1: np.array([-1.5, -1.5, -1.5, -1.5, -3, 3]), # open
115+
1: np.array([1.5, 1.5, 1.5, 1.5, 3, 3]), # close
116+
}
117+
104118
@property
105119
def speed(self):
106120
return 0.15

0 commit comments

Comments
 (0)