Exemple #1
0
    def __init__(self):
        if Server.instance:
            raise SingletonAccessException()
        print "sever created"
        Server.instance = self

        self._initializeSocket()
        self._setConnections()
        SendEvent.addHandler(self.send)
Exemple #2
0
    def __doDrawing(self, orientation, scale):
        print "Extracting points with camera..."
        drawingCountoursFound = False

        drawingCountour = []

        tryCount = 0
        while not drawingCountoursFound:
            shuffleDistance = 3
            try:
                drawingCountour = self.cam.getDrawingContour()
                drawingCountoursFound = True
            except ValueError:
                print "Failed to extract points from camera! Retrying... with count: " + str(tryCount)
                if not tryCount % 5:
                    self.robotMover.relativeShuffle(shuffleDistance, -150)
                elif tryCount % 5 == 1:
                    self.robotMover.relativeShuffle(shuffleDistance, 90)
                elif tryCount % 5 == 2:
                    self.robotMover.relativeShuffle(shuffleDistance, -30)
                elif tryCount % 5 == 3:
                    self.robotMover.doRelativeRotation(-10)
                else:
                    self.robotMover.doRelativeRotation(20)
                tryCount += 1

        points = drawingCountour[0]
        size = drawingCountour[1]

        print points
        print size

        pointsToDraw = self.imagePointsTransformer.transform(drawingCountour, orientation, scale)

        SendEvent.send(SendDessin(pointsToDraw))

        movedPoints = PointsCloudOperations.move(pointsToDraw, 144.8, 25.5)

        print "going to first drawing point"
        self.robotMover.doSnakeMovement(movedPoints[0], 270)
        print "arrived at first drawing point!"

        prehensorController = PrehensorController()
        prehensorController.dropPrehensor()
        movedPoints.append(movedPoints[0]) # this is to close the figure

        self.robotMover.doShuffleMovement(movedPoints, 270)

        prehensorController.raisePrehensor()
Exemple #3
0
    def __init__(self, obstacle1, obstacle2):
        Terrain.OBSTACLE_1 = obstacle1
        Terrain.OBSTACLE_2 = obstacle2

        print "obstacle 1: " + str(obstacle1)
        print "obstacle 2: " + str(obstacle2)

        SendEvent.send(SendConfirm())

        self.robotMover = RobotMover()
        self.signalSearcher = ManchesterSignalSearcher()
        self.captorsController = CaptorsController()
        self.imagePointsTransformer = ImagePointsTransformer()
        self.cam = Camera()
        self.ledController = LedController()

        self.firstTurnOver = False
Exemple #4
0
    def run(self):
        self.ledController.turnLedOff()

        interpretedSignal = ()

        if not self.firstTurnOver:
            self.__acquireCurrentPose()
            self.__doZignage()

            interpretedSignal, signalPosition = self.signalSearcher.searchSignal()
            self.signalPosition = signalPosition
        else:
            self.__doZignage_b()
            self.robotMover.doSnakeMovement(self.signalPosition, 270)
            interpretedSignal = self.signalSearcher.doSimpleSignalDecoding()

        print "interpreted signal: " + str(interpretedSignal)

        figureId = interpretedSignal[0]
        orientation = interpretedSignal[1]
        scale = interpretedSignal[2]

        self.__doZignage()

        self.__goToProperImageForScanning(figureId)

        self.__doDrawing(orientation, scale)

        self.robotMover.doSnakeMovement(Terrain.AR_TAG_SOUTH_FACE, 90)

        self.__doZignage_a()

        self.flashLed()

        SendEvent.send(SendEnd())
        self.firstTurnOver = True
        StateController.instance.endMainLoop()
        return
Exemple #5
0
Fichier : robot.py Projet : spg/JDV
 def setCurrentPose(pose):
     Robot.currentPose = pose
     SendEvent.send(SendPose(pose[0], pose[1], pose[2]))
Exemple #6
0
 def logToBase(message):
     logAction = Log(message)
     SendEvent.send(logAction)