def __init__(self): self.robot_position = [-0.8, 0, 0] self.contact_threshold = 0.1 self.action_dim = self.num_joints URDFBasedRobot.__init__( self, 'kuka_gripper_description/urdf/kuka_gripper.urdf', 'kuka0', action_dim=self.action_dim, obs_dim=1) self.observation_space = gym.spaces.Dict({ self.ObsSpaces.JOINT_POSITIONS: gym.spaces.Box(-np.inf, np.inf, [self.num_joints], dtype=float), self.ObsSpaces.TOUCH_SENSORS: gym.spaces.Box(0, np.inf, [self.num_touch_sensors], dtype=float), self.ObsSpaces.RETINA: gym.spaces.Box(0, 255, [Kuka.eye_height, Kuka.eye_width, 3], dtype=float), self.ObsSpaces.GOAL: gym.spaces.Box(0, 255, [Kuka.eye_height, Kuka.eye_width, 3], dtype=float) }) self.target = "orange" self.object_names = dict() self.object_bodies = dict() self.robot_parts = {}
def __init__(self): self.robot_position = [0, 0, 0] self.contact_threshold = 0.1 self.action_dim = self.num_joints URDFBasedRobot.__init__(self, 'hand_description/urdf/hand.urdf', 'hand0', action_dim=self.action_dim, obs_dim=1) self.observation_space = gym.spaces.Dict({ self.ObsSpaces.JOINT_POSITIONS: gym.spaces.Box( -np.inf, np.inf, [self.num_joints], dtype = float), self.ObsSpaces.TOUCH_SENSORS: gym.spaces.Box( 0, np.inf, [self.num_touch_sensors], dtype = float)}) self.object_names = dict() self.object_bodies = dict() self.robot_parts = {} self.touch_sensors = [] self.joint_names = [] for arm_part in ["arm_base", "arm0", "arm1", "palm"]: self.joint_names.append(arm_part) for finger in ["thumb", "index", "middle", "ring", "little"]: for nm in range(4): if nm >= 2: self.touch_sensors.append(finger+"%d"%nm) self.joint_names.append(finger+"%d"%nm)
def __init__(self, additional_obs=False, objects=3): self.robot_position = [-0.55, 0, -0.04] self.contact_threshold = 0.1 self.used_objects = ["table", "cube", "tomato", "mustard"][:objects+1] self.action_dim = self.num_joints URDFBasedRobot.__init__(self, 'kuka_gripper_description/urdf/' 'kuka_gripper.urdf', 'kuka0', action_dim=self.action_dim, obs_dim=1) self.min_joints = np.ones(9)*-np.pi*0.944 self.max_joints = np.ones(9)*np.pi*0.944 self.min_joints[0] = -np.pi*0.666 # Restricted range (min -0.944) self.max_joints[0] = np.pi*0.666 # Restricted range (max 0.944) self.min_joints[1:9:2] = -np.pi*0.666 self.max_joints[1:9:2] = np.pi*0.666 self.min_joints[6] = -np.pi*0.972 self.max_joints[6] = np.pi*0.972 self.min_joints[-2:] = 0 self.max_joints[-2:] = np.pi/2 self.action_space = gym.spaces.Box(low=self.min_joints, high=self.max_joints, dtype=float) if additional_obs: obj_obs = {} for obj in self.used_objects[1:]: high = np.array([np.finfo(np.float32).max, np.finfo(np.float32).max, np.finfo(np.float32).max]) obj_obs[obj] = gym.spaces.Box(-high, high, dtype=float) self.observation_space = gym.spaces.Dict({ self.ObsSpaces.JOINT_POSITIONS: gym.spaces.Box( -np.inf, np.inf, [self.num_joints], dtype=float), self.ObsSpaces.TOUCH_SENSORS: gym.spaces.Box( 0, np.inf, [self.num_touch_sensors], dtype=float), self.ObsSpaces.RETINA: gym.spaces.Box( 0, 255, [Kuka.eye_height, Kuka.eye_width, 3], dtype=np.uint8), self.ObsSpaces.DEPTH: gym.spaces.Box( 0, 1, [Kuka.eye_height, Kuka.eye_width], dtype=float), self.ObsSpaces.GOAL: gym.spaces.Box( 0, 255, [Kuka.eye_height, Kuka.eye_width, 3], dtype=np.uint8), self.ObsSpaces.MASK: gym.spaces.Box( 0, 255, [Kuka.eye_height, Kuka.eye_width], dtype=np.int32), self.ObsSpaces.GOAL_MASK: gym.spaces.Box( 0, 255, [Kuka.eye_height, Kuka.eye_width], dtype=np.int32), self.ObsSpaces.OBJ_POS: gym.spaces.Dict(obj_obs), self.ObsSpaces.GOAL_POS: gym.spaces.Dict(obj_obs) } ) else: self.observation_space = gym.spaces.Dict({ self.ObsSpaces.JOINT_POSITIONS: gym.spaces.Box( -np.inf, np.inf, [self.num_joints], dtype=float), self.ObsSpaces.TOUCH_SENSORS: gym.spaces.Box( 0, np.inf, [self.num_touch_sensors], dtype=float), self.ObsSpaces.RETINA: gym.spaces.Box( 0, 255, [Kuka.eye_height, Kuka.eye_width, 3], dtype=np.uint8), self.ObsSpaces.DEPTH: gym.spaces.Box( 0, 1, [Kuka.eye_height, Kuka.eye_width], dtype=float), self.ObsSpaces.GOAL: gym.spaces.Box( 0, 255, [Kuka.eye_height, Kuka.eye_width, 3], dtype=np.uint8)} ) self.target = "orange" self.object_names = dict() self.object_bodies = dict() self.robot_parts = {}
from robot_bases import XmlBasedRobot, MJCFBasedRobot, URDFBasedRobot