def _get_obs(self): # "primary" information, either this is the visual frame or the object position and velocity achieved_goal = self._get_achieved_goal().ravel() if self.visual_input: primary = self.render(mode="rgb_array", height=VISION_WH, width=VISION_WH) else: object_vel = self.sim.data.get_joint_qvel('object:joint') primary = np.concatenate([achieved_goal, object_vel]) # get proprioceptive information (positions of joints) robot_pos, robot_vel = manipulate.robot_get_obs(self.sim) proprioception = np.concatenate([robot_pos, robot_vel]) # touch sensor information if self.touch_get_obs == 'sensordata': touch = self.sim.data.sensordata[self._touch_sensor_id] else: raise NotImplementedError("Only sensor data supported atm, sorry.") return { "observation": np.array((primary.copy(), proprioception.copy(), touch.copy(), self.goal.ravel().copy())), "achieved_goal": achieved_goal.copy(), "desired_goal": self.goal.ravel().copy(), }
def _get_obs(self): robot_qpos, robot_qvel = manipulate.robot_get_obs(self.sim) object_qvel = self.sim.data.get_joint_qvel('object:joint') fingertip_pos = self.sim.data.get_site_xpos('robot0:T_fftip_tip') achieved_goal = np.concatenate( [self._get_achieved_goal().ravel(), fingertip_pos]) # this contains the object position + rotation touch_values = [ ] # get touch sensor readings. if there is one, set value to 1 if self.touch_get_obs == 'sensordata': touch_values = self.sim.data.sensordata[self._touch_sensor_id] elif self.touch_get_obs == 'boolean': touch_values = self.sim.data.sensordata[ self._touch_sensor_id] > 0.0 elif self.touch_get_obs == 'log': touch_values = np.log( self.sim.data.sensordata[self._touch_sensor_id] + 1.0) observation = np.concatenate( [robot_qpos, fingertip_pos, touch_values, achieved_goal]) return { 'observation': observation.copy(), 'achieved_goal': achieved_goal.copy(), 'desired_goal': self.goal.ravel().copy(), }
def _get_obs(self): robot_qpos, robot_qvel = manipulate.robot_get_obs(self.sim) object_qvel = self.sim.data.get_joint_qvel('object:joint') achieved_goal = self._get_achieved_goal().ravel() # this contains the object position + rotation touch_values = [] # get touch sensor readings. if there is one, set value to 1 if self.touch_get_obs == 'sensordata': touch_values = self.sim.data.sensordata[self._touch_sensor_id] elif self.touch_get_obs == 'boolean': touch_values = self.sim.data.sensordata[self._touch_sensor_id] > 0.0 elif self.touch_get_obs == 'log': touch_values = np.log(self.sim.data.sensordata[self._touch_sensor_id] + 1.0) observation = np.concatenate([robot_qpos, robot_qvel, object_qvel, touch_values, achieved_goal]) return { 'observation': observation.copy(), 'achieved_goal': achieved_goal.copy(), 'desired_goal': self.goal.ravel().copy(), }
def _get_obs(self): # "primary" information, either this is the visual frame or the object position and velocity achieved_goal = self._get_achieved_goal().ravel() visual = self.render(mode="rgb_array", height=VISION_WH, width=VISION_WH) # get proprioceptive information (positions of joints) and touch sensors robot_pos, robot_vel = manipulate.robot_get_obs(self.sim) proprioception = np.concatenate([robot_pos, robot_vel]) touch = self.sim.data.sensordata[self._touch_sensor_id] return { "observation": np.array((visual.copy(), proprioception.copy(), touch.copy(), self.goal.ravel().copy())), "achieved_goal": achieved_goal.copy(), "desired_goal": self.goal.ravel().copy(), }
def _get_obs(self): robot_qpos, robot_qvel = manipulate.robot_get_obs(self.sim) object_qvel = self.sim.data.get_joint_qvel('object:joint') achieved_goal = self._get_achieved_goal().ravel() # this contains the object position + rotation touch_values = [] # get touch sensor readings. if there is one, set value to 1 if self.touch_get_obs == 'boolean': for touch_sensor_id, site_id in self._touch_sensor_id_site_id: value = 1.0 if self.sim.data.sensordata[touch_sensor_id] != 0.0 else 0.0 touch_values.append(value) elif self.touch_get_obs == 'log': for touch_sensor_id, site_id in self._touch_sensor_id_site_id: value = self.sim.data.sensordata[touch_sensor_id] touch_values.append(value) if len(touch_values) > 0: touch_values = np.log(np.array(touch_values) + 1.0) observation = np.concatenate([robot_qpos, robot_qvel, object_qvel, touch_values, achieved_goal]) return { 'observation': observation.copy(), 'achieved_goal': achieved_goal.copy(), 'desired_goal': self.goal.ravel().copy(), }
def _get_obs(self): robot_qpos, robot_qvel = manipulate.robot_get_obs(self.sim) object_qvel = self.sim.data.get_joint_qvel("object:joint") achieved_goal = (self._get_achieved_goal().ravel() ) # this contains the object position + rotation touch_values = [ ] # get touch sensor readings. if there is one, set value to 1 if self.touch_get_obs == "sensordata": touch_values = self.sim.data.sensordata[self._touch_sensor_id] elif self.touch_get_obs == "boolean": touch_values = self.sim.data.sensordata[ self._touch_sensor_id] > 0.0 elif self.touch_get_obs == "log": touch_values = np.log( self.sim.data.sensordata[self._touch_sensor_id] + 1.0) observation = np.concatenate( [robot_qpos, robot_qvel, object_qvel, touch_values, achieved_goal]) return { "observation": observation.copy(), "achieved_goal": achieved_goal.copy(), "desired_goal": self.goal.ravel().copy(), }