예제 #1
0
    def convertBoard(self, cubes):
        """
        Takes in a list of cubes structs and converts it to board model

        Called by Kevin's script for building planning
        """
        #Set Up board
        board = []

        #Add a new z layers
        for i in xrange(5):
            board.append([[None, None, None, None, None],
                          [None, None, None, None, None],
                          [None, None, None, None, None],
                          [None, None, None, None, None],
                          [None, None, None, None, None]])

        #Convert cube data to board dimensions
        #Fill out board according to cube data
        for cube in cubes.building:
            gcube = Grid_Cube()
            gcube.x = self.closest(self.pixelX, cube.x)
            gcube.y = self.closest(self.pixelY, cube.y)
            gcube.z = self.closest(self.pixelZ, cube.z)
            board[gcube.x][gcube.y][gcube.z] = gcube
        return board  #3d array with x, y, and z of blocks
예제 #2
0
 def make_grid_cube(self, cube):
     """
     converting between data types, this one converts from python cube to ros cube
     """
     if not cube:
         return None
     grid_cube = Grid_Cube()
     grid_cube.x = cube.x
     grid_cube.y = cube.y
     grid_cube.z = cube.z
     return grid_cube
예제 #3
0
    def receive_email(self):
        username = '******'
        password = '******'

        # login to mail service
        M = imaplib.IMAP4_SSL('imap.gmail.com', '993')
        # M.login(username, getpass.getpass())
        M.login(username, password)

        M.select()
        typ, data = M.search(None, 'ALL')

        # read from the most recent email
        num = data[0].split(' ')[-1]
        typ, data = M.fetch(num, '(RFC822)')
        subject = data[0][1].split('\r\n')[11]
        body = data[0][1].split('\r\n')[15]
        M.close()
        M.logout()

        if subject != self.previous_subject and self.is_receiving:
            print("email received")
            cube_structure = Cube_Structures()
            coords = body.split(',')
            topic = coords[0]
            coords = coords[1:]
            if topic == '/build_cmd' and self.name != 'castor':
                real_building = Real_Structure()
                coords = coords[0:len(coords) - 1]

                for i in range(len(coords) / 6):
                    real_building.building.append(
                        Real_Cube(x=float(coords[i * 3]),
                                  y=float(coords[i * 3 + 1]),
                                  z=float(coords[i * 3 + 2])))
                cube_structure.real_building = real_building

                grid_building = Grid_Structure()
                for i in range(len(coords) / 6, len(coords) / 3):
                    grid_building.building.append(
                        Grid_Cube(x=int(coords[i * 3]),
                                  y=int(coords[i * 3 + 1]),
                                  z=int(coords[i * 3 + 2])))
                cube_structure.grid_building = grid_building

                print("Cube Message Published")
                self.cmd_pub.publish(cube_structure)
            elif topic == '/coordination_status_castor' and self.name == 'pollux':
                print('Castor Status Message Published')
                print(coords[0])
                self.castor_status_pub.publish(coords[0])
            elif topic == '/coordination_status_pollux' and self.name == 'castor':
                print('Pollux Status Message Published')
                print(coords[0])
                self.pollux_status_pub.publish(coords[0])

        self.previous_subject = subject
        self.is_receiving = True
예제 #4
0
    def make_real_cube(self, cube):
        """
        converting between data types, this one converts from python cube to ros cube
        """

        real_cube = Grid_Cube()
        real_cube.height = cube.height
        real_cube.connections = cube.connections
        real_cube.x = cube.x
        real_cube.y = cube.y
        real_cube.z = cube.z
        return real_cube
예제 #5
0
    def make_real_cube(self, cube):
        """
        converts between python class cube and ros data structure cube
        """

        real_cube = Grid_Cube()
        real_cube.height = cube.height
        real_cube.connections = cube.connections
        real_cube.x = cube.x
        real_cube.y = cube.y
        real_cube.z = cube.z
        return real_cube