示例#1
0
    def parseMessage(self, msg_str):
        try:
            msg_str = msg_str.strip("\< \>\n\r")
            msg_parts1 = msg_str.split("|")
            self.type = RobotState.STATES[int(msg_parts1[0])]
            msg_parts2 = msg_parts1[1].split(":")
            self.messageNumber = int(msg_parts2[0])
            for i in range(1, len(msg_parts2)):
                self.messageData.append(float(msg_parts2[i]))

        #Some error occurred in parsing the message - probably malformed.
        except:
            LOGGER.Moderate("Error on message:" + msg_str)
            pass
示例#2
0
                winchEncoderResetFlag = True
                LOGGER.Low("Acquiring Lock")
                motorHandlerLock.acquire()
                motorSerialHandler.sendMessage("<ResetWinchEncoder>\n")
                motorHandlerLock.release()
                LOGGER.Low("Releasing Lock")

            elif (currentMessage.type == "MSG_MOTOR_VALUES"):
                LOGGER.Debug("Received a MSG_MOTOR_VALUES")
                print "MADE IT 1"

            elif (currentMessage.type == "MSG_RATCHET_POSITION"):
                LOGGER.Debug("Received a MSG_RATCHET_POSITION")

            else:
                LOGGER.Moderate("Received an invalid message.")

        #
        # MSG_STOP:
        # Stop all motors immediately
        #
        if (currentMessage.type == "MSG_STOP"):
            ceaseAllMotorFunctions()
            outboundMessageQueue.add("Finished\n")

        #
        # MSG_DRIVE_TIME:
        # Drive forward/backward with both motors at the same value
        # Data 0: The time in seconds the robot should drive
        # Data 1: The power/speed to drive at
        #