def go(self, speed, direction): """update the speed and direction of the robot""" rightM = 0 leftM = 0 if direction == 0: rightM = 100 leftM = 100 elif direction == 45: rightM = 50 leftM = 100 elif direction == -45: rightM = 100 leftM = 50 elif direction == 90: rightM = -80 leftM = 80 elif direction == -90: rightM = 80 leftM = -80 elif direction == 135: rightM = -50 leftM = -100 elif direction == -135: rightM = -100 leftM = -50 elif abs(direction) == 180: rightM = -100 leftM = -100 speed = speed / 100.0 rightM = rightM * speed leftM = leftM * speed print rightM, leftM self.pinsTL.acquire() # acquire a Thread Lock if RobotHelper.isPositive(rightM): self.pinArray["RightBack"].stop() self.pinArray["RightFront"].start(rightM) else: self.pinArray["RightFront"].stop() self.pinArray["RightBack"].start(abs(rightM)) if RobotHelper.isPositive(leftM): self.pinArray["LeftBack"].stop() self.pinArray["LeftFront"].start(leftM) else: self.pinArray["LeftFront"].stop() self.pinArray["LeftBack"].start(abs(leftM)) self.pinsTL.release() # release the Thread Lock