def MovePiece(self,moveTuple): #Square variables fromSquare_r = moveTuple[0][0] fromSquare_c = moveTuple[0][1] toSquare_r = moveTuple[1][0] toSquare_c = moveTuple[1][1] #Gripper and arm initializations grip_right = baxter_interface.Gripper('right') right = baxter_interface.Limb('right') right.move_to_neutral() grip_right.calibrate() grip_right.open() #Give initial Cartesian coordinates to Baxter using fromSquare row and columns moveArmLoc('right', self.GetCartesian_col(fromSquare_c), self.GetCartesian_row(fromSquare_r), -0.20) time.sleep(1) #Pick up piece findPiece() moveArmLoc('right', self.GetCartesian_col(fromSquare_c), self.GetCartesian_row(fromSquare_r), -0.32) time.sleep(1) grip_right.close() time.sleep(1) #Give final Cartesian coordinates to Baxter using toSquare row and columns moveArmLoc('right', self.GetCartesian_col(toSquare_c), self.GetCartesian_row(toSquare_r), -0.20) #Drop piece moveArmLoc('right', self.GetCartesian_col(toSquare_c), self.GetCartesian_row(toSquare_r), -0.32) time.sleep(1) grip_right.open() #Return to home position moveArmLoc('right', self.GetCartesian_col(toSquare_c), self.GetCartesian_row(toSquare_r), -0.20) right.move_to_neutral() #Assign square positions for from and to pieces fromPiece = self.squares[fromSquare_r][fromSquare_c] toPiece = self.squares[toSquare_r][toSquare_c] #Move piece by changing square locations self.squares[toSquare_r][toSquare_c] = fromPiece self.squares[fromSquare_r][fromSquare_c] = 'e' fromPiece_fullString = self.GetFullString(fromPiece) toPiece_fullString = self.GetFullString(toPiece) if toPiece == 'e': messageString = fromPiece_fullString+ " moves from "+self.ConvertToAlgebraicNotation(moveTuple[0])+\ " to "+self.ConvertToAlgebraicNotation(moveTuple[1]) else: messageString = fromPiece_fullString+ " from "+self.ConvertToAlgebraicNotation(moveTuple[0])+\ " captures "+toPiece_fullString+" at "+self.ConvertToAlgebraicNotation(moveTuple[1])+"!" #capitalize first character of messageString messageString = string.upper(messageString[0])+messageString[1:len(messageString)] return messageString
def __init__(self,options): if options.debug: self.Board = ChessBoard(2) self.debugMode = True else: self.Board = ChessBoard(0) #0 for normal board setup; see ChessBoard class for other options (for testing purposes) self.debugMode = False self.Rules = ChessRules() findPiece()