def think(self, perception): action = super(PIDAgent, self).think(perception) '''calculate control vector (speeds) from perception.joint: current joints' positions (dict: joint_id -> position (current)) self.target_joints: target positions (dict: joint_id -> position (target)) ''' joint_angles = np.asarray( [perception.joint[joint_id] for joint_id in JOINT_CMD_NAMES]) target_angles = np.asarray([self.target_joints.get(joint_id, perception.joint[joint_id]) for joint_id in JOINT_CMD_NAMES]) u = self.joint_controller.control(target_angles, joint_angles) action.speed = dict(zip(JOINT_CMD_NAMES.iterkeys(), u)) # dict: joint_id -> speed return action
def think(self, perception): action = super(PIDAgent, self).think(perception) '''calculate control vector (speeds) from perception.joint: current joints' positions (dict: joint_id -> position (current)) self.target_joints: target positions (dict: joint_id -> position (target)) ''' joint_angles = np.asarray( [perception.joint[joint_id] for joint_id in JOINT_CMD_NAMES]) target_angles = np.asarray([self.target_joints.get(joint_id, perception.joint[joint_id]) for joint_id in JOINT_CMD_NAMES]) u = self.joint_controller.control(target_angles, joint_angles) action.speed = dict(zip(JOINT_CMD_NAMES.iterkeys(), u)) # dict: joint_id -> speed return action
def think(self, perception): if self.still: return super(AngleInterpolationAgent, self).think(perception) target_joints = self.angle_interpolation(perception) self.target_joints.update(target_joints) self.target_joints_log.append(self.target_joints.copy()) self.joints_log.append(perception.joint.copy()) result = super(AngleInterpolationAgent, self).think(perception) self.actions_log.append( dict(zip(JOINT_CMD_NAMES.iterkeys(), self.joint_controller.u))) return result
def think(self, perception): # What is SparkAgent.think method doing? action = super(PIDAgent, self).think(perception) # calculate control vector (speeds) from perception.joint, self.target_joints joint_angles = np.asarray( [perception.joint[joint_id] for joint_id in JOINT_CMD_NAMES]) target_angles = np.asarray([self.target_joints.get(joint_id, perception.joint[joint_id]) for joint_id in JOINT_CMD_NAMES]) # Here, PIDController.control() method is called to determine this timestep's actions u = self.joint_controller.control(target_angles, joint_angles) # Prepare for return action.speed = dict(zip(JOINT_CMD_NAMES.iterkeys(), u)) # dict: joint_id -> speed return action