Beispiel #1
0
def GenerateRuntime():
    # parameters
    param_server = ParameterServer()
    # configure both lanes of the highway. the right lane has one controlled agent
    left_lane = CustomLaneCorridorConfig(params=param_server,
                                        lane_corridor_id=0,
                                        road_ids=[0, 1],
                                        behavior_model=BehaviorMobilRuleBased(param_server),
                                        s_min=5.,
                                        s_max=50.)
    right_lane = CustomLaneCorridorConfig(params=param_server,
                                          lane_corridor_id=1,
                                          road_ids=[0, 1],
                                          controlled_ids=True,
                                          behavior_model=BehaviorMobilRuleBased(param_server),
                                          s_min=5.,
                                          s_max=20.)
    scenarios = \
      ConfigWithEase(num_scenarios=3,
                    map_file_name=Data.xodr_data("DR_DEU_Merging_MT_v01_shifted"),
                    random_seed=0,
                    params=param_server,
                    lane_corridor_configs=[left_lane, right_lane])
    # viewer
    viewer = MPViewer(params=param_server,
                      x_range=[-35, 35],
                      y_range=[-35, 35],
                      follow_agent_id=True)
    env = Runtime(step_time=0.2,
                  viewer=viewer,
                  scenario_generator=scenarios,
                  render=True,
                  maintain_world_history=True)
    return env
Beispiel #2
0
    def __init__(self,
                 params=None,
                 number_of_senarios=250,
                 random_seed=0,
                 ml_behavior=None,
                 viewer=True):
        params["BehaviorIDMClassic"]["BrakeForLaneEnd"] = True
        params["BehaviorIDMClassic"]["BrakeForLaneEndEnabledDistance"] = 100.
        params["BehaviorIDMClassic"]["BrakeForLaneEndDistanceOffset"] = 25.
        params["BehaviorIDMClassic"]["DesiredVelocity"] = 12.5
        params["World"]["remove_agents_out_of_map"] = False
        left_lane = MergingLaneCorridorConfig(params=params,
                                              road_ids=[0, 1],
                                              min_vel=10.,
                                              max_vel=15.,
                                              s_min=5.,
                                              s_max=25.,
                                              lane_corridor_id=0,
                                              controlled_ids=None)
        right_lane = MergingLaneCorridorConfig(
            params=params,
            road_ids=[0, 1],
            lane_corridor_id=1,
            s_min=5.,
            s_max=25.,
            min_vel=8.,
            max_vel=12.,
            behavior_model=BehaviorIDMClassic(params),
            controlled_ids=True)
        scenario_generation = \
          ConfigWithEase(
            num_scenarios=number_of_senarios,
            map_file_name=os.path.join(os.path.dirname(__file__), "../../../environments/blueprints/merging/DR_DEU_Merging_MT_v01_shifted.xodr"),  # NOLINT
            random_seed=random_seed,
            params=params,
            lane_corridor_configs=[left_lane, right_lane])
        if viewer:
            viewer = MPViewer(params=params,
                              x_range=[-35, 35],
                              y_range=[-35, 35],
                              follow_agent_id=True)
        dt = 0.2
        evaluator = GoalReachedGuiding(params)
        # evaluator = GoalReached(params)
        observer = NearestObserver(params)
        ml_behavior = ml_behavior

        super().__init__(scenario_generation=scenario_generation,
                         viewer=viewer,
                         dt=dt,
                         evaluator=evaluator,
                         observer=observer,
                         ml_behavior=ml_behavior)
Beispiel #3
0
  def __init__(self,
               params=None,
               number_of_senarios=250,
               random_seed=0,
               ml_behavior=None,
               viewer=True):

    params["BehaviorIDMClassic"]["DesiredVelocity"] = 30.
    left_lane = HighwayLaneCorridorConfig(params=params,
                                          road_ids=[16],
                                          lane_corridor_id=0,
                                          min_vel=25.0,
                                          max_vel=30.0,
                                          controlled_ids=None)
    right_lane = HighwayLaneCorridorConfig(params=params,
                                           road_ids=[16],
                                           lane_corridor_id=1,
                                           min_vel=25.0,
                                           max_vel=30.0,
                                           controlled_ids=True)
    scenario_generation = \
      ConfigWithEase(
        num_scenarios=number_of_senarios,
        map_file_name=os.path.join(os.path.dirname(__file__), "../../../environments/blueprints/highway/city_highway_straight.xodr"),  # NOLINT
        random_seed=random_seed,
        params=params,
        lane_corridor_configs=[left_lane, right_lane])
    if viewer:
      viewer = MPViewer(params=params,
                        x_range=[-35, 35],
                        y_range=[-35, 35],
                        follow_agent_id=True)
    dt = 0.2
    evaluator = GoalReachedGuiding(params)
    observer = NearestObserver(params)
    ml_behavior = ml_behavior

    super().__init__(
      scenario_generation=scenario_generation,
      viewer=viewer,
      dt=dt,
      evaluator=evaluator,
      observer=observer,
      ml_behavior=ml_behavior)
Beispiel #4
0
    behavior_model=BehaviorMobilRuleBased(param_server),
    s_min=5.,
    s_max=50.)
right_lane = CustomLaneCorridorConfig(
    params=param_server,
    lane_corridor_id=1,
    road_ids=[0, 1],
    controlled_ids=True,
    behavior_model=BehaviorMobilRuleBased(param_server),
    s_min=5.,
    s_max=20.)

scenarios = \
    ConfigWithEase(num_scenarios=3,
                   map_file_name=Data.xodr_data("DR_DEU_Merging_MT_v01_centered"),
                   random_seed=0,
                   params=param_server,
                   lane_corridor_configs=[left_lane, right_lane])

# viewer
viewer = MPViewer(
    params=param_server,
    # x_range=[-35, 35],
    # y_range=[-35, 35],
    follow_agent_id=False)

sim_step_time = param_server["simulation"]["step_time",
                                           "Step-time used in simulation",
                                           0.05]
sim_real_time_factor = param_server["simulation"][
    "real_time_factor", "execution in real-time or faster", 1.]
Beispiel #5
0
# configure both lanes of the highway. the right lane has one controlled agent
left_lane = HighwayLaneCorridorConfig(params=param_server,
                                      road_ids=[16],
                                      lane_corridor_id=0)
right_lane = HighwayLaneCorridorConfig(params=param_server,
                                       road_ids=[16],
                                       lane_corridor_id=1,
                                       controlled_ids=True)

# create 5 scenarios
scenarios = \
  ConfigWithEase(
    num_scenarios=5,
    map_file_name=os.path.join(
      os.path.dirname(__file__),
      "../bark/runtime/tests/data/city_highway_straight.xodr"),
    random_seed=0,
    params=param_server,
    lane_corridor_configs=[left_lane, right_lane])

# viewer
viewer = MPViewer(params=param_server,
                  x_range=[-75, 75],
                  y_range=[-75, 75],
                  follow_agent_id=True)

sim_step_time = param_server["simulation"]["step_time",
                                          "Step-time used in simulation",
                                          0.05]
sim_real_time_factor = param_server["simulation"][
  "real_time_factor",
        road_ids=[0, 1],
        behavior_model=BehaviorMobilRuleBased(param_server),
        s_min=5.,
        s_max=50.)
    right_lane = CustomLaneCorridorConfig(
        params=param_server,
        lane_corridor_id=1,
        road_ids=[0, 1],
        controlled_ids=True,
        behavior_model=BehaviorMobilRuleBased(param_server),
        s_min=5.,
        s_max=20.)
    scenarios = \
      ConfigWithEase(num_scenarios=3,
                    map_file_name="examples/data/DR_DEU_Merging_MT_v01_shifted.xodr",
                    random_seed=0,
                    params=param_server,
                    lane_corridor_configs=[left_lane, right_lane])

    viewer = BufferedViewer()
    env = Runtime(step_time=0.2,
                  viewer=viewer,
                  scenario_generator=scenarios,
                  render=True,
                  maintain_world_history=True)

    # run BARKSCAPE
    logger = logging.getLogger()
    custom_stream = CustomStream(logger=logger)
    bark_server = BaseServer(runner=BARKRunner,
                             runnable_object=env,
            params=param_server,
            source_pos=[3, -30],
            sink_pos=[-30, 3],
            behavior_model=BehaviorIntersectionRuleBased(param_server),
            controlled_ids=True,
            min_vel=5.,
            max_vel=5.,
            ds_min=5.,
            ds_max=10.,
            s_min=15.,
            s_max=30.))

    scenarios = \
      ConfigWithEase(num_scenarios=3,
                    map_file_name=Data.xodr_data("threeway_intersection"),
                    random_seed=0,
                    params=param_server,
                    lane_corridor_configs=lane_corridors)

    viewer = BufferedViewer()
    env = Runtime(step_time=0.2,
                  viewer=viewer,
                  scenario_generator=scenarios,
                  render=True,
                  maintain_world_history=True)

    # run BARKSCAPE
    logger = logging.getLogger()
    bark_server = BaseServer(runner=BARKRunner,
                             runnable_object=env,
                             logger=logger)
Beispiel #8
0

# configure both lanes of the highway. the right lane has one controlled agent
left_lane = HighwayLaneCorridorConfig(params=param_server,
                                      road_ids=[16],
                                      lane_corridor_id=0)
right_lane = HighwayLaneCorridorConfig(params=param_server,
                                       road_ids=[16],
                                       lane_corridor_id=1,
                                       controlled_ids=True)

# create 5 scenarios
scenarios = \
    ConfigWithEase(
        num_scenarios=5,
        map_file_name=Data.xodr_data("city_highway_straight"),
        random_seed=0,
        params=param_server,
        lane_corridor_configs=[left_lane, right_lane])

# viewer
viewer = MPViewer(params=param_server,
                  x_range=[-75, 75],
                  y_range=[-75, 75],
                  follow_agent_id=True)

sim_step_time = param_server["simulation"]["step_time",
                                           "Step-time used in simulation",
                                           0.05]
sim_real_time_factor = param_server["simulation"][
    "real_time_factor", "execution in real-time or faster", 0.5]
Beispiel #9
0
    def __init__(self,
                 params=None,
                 num_scenarios=250,
                 random_seed=0,
                 ml_behavior=None,
                 viewer=True,
                 mode="medium"):
        if mode == "dense":
            ds_min = 15.
            ds_max = 30.
        if mode == "medium":
            ds_min = 20.
            ds_max = 35.
        params["World"]["remove_agents_out_of_map"] = False

        ego_lane_id = 2
        lane_configs = []
        for i in range(0, 4):
            is_controlled = True if (ego_lane_id == i) else None
            s_min = 0
            s_max = 250
            if is_controlled == True:
                s_min = 40.
                s_max = 80.
            local_params = params.clone()
            local_params["BehaviorIDMClassic"][
                "DesiredVelocity"] = np.random.uniform(12, 17)
            lane_conf = HighwayLaneCorridorConfig(params=local_params,
                                                  road_ids=[16],
                                                  lane_corridor_id=i,
                                                  min_vel=12.5,
                                                  max_vel=17.5,
                                                  ds_min=ds_min,
                                                  ds_max=ds_max,
                                                  s_min=s_min,
                                                  s_max=s_max,
                                                  controlled_ids=is_controlled)
            lane_configs.append(lane_conf)

        scenario_generation = \
          ConfigWithEase(
            num_scenarios=num_scenarios,
            map_file_name=os.path.join(os.path.dirname(__file__), "../../../environments/blueprints/highway/round_highway.xodr"),  # pylint: disable=unused-import
            random_seed=random_seed,
            params=params,
            lane_corridor_configs=lane_configs)
        if viewer:
            # viewer = MPViewer(params=params,
            #                   use_world_bounds=True)
            viewer = BufferedMPViewer(params=params,
                                      x_range=[-55, 55],
                                      y_range=[-55, 55],
                                      follow_agent_id=True)
        dt = 0.2
        params["ML"]["RewardShapingEvaluator"]["PotentialVelocityFunctor"][
            "DesiredVel", "Desired velocity for the ego agent.", 20]
        evaluator = RewardShapingEvaluator(params)
        observer = NearestObserver(params)
        ml_behavior = ml_behavior

        super().__init__(scenario_generation=scenario_generation,
                         viewer=viewer,
                         dt=dt,
                         evaluator=evaluator,
                         observer=observer,
                         ml_behavior=ml_behavior)
Beispiel #10
0
        params=param_server,
        source_pos=[3, -30],
        sink_pos=[-30, 3],
        behavior_model=BehaviorIntersectionRuleBased(param_server),
        controlled_ids=True,
        min_vel=5.,
        max_vel=5.,
        ds_min=5.,
        ds_max=10.,
        s_min=15.,
        s_max=30.))

scenarios = \
  ConfigWithEase(num_scenarios=3,
                 map_file_name= os.path.join(os.path.dirname(__file__),
                 "../bark/runtime/tests/data/threeway_intersection.xodr"),
                 random_seed=0,
                 params=param_server,
                 lane_corridor_configs=lane_corridors)

# viewer
viewer = MPViewer(params=param_server, use_world_bounds=True)

# viewer = Panda3dViewer(params=param_server,
#                        x_range=[-40, 40],
#                        y_range=[-40, 40],
#                        follow_agent_id=agent3.id)

# World Simulation
sim_step_time = param_server["simulation"]["step_time",
                                           "Step-time used in simulation", 0.2]
sim_real_time_factor = param_server["simulation"][
Beispiel #11
0
    s_min=5.,
    s_max=50.)
right_lane = CustomLaneCorridorConfig(
    params=param_server,
    lane_corridor_id=1,
    road_ids=[0, 1],
    controlled_ids=True,
    behavior_model=BehaviorMobilRuleBased(param_server),
    s_min=5.,
    s_max=20.)

scenarios = \
  ConfigWithEase(num_scenarios=3,
                 map_file_name=os.path.join(
                   os.path.dirname(__file__),
                   "../bark/runtime/tests/data/DR_DEU_Merging_MT_v01_shifted.xodr"),
                 random_seed=0,
                 params=param_server,
                 lane_corridor_configs=[left_lane, right_lane])

# viewer
viewer = MPViewer(params=param_server,
                  x_range=[-35, 35],
                  y_range=[-35, 35],
                  follow_agent_id=True)
# viewer = Panda3dViewer(params=param_server,
#                        x_range=[-40, 40],
#                        y_range=[-40, 40],
#                        follow_agent_id=True,
#                        light_pose=[1000, 1000, 100000],
#                        camera_pose=[1000, 980, 100])
Beispiel #12
0
    def __init__(self,
                 params=None,
                 num_scenarios=250,
                 random_seed=0,
                 ml_behavior=None,
                 viewer=True):
        lane_corridors = []
        lane_corridors.append(
            IntersectionLaneCorridorConfig(
                params=params,
                source_pos=[-40, -3],
                sink_pos=[40, -3],
                behavior_model=BehaviorMobilRuleBased(params),
                min_vel=10.,
                max_vel=12.,
                ds_min=10.,
                ds_max=25.,
                s_min=5.,
                s_max=50.,
                controlled_ids=None))
        lane_corridors.append(
            IntersectionLaneCorridorConfig(
                params=params,
                source_pos=[40, 3],
                sink_pos=[-40, 3],
                behavior_model=BehaviorMobilRuleBased(params),
                min_vel=10.,
                max_vel=12.,
                ds_min=15.,
                ds_max=25.,
                s_min=5.,
                s_max=50.,
                controlled_ids=None))
        lane_corridors.append(
            IntersectionLaneCorridorConfig(
                params=params,
                source_pos=[3, -30],
                sink_pos=[-40, 3],
                behavior_model=BehaviorMobilRuleBased(params),
                min_vel=5.,
                max_vel=10.,
                ds_min=40.,
                ds_max=40.,
                s_min=30.,
                s_max=40.,
                controlled_ids=True))

        scenario_generation = \
          ConfigWithEase(
            num_scenarios=num_scenarios,
            map_file_name=os.path.join(os.path.dirname(__file__), "../../../environments/blueprints/intersection/4way_intersection.xodr"),  # pylint: disable=unused-import
            random_seed=random_seed,
            params=params,
            lane_corridor_configs=lane_corridors)
        if viewer:
            viewer = BufferedMPViewer(params=params,
                                      x_range=[-30, 30],
                                      y_range=[-30, 30],
                                      follow_agent_id=True)
        dt = 0.2

        params["ML"]["RewardShapingEvaluator"]["PotentialVelocityFunctor"][
            "DesiredVel", "Desired velocity for the ego agent.", 6]
        evaluator = RewardShapingEvaluator(params)
        observer = NearestAgentsObserver(params)
        ml_behavior = ml_behavior

        super().__init__(scenario_generation=scenario_generation,
                         viewer=viewer,
                         dt=dt,
                         evaluator=evaluator,
                         observer=observer,
                         ml_behavior=ml_behavior)
Beispiel #13
0
    s_max=50.)
right_lane = CustomLaneCorridorConfig(
    params=param_server,
    lane_corridor_id=1,
    road_ids=[0, 1],
    controlled_ids=True,
    behavior_model=BehaviorMobilRuleBased(param_server),
    s_min=5.,
    s_max=20.)

map_path = "bark/runtime/tests/data/DR_DEU_Merging_MT_v01_centered.xodr"

scenarios = \
    ConfigWithEase(num_scenarios=3,
                   map_file_name=map_path,
                   random_seed=0,
                   params=param_server,
                   lane_corridor_configs=[left_lane, right_lane])

# viewer
viewer = MPViewer(
    params=param_server,
    # x_range=[-35, 35],
    # y_range=[-35, 35],
    follow_agent_id=False)
# viewer = Panda3dViewer(params=param_server,
#                        x_range=[-40, 40],
#                        y_range=[-40, 40],
#                        follow_agent_id=True,
#                        light_pose=[1000, 1000, 100000],
#                        camera_pose=[1000, 980, 100])
Beispiel #14
0
    def __init__(self,
                 params=None,
                 number_of_senarios=250,
                 random_seed=0,
                 ml_behavior=None,
                 viewer=True):
        lane_corridors = []
        lane_corridors.append(
            IntersectionLaneCorridorConfig(
                params=params,
                source_pos=[-40, -3],
                sink_pos=[40, -3],
                behavior_model=BehaviorIntersectionRuleBased(params),
                min_vel=10.,
                max_vel=15.,
                ds_min=10.,
                ds_max=15.,
                s_min=5.,
                s_max=50.,
                controlled_ids=None))
        lane_corridors.append(
            IntersectionLaneCorridorConfig(
                params=params,
                source_pos=[40, 3],
                sink_pos=[-40, 3],
                behavior_model=BehaviorIntersectionRuleBased(params),
                min_vel=10.,
                max_vel=15.,
                ds_min=15.,
                ds_max=15.,
                s_min=5.,
                s_max=50.,
                controlled_ids=None))
        lane_corridors.append(
            IntersectionLaneCorridorConfig(
                params=params,
                source_pos=[3, -30],
                sink_pos=[-40, 3],
                behavior_model=BehaviorIntersectionRuleBased(params),
                min_vel=5.,
                max_vel=10.,
                ds_min=10.,
                ds_max=15.,
                s_min=10.,
                s_max=25.,
                controlled_ids=True))

        scenario_generation = \
          ConfigWithEase(
            num_scenarios=number_of_senarios,
            map_file_name=os.path.join(os.path.dirname(__file__), "../../../environments/blueprints/intersection/4way_intersection.xodr"),  # NOLINT
            random_seed=random_seed,
            params=params,
            lane_corridor_configs=lane_corridors)
        if viewer:
            viewer = MPViewer(params=params,
                              x_range=[-35, 35],
                              y_range=[-35, 35],
                              follow_agent_id=True)
        dt = 0.2
        evaluator = GoalReached(params)
        observer = NearestObserver(params)
        ml_behavior = ml_behavior

        super().__init__(scenario_generation=scenario_generation,
                         viewer=viewer,
                         dt=dt,
                         evaluator=evaluator,
                         observer=observer,
                         ml_behavior=ml_behavior)
Beispiel #15
0
    def __init__(self,
                 params=None,
                 num_scenarios=250,
                 random_seed=0,
                 ml_behavior=None,
                 viewer=True,
                 mode="dense"):
        params["BehaviorIDMClassic"]["BrakeForLaneEnd"] = True
        params["BehaviorIDMClassic"]["BrakeForLaneEndEnabledDistance"] = 100.
        params["BehaviorIDMClassic"]["BrakeForLaneEndDistanceOffset"] = 30.
        params["BehaviorIDMClassic"]["DesiredVelocity"] = 10.
        params["World"]["remove_agents_out_of_map"] = False
        # TODO: modify dense
        # ds_min and ds_max
        if mode == "dense":
            ds_min = 7.
            ds_max = 12.
        if mode == "medium":
            ds_min = 12.
            ds_max = 17.
        left_lane = MergingLaneCorridorConfig(params=params,
                                              road_ids=[0, 1],
                                              ds_min=ds_min,
                                              ds_max=ds_max,
                                              min_vel=9.,
                                              max_vel=11.,
                                              s_min=5.,
                                              s_max=45.,
                                              lane_corridor_id=0,
                                              controlled_ids=None)
        right_lane = MergingLaneCorridorConfig(params=params,
                                               road_ids=[0, 1],
                                               lane_corridor_id=1,
                                               ds_min=ds_min,
                                               ds_max=ds_max,
                                               s_min=5.,
                                               s_max=25.,
                                               min_vel=9.,
                                               max_vel=11.,
                                               controlled_ids=True)
        scenario_generation = \
          ConfigWithEase(
            num_scenarios=num_scenarios,
            map_file_name=os.path.join(os.path.dirname(__file__), "../../../environments/blueprints/merging/DR_DEU_Merging_MT_v01_centered.xodr"),  # pylint: disable=unused-import
            random_seed=random_seed,
            params=params,
            lane_corridor_configs=[left_lane, right_lane])
        if viewer:
            viewer = BufferedMPViewer(params=params,
                                      x_range=[-25, 25],
                                      y_range=[-25, 25],
                                      follow_agent_id=True)
        dt = 0.2
        params["ML"]["RewardShapingEvaluator"]["PotentialVelocityFunctor"][
            "DesiredVel", "Desired velocity for the ego agent.", 20]
        evaluator = RewardShapingEvaluator(params)
        observer = NearestAgentsObserver(params)
        ml_behavior = ml_behavior

        super().__init__(scenario_generation=scenario_generation,
                         viewer=viewer,
                         dt=dt,
                         evaluator=evaluator,
                         observer=observer,
                         ml_behavior=ml_behavior)