@@ -108,6 +108,7 @@ def __init__(
108
108
base_name = "body" ,
109
109
grasping_mode = "assisted" ,
110
110
higher_limits = False ,
111
+ legacy_proprioception = False ,
111
112
** kwargs ,
112
113
):
113
114
"""
@@ -133,6 +134,8 @@ def __init__(
133
134
:param higher_limits: bool, indicating whether the limbs' velocity and position limits should be set
134
135
in the extended mode which allows for the instant responsiveness required for VR. Defaults to True.
135
136
learning-based agents should set this parameter to False for a more realistic capability set.
137
+ :param legacy_proprioception: Use the proprioception dimensions and dict keys that the BehaviorRobot had at
138
+ the BEHAVIOR challenge, rather than the ones automatically generated by underlying robot classes.
136
139
:param **kwargs: see ManipulationRobot, LocomotionRobot, ActiveCameraRobot
137
140
"""
138
141
assert reset_joint_pos is None , "BehaviorRobot doesn't support hand-specified reset_joint_pos"
@@ -144,6 +147,7 @@ def __init__(
144
147
self .use_ghost_hands = use_ghost_hands
145
148
self .normal_color = normal_color
146
149
self .show_visual_head = show_visual_head
150
+ self ._legacy_proprioception = legacy_proprioception
147
151
148
152
self ._position_limit_coefficient = 1 if higher_limits else LOWER_LIMITS_POSITION_COEFFICIENT
149
153
self ._velocity_limit_coefficient = 1 if higher_limits else LOWER_LIMITS_VELOCITY_COEFFICIENT
@@ -290,6 +294,51 @@ def set_position_orientation(self, pos, orn):
290
294
291
295
clear_cached_states (self )
292
296
297
+ @property
298
+ def default_proprio_obs (self ):
299
+ if self ._legacy_proprioception :
300
+ return [
301
+ "left_hand_position_local" ,
302
+ "left_hand_orientation_local" ,
303
+ "right_hand_position_local" ,
304
+ "right_hand_orientation_local" ,
305
+ "eye_position_local" ,
306
+ "eye_orientation_local" ,
307
+ "left_hand_trigger_fraction" ,
308
+ "left_hand_is_grasping" ,
309
+ "right_hand_trigger_fraction" ,
310
+ "right_hand_is_grasping" ,
311
+ ]
312
+
313
+ # Otherwise just return the default observations
314
+ return super ().default_proprio_obs
315
+
316
+ def _get_proprioception_dict (self ):
317
+ if self ._legacy_proprioception :
318
+ # In the legacy proprioception mode, we use some custom labels and fields.
319
+ state = {}
320
+
321
+ # Get all the part poses first.
322
+ for part_name , part in self ._parts .items ():
323
+ if part_name == "body" :
324
+ continue
325
+ part_pos , part_orn = part .get_local_position_orientation ()
326
+ state [f"{ part_name } _position_local" ] = part_pos
327
+ state [f"{ part_name } _orientation_local" ] = p .getEulerFromQuaternion (part_orn )
328
+
329
+ # Get grasping information.
330
+ for arm in self .arm_names :
331
+ finger_pos = self .joint_positions [self .gripper_control_idx [arm ]]
332
+ min_pos = self .joint_lower_limits [self .gripper_control_idx [arm ]]
333
+ max_pos = self .joint_upper_limits [self .gripper_control_idx [arm ]]
334
+ trigger_fraction = np .max ((finger_pos - min_pos ) / (max_pos - min_pos ))
335
+ state [f"{ arm } _trigger_fraction" ] = [np .clip (trigger_fraction , 0 , 1 )]
336
+ state [f"{ arm } _is_grasping" ] = [self .is_grasping (arm = arm )]
337
+
338
+ return state
339
+
340
+ return super ()._get_proprioception_dict ()
341
+
293
342
def set_poses (self , poses ):
294
343
assert len (poses ) == len (self ._parts ), "Number of poses (%d) does not match number of parts (%d)" % (
295
344
len (poses ),
0 commit comments