示例#1
0
class NAOProtocol(RobotProtocol):
    def __init__(self):
        self.walk = None

    def nxt_missing(self, nxt_handle, color):
        print "Searching for NXT #%d, color=%d" % (nxt_handle, color)
        return {"ack": "searching"}

    command.NXTMissing.responder(nxt_missing)

    def perform_calibration(self, nao_handle, nxt_handle, color):
        print "Performing calibration on NXT #%d, color=%d" % (nxt_handle, color)
        calibration = NAOCalibration()
        calibrationResult = calibration.performCalibration(color)
        if calibrationResult[0] != -1:
            return {
                "nao_handle": nao_handle,
                "nxt_handle": nxt_handle,
                "x_axis": calibrationResult[0],
                "y_axis": calibrationResult[1],
                "yaw": calibrationResult[2],
            }
        else:
            return {"handle": self.handle, "nxt_handle": nxt_handle, "x_axis": -1, "y_axis": -1, "yaw": -1}

    command.PerformCalibration.responder(perform_calibration)

    def send_path(self, path):
        print "Follow path"
        pprint.pprint(path)
        return {"ack": "follow path"}

    command.SendPath.responder(send_path)

    def nao_walk(self, nao_handle, nxt_handle):
        print "NAOWalk started"
        self.walk = NaoWalk(self)
        self.walk.followRedBall()
        return {"ack": "walk finished"}

    command.NAOWalk.responder(nao_walk)

    def target_reached(self):
        print "Target reached"
        self.walk.target_reached = True

    command.TargetReached.responder(target_reached)
示例#2
0
 def nao_walk(self, nao_handle, nxt_handle):
     print "NAOWalk started"
     self.walk = NaoWalk(self)
     self.walk.followRedBall()
     return {"ack": "walk finished"}