def _create_map_1(env):
    #obs_movement = MovementPattern.StaticMovement((0,0))
    #obs = DynamicObstacle(obs_movement)
    #obs.fillcolor = (0x55, 0x55, 0x55)
    #obs.shape = 4
    #obs.polygon = Polygon([
    #	(640, 80),
    #	(640, 480),
    #	(445, 450),
    #	(408, 300),
    #	(408, 165),
    #	(460, 108),
    #	(490, 104),
    #	(490, 91),
    #	(640, 80),
    #]);
    with open('obs2.json') as f:
        obslist = json.load(f)

    for obs in obslist:
        obs_movement = MovementPattern.StaticMovement((0, 0))
        if obs['type'] == 'circle':
            obs_movement = MovementPattern.StaticMovement(obs['center'])
            obs2 = DynamicObstacle(obs_movement)
            obs2.shape = 1
            obs2.radius = obs['radius']
            obs2.fillcolor = (0x55, 0x55, 0x55)
            env.static_obstacles.append(obs2)
            continue
        polygon = Polygon(np.array(obs['points']))
        obs2 = DynamicObstacle(obs_movement)
        obs2.shape = 4
        obs2.polygon = polygon
        obs2.fillcolor = (0x55, 0x55, 0x55)
        env.static_obstacles.append(obs2)
def make_default_robot(robot_name, path_color):
    start_point = Target(
        (np.random.randint(50, 350), np.random.randint(350, 550)),
        radius=20,
        color=0x00FF00)
    initial_position = np.array(start_point.position)
    target = Target((np.random.randint(600, 760), np.random.randint(50, 250)),
                    radius=20)
    objective = NavigationObjective(target, env)

    env.non_interactive_objects += [start_point, target]

    robot = Robot(initial_position,
                  cmdargs,
                  env,
                  path_color=path_color,
                  name=robot_name,
                  objective=objective)
    robot.put_sensor('radar', RadarSensor(env, robot, [], radar))
    robot.put_sensor('gps', GpsSensor(robot))
    if robot_name in params['robots']:
        robot.put_sensor('params', params['robots'][robot_name])
    else:
        robot.put_sensor('params', {})

    robot_obstacle = DynamicObstacle(MovementPattern.RobotBodyMovement(robot))
    robot_obstacle.shape = 1
    robot_obstacle.radius = 10
    robot_obstacle.fillcolor = (0xcc, 0x88, 0x44)
    robot.set_obstacle(robot_obstacle)

    return robot, target
Ejemplo n.º 3
0
def _create_obs_from_spec(obs_spec):
    obs_movement = MovementPattern.StaticMovement((0, 0))
    if obs_spec['type'] == 'circle':
        obs_movement = MovementPattern.StaticMovement(obs_spec['center'])
        new_obs = DynamicObstacle(obs_movement)
        new_obs.shape = 1
        new_obs.radius = obs_spec['radius']
        new_obs.fillcolor = (0x55, 0x55, 0x55)
        return new_obs

    polygon = Polygon(np.array(obs_spec['points']))
    new_obs = DynamicObstacle(obs_movement)
    new_obs.shape = 4
    new_obs.polygon = polygon
    new_obs.fillcolor = (0x55, 0x55, 0x55)
    return new_obs
def _create_map_2(env):
    with open('obs2.json') as f:
        obslist = json.load(f)

    for obs in obslist:
        obs_movement = MovementPattern.StaticMovement((0, 0))
        if obs['type'] == 'circle':
            obs_movement = MovementPattern.StaticMovement(obs['center'])
            obs2 = DynamicObstacle(obs_movement)
            obs2.shape = 1
            obs2.radius = obs['radius']
            obs2.fillcolor = (0x55, 0x55, 0x55)
            env.static_obstacles.append(obs2)
            continue
        polygon = Polygon(np.array(obs['points']))
        obs2 = DynamicObstacle(obs_movement)
        obs2.shape = 4
        obs2.polygon = polygon
        obs2.fillcolor = (0x55, 0x55, 0x55)
        env.static_obstacles.append(obs2)