Exemplo n.º 1
0
    def SaveMap(self):
        mower = None
        station = None
        if self.isMowerPlaced:
            mower = Point(self.posX, self.posY)
            mower.borderId = 0
        if self.isStationPlaced:
            station = Point(self.stationPosX, self.stationPosY)
            station.borderId = 0

        self.lawn.SaveMap(mower, station)
Exemplo n.º 2
0
    def LoadMap(self):
        self.shape = Shape()
        self.shapes = []
        self.loadState = 0
        self.lawn = 'lawn'
        self.obstacle = 'obstacle'
        self.mower = 'mower'
        self.station = 'station'

        f = open(
            "/home/pi/catkin_ws/src/intelli_mower/src/IntelliMowerAlgorithmRoS/src/map_one",
            'r')
        for line in f:
            if line.strip() == str(self.lawn):
                self.loadState = 3

            elif line.strip() == str(self.obstacle):
                self.loadState = 4
                newShape = Shape()
                self.shapes.append(newShape)

            elif line.strip() == str(self.mower):
                self.loadState = 1

            elif line.strip() == str(self.station):
                self.loadState = 2

            else:
                if self.loadState == 1:
                    cords = line.split()
                    self.mowerP = Point(float(cords[0]), float(cords[1]))
                    self.mowerP.borderId = int(cords[2])

                elif self.loadState == 2:
                    cords = line.split()
                    self.stationP = Point(float(cords[0]), float(cords[1]))
                    self.stationP.borderId = int(cords[2])

                # load outer border
                elif self.loadState == 3:
                    cords = line.split()
                    p = Point(float(cords[0]), float(cords[1]))
                    p.borderId = int(cords[2])
                    self.shape.AddBorderPoint(p)

                # load inner border
                elif self.loadState == 4:
                    cords = line.split()
                    p = Point(float(cords[0]), float(cords[1]))
                    p.borderId = int(cords[2])
                    self.shapes[-1].AddBorderPoint(p)
        f.close()
Exemplo n.º 3
0
    def Controller(self, x=0, y=0):
        if self.state == 0:
            return
        # state 1 is in Set Lawn Boundary Mode
        elif self.state == 1:
            newLawnPoint = Point(x, y)
            newLawnPoint.borderId = 0
            self.lawn.outerBorder.AddBorderPoint(newLawnPoint)

        # state 2 is in Set Obstacle Boundary Mode
        elif self.state == 2:
            newObstaclePoint = Point(x, y)
            newObstaclePoint.borderId = len(self.lawn.innerBorders)
            self.lawn.innerBorders[-1].AddBorderPoint(newObstaclePoint)

        # state 3 place the mower with mouse click
        elif self.state == 3:
            self.PlaceMower(x, y)

        # state 4 place the charging station with mouse click
        elif self.state == 4:
            self.PlaceStation(x, y)