def _set_action(self, action): assert action.shape == (2, ) action = action.copy( ) # ensure that we don't change the action outside of this scope pos_ctrl = action[:2] # robot:body0 and robot:body1 for moving limbs pos_ctrl *= 0.05 # limit maximum change in position # Apply action to simulation. utils.ctrl_set_action(self.sim, pos_ctrl)
def _set_action(self, action): assert action.shape == (2,) action = np.array(action.copy()) # ensure that we don't change the action outside of this scope action *= 1 action = action.clip(-0.5,0.5) # Apply action to simulation. utils.ctrl_set_action(self.sim, action) #utils.mocap_set_action(self.sim, action) for i in range(60): self.sim.step()
def _set_action(self, action): assert action.shape == (4, ) action = action.copy( ) # ensure that we don't change the action outside of this scope pos_ctrl, gripper_ctrl = action[:3], action[3] pos_ctrl *= 0.05 # limit maximum change in position rot_ctrl = [ 1., 0., 1., 0. ] # fixed rotation of the end effector, expressed as a quaternion gripper_ctrl = np.array([gripper_ctrl, gripper_ctrl]) assert gripper_ctrl.shape == (2, ) if self.block_gripper: gripper_ctrl = np.zeros_like(gripper_ctrl) action = np.concatenate([pos_ctrl, rot_ctrl, gripper_ctrl]) # Apply action to simulation. utils.ctrl_set_action(self.sim, action) utils.mocap_set_action(self.sim, action)
def _set_action(self, action): """ Currently, I am just returning 1 number for the gripper control because there are 2 fingers in the robot that is used in the OpenAI gym library. If I start using movo, I would need 3 fingers so perhaps increase the gripper control from 2 to 3. """ assert action.shape == (8,) action = action.copy() # ensures that we don't change the action outside of this scope pos_ctrl, rot_ctrl, gripper_ctrl = action[:3], action[3:7], action[-1] # This is where I match the gripper control to number of fingers gripper_ctrl = np.array([gripper_ctrl, gripper_ctrl]) assert gripper_ctrl.shape == (2,) # Create the action that we want to pass into the simulation action = np.concatenate([pos_ctrl, rot_ctrl, gripper_ctrl]) # Now apply the action to the simulation utils.ctrl_set_action(self.sim, action) # note self.sim is an inherited variable utils.mocap_set_action(self.sim, action)