Esempio n. 1
0
def GetConfig(path):
    cfg = configparser.ConfigParser()
    cfg.read(path)

    name = cfg.get('Project', 'name')
    death_setup = cfg.get('Project', 'death_setup')
    unit_setup = cfg.get('Project', 'unit_setup')
    scenario_count = cfg.get('Project', 'scenario_count')  #테스트할 시나리오 갯수

    scenarios = []

    #각 테스트 시나리오는 Scenario 객체로 관리
    for i in range(int(scenario_count)):
        scen = Scenario('scenario_' + str(i))
        scen.SetScenario(cfg)
        scenarios.append(scen)

    #데스 테스트와 유닛 테스트의 파일 열
    with open(join(info_dir, death_setup), 'r') as setup:
        death_setup_file = setup.read()

    with open(join(info_dir, unit_setup), 'r') as setup:
        unit_setup_file = setup.read()

    #최종 설정들은 딕셔너리로 관리
    config = {
        'name': name,
        'death_setup': death_setup_file,
        'unit_setup': unit_setup_file,
        'scenario_count': scenario_count,
        'scenarios': scenarios
    }

    return config
def main(argv):

    # read factory settings
    factory_settings = FactorySettings('factory_settings.json')

    # create synthetic scene
    scene = {
        'X' : FLAGS.X,
        'Y' : FLAGS.Y,
        'Z' : FLAGS.Z,
        'SCALE' : FLAGS.SCALE,
        'DISTANCE' : FLAGS.DISTANCE,
        'ROT_X' : FLAGS.ROT_X,
        'ROT_Y' : FLAGS.ROT_Y,
        'ROT_Z' : FLAGS.ROT_Z,
        'MIN' : FLAGS.MIN,
        'MAX' : FLAGS.MAX,
        'POINTS': FLAGS.POINTS
    }
    points = Scene(SceneType.cube, scene)
    points.visualize()

    logging.info('Create Scencario')

    changes = []
    changes += [Change(ChangeType.translation, 20, [10, 0, 0])]
    changes += [Change(ChangeType.translation, 30, [0, 10, 0])]
    changes += [Change(ChangeType.translation, 40, [0 , 0, 10])]
    changes += [Change(ChangeType.rotation, 50, [3, 0, 0])]
    changes += [Change(ChangeType.rotation, 60, [0, 3, 0])]
    changes += [Change(ChangeType.rotation, 70, [0, 0, 3])]

    # create scneario
    scenario = Scenario(100, changes, points, factory_settings, (752, 480), FLAGS.NOISE)
    scenario.generate_sequence()
Esempio n. 3
0
    def _compare_image_to_pickle(self, image, saved_picklable_image):
        """
        Compare the image to the saved_picklable_image.

        To do this, the image is loaded and prepared for pickling before
        being compared to the saved_picklable_image.

        We cant compare surfaces for equality directly so we have to use
        the  picklable representation.
        """
        # Load the image
        surface = pygame.image.load(image)
        # Prepare the image for pickling
        picklable_surface = Scenario.format_surface_for_pickle(surface)
        # Compare the picklable given image with the saved picklable image
        self.assertEqual(picklable_surface, saved_picklable_image)
def main():
    """Write a scibot file."""
    # Initalises a new scenario object and sets the scenario name.
    scenario = Scenario("Default")

    # Tthe size of an individual square
    scenario.set_board_step(150)

    # Sets the width of the map in terms of squares
    scenario.set_logical_width(5)
    # Sets the height of the map in terms of squares
    scenario.set_logical_height(8)

    # Sets the bee bot starting square (x, y)
    scenario.set_beebot_start_position(3, 1)

    # Set the beebot sprite
    scenario.set_beebot_sprite("./img/Default/robot.jpg")
    # Sets the beebots starting direction, where "UP" is "Heading.NORTH",
    # other options are Heading.East etc
    scenario.set_beebot_heading(Heading.NORTH)

    # Sets the image on the map
    scenario.set_background("./img/Default/background.jpg")
    # If the image has no grid, one can be added by choosing a (R,G,B) tuple
    scenario.set_border_colour((0, 0, 0))

    # This line addes an obstacle at square (2,1)
    # with sprite "./img/Default/obstacle1.jpg".
    # scenario.addObstacle(2,1) would add an obstacle at (2,1) with no sprite,
    # ie it will show whatever is on the background
    scenario.add_obstacle(2, 1, "./img/Default/obstacle1.jpg")
    # Add another obstacle
    scenario.add_obstacle(2, 3, "./img/Default/obstacle1.jpg")

    # Adds a goal square at (1,2) with sprite "./img/Default/goal1.jpg"
    scenario.add_goal(1, 2, "./img/Default/goal1.jpg")
    # add another goal
    scenario.add_goal(2, 0, "./img/Default/goal1.jpg")

    # This method means the goals must be met in the order added (Default)
    # scenario.set_ordered_goals(True)
    # This method means the goals can be met in any order
    scenario.set_ordered_goals(False)

    # Sets the sprite to be displayed when the robot crashes
    scenario.set_beebot_fail_sprite("./img/Default/robotx.jpg")

    # Copy the LICENSE from below into the Scenario
    scenario.set_license(LICENSE)

    # Writes the scibot file
    scenario.write_to_file()
Esempio n. 5
0
    def setUp(self):
        """
        Create a minimal Scenario and use it to create a BeeBot.

        The Scenario is 5x5 (logical and pixel size)
        with the BeeBot in the centre, and no Obstacles or Goals.
        """
        # Create the minimal Scenario
        test_scenario = Scenario('Test')
        test_scenario.set_board_step(1)
        test_scenario.set_logical_width(5)
        test_scenario.set_logical_height(5)
        test_scenario.set_beebot_start_position(2, 2)
        test_scenario.set_beebot_sprite('img/Default/robot.jpg')
        # Create the test BeeBot
        self.test_robot = BeeBot(test_scenario)
Esempio n. 6
0
    def setUp(self):
        scenario = Scenario('Test')
        scenario.set_board_step(150)
        scenario.set_logical_width(5)
        scenario.set_logical_height(8)
        scenario.set_beebot_start_position(3, 1)
        scenario.set_beebot_sprite('./img/Default/robot.jpg')
        scenario.set_beebot_heading(Heading.NORTH)
        scenario.set_background('./img/Default/background.jpg')
        scenario.set_border_colour((0, 0, 0))
        scenario.add_obstacle(2, 1)
        scenario.add_obstacle(2, 3)
        scenario.add_goal(1, 2)
        scenario.add_goal(2, 0)
        scenario.set_ordered_goals(False)
        scenario.set_beebot_fail_sprite('./img/Default/robotx.jpg')
        scenario.set_license('Test License')

        # Writes the scibot file
        scenario.write_to_file()
def main():
    """Write a scibot file."""
    # Initalises a new scenario object and sets the scenario name.
    scenario = Scenario("Default")

    # Tthe size of an individual square
    scenario.set_board_step(150)

    # Sets the width of the map in terms of squares
    scenario.set_logical_width(5)
    # Sets the height of the map in terms of squares
    scenario.set_logical_height(8)

    # Sets the bee bot starting square (x, y)
    scenario.set_beebot_start_position(3, 1)

    # Set the beebot sprite
    scenario.set_beebot_sprite("./img/Default/robot.jpg")
    # Sets the beebots starting direction, where "UP" is "Heading.NORTH",
    # other options are Heading.East etc
    scenario.set_beebot_heading(Heading.NORTH)

    # Sets the image on the map
    scenario.set_background("./img/Default/background.jpg")
    # If the image has no grid, one can be added by choosing a (R,G,B) tuple
    scenario.set_border_colour((0, 0, 0))

    # This line addes an obstacle at square (2,1)
    # with sprite "./img/Default/obstacle1.jpg".
    # scenario.addObstacle(2,1) would add an obstacle at (2,1) with no sprite,
    # ie it will show whatever is on the background
    scenario.add_obstacle(2, 1, "./img/Default/obstacle1.jpg")
    # Add another obstacle
    scenario.add_obstacle(2, 3, "./img/Default/obstacle1.jpg")

    # Adds a goal square at (1,2) with sprite "./img/Default/goal1.jpg"
    scenario.add_goal(1, 2, "./img/Default/goal1.jpg")
    # add another goal
    scenario.add_goal(2, 0, "./img/Default/goal1.jpg")

    # This method means the goals must be met in the order added (Default)
    # scenario.set_ordered_goals(True)
    # This method means the goals can be met in any order
    scenario.set_ordered_goals(False)

    # Sets the sprite to be displayed when the robot crashes
    scenario.set_beebot_fail_sprite("./img/Default/robotx.jpg")

    # Copy the LICENSE from below into the Scenario
    scenario.set_license(LICENSE)

    # Writes the scibot file
    scenario.write_to_file()
Esempio n. 8
0
    def setUp(self):
        """
        Create a minimal Scenario and use it to create a Board.

        The Scenario is 5x5 (logical size) with the no BeeBot,
        but one Obstacle and Goal.
        """
        # Create the minimal Scenario
        test_scenario = Scenario('Test')
        test_scenario.set_board_step(150)
        test_scenario.set_logical_width(5)
        test_scenario.set_logical_height(8)
        test_scenario.set_background('img/Default/background.jpg')
        test_scenario.add_goal(0, 0)
        test_scenario.add_obstacle(1, 1)

        # Create the test Board
        self.test_board = Board(test_scenario)