def __init__(self,
                 blueprint=None,
                 ml_behavior=None,
                 observer=None,
                 evaluator=None,
                 step_time=None,
                 viewer=None,
                 scenario_generator=None,
                 render=False):

        if blueprint is not None:
            self._scenario_generator = blueprint._scenario_generation
            self._viewer = blueprint._viewer
            self._ml_behavior = blueprint._ml_behavior
            self._step_time = blueprint._dt
            self._evaluator = blueprint._evaluator
            self._observer = blueprint._observer
        Runtime.__init__(self,
                         step_time=step_time or self._step_time,
                         viewer=viewer or self._viewer,
                         scenario_generator=scenario_generator
                         or self._scenario_generator,
                         render=render)
        self._ml_behavior = ml_behavior or self._ml_behavior
        self._observer = observer or self._observer
        self._evaluator = evaluator or self._evaluator
Exemple #2
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
Exemple #3
0
    # 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.]

viewer = VideoRenderer(renderer=viewer,
                       world_step_time=sim_step_time,
                       fig_path="/tmp/video")

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

# Defining vehicles dynamics for RSS

# Input format:
# [longitudinal max acceleration, longitudinal max braking, longitudinal min acceleration,
# longitudinal min brake correct, lateral max acceleration, lateral min braking,
# lateral flucatuation_margin, agent response time]
#
# Detailed explanation please see:
# https://intel.github.io/ad-rss-lib/ad_rss/Appendix-ParameterDiscussion/#parameter-discussion

# Example of using RSS to evaluate the safety situation of the evaluating agent.
# The evaluating agent is defined with agent_id when initializing EvaluatorRSS.
Exemple #4
0
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]

# viewer = VideoRenderer(renderer=viewer,
#                        world_step_time=sim_step_time,
#                        fig_path="/home/hart/Dokumente/2020/bark/video")

# gym like interface
env = Runtime(step_time=0.2,
              viewer=viewer,
              scenario_generator=scenarios,
              render=True)
      


# run 3 scenarios
for episode in range(0, 1):
  env.reset()
  # step each scenario 20 times
  for step in range(0, 70):
    env.step()
    time.sleep(sim_step_time/sim_real_time_factor)

# viewer.export_video(filename="/home/hart/Dokumente/2020/bark/video/video", remove_image_dir=False)
    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,
                             logger=logger,
                             stream=custom_stream)
    bark_server.Start()