Beispiel #1
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()
Beispiel #2
0
    def transform(self, pointsFromImage, orientation, scale):
        transformedPoints = PointsCloudOperations.scale(pointsFromImage[0], 60 / int(pointsFromImage[1]))

        movedPoints = PointsCloudOperations.move(transformedPoints, -30, -30)

        if orientation == ManchesterSignalInterpreter.EAST:
            rotatedPoints = PointsCloudOperations.rotate(movedPoints, 90)
        elif orientation == ManchesterSignalInterpreter.WEST:
            rotatedPoints = PointsCloudOperations.rotate(movedPoints, 270)
        elif orientation == ManchesterSignalInterpreter.SOUTH:
            rotatedPoints = PointsCloudOperations.rotate(movedPoints, 180)
        else:
            rotatedPoints = PointsCloudOperations.rotate(movedPoints, 0)

        if scale == ManchesterSignalInterpreter.FACTOR_2:
            rotatedPoints = PointsCloudOperations.scale(rotatedPoints, 0.5)
            transformedPoints = PointsCloudOperations.move(rotatedPoints, 30, 30)
        else:
            transformedPoints = PointsCloudOperations.move(rotatedPoints, 30, 30)

        return transformedPoints
Beispiel #3
0
    def test_scale_simpleCase_1(self):
        cloud = [(0, 0), (2, 0), (2, 2), (0, 2)]

        self.assertEqual([(0, 0), (1, 0), (1, 1), (0, 1)], PointsCloudOperations.scale(cloud, 0.5))
Beispiel #4
0
    def test_move_simpleCase_4(self):
        cloud = [(103, 90), (254, 78), (691, 690), (3, 4)]

        self.assertEqual([(92.5, 93), (243.5, 81), (680.5, 693), (-7.5, 7)],
            PointsCloudOperations.move(cloud, -10.5, 3))
Beispiel #5
0
    def test_move_simpleCase_3(self):
        cloud = [(100, 100), (250, 80), (400, 400), (0, 0)]

        self.assertEqual([(90, 110), (240, 90), (390, 410), (-10, 10)], PointsCloudOperations.move(cloud, -10, 10))
Beispiel #6
0
    def test_move_simpleCase_2(self):
        cloud = [(1, 1), (2, 2), (2, 0), (0, 0)]

        self.assertEqual([(1, 1), (2, 2), (2, 0), (0, 0)], PointsCloudOperations.move(cloud, 0, 0))
Beispiel #7
0
    def test_move_simpleCase_1(self):
        cloud = [(0, 0), (2, 0), (2, 2), (0, 2)]

        self.assertEqual([(1, 1), (3, 1), (3, 3), (1, 3)], PointsCloudOperations.move(cloud, 1, 1))
Beispiel #8
0
    def test_scale_simpleCase_4(self):
        cloud = [(103, 90), (254, 78), (691, 690), (3, 4)]

        self.assertEqual([(8.24, 7.2), (20.32, 6.24), (55.28, 55.2), (0.24, 0.32)],
            PointsCloudOperations.scale(cloud, 60 / 750))
Beispiel #9
0
    def test_scale_simpleCase_3(self):
        cloud = [(100, 100), (250, 80), (400, 400), (0, 0)]

        self.assertEqual([(15, 15), (37.5, 12), (60, 60), (0, 0)], PointsCloudOperations.scale(cloud, 60 / 400))
Beispiel #10
0
    def test_scale_simpleCase_2(self):
        cloud = [(1, 1), (2, 2), (2, 0), (0, 0)]

        self.assertEqual([(2, 2), (4, 4), (4, 0), (0, 0)], PointsCloudOperations.scale(cloud, 2))