def __init__(self,
              params=ParameterServer(),
              eval_agent=None,
              bark_eval_fns=None,
              bark_ml_eval_fns=None):
   self._eval_agent = eval_agent
   self._params = params["ML"]["GeneralEvaluator"]
   self._bark_eval_fns = bark_eval_fns or {
     "goal_reached" : lambda: EvaluatorGoalReached(),
     "collision" : lambda: EvaluatorCollisionEgoAgent(),
     "step_count" : lambda: EvaluatorStepCount(),
     "drivable_area" : lambda: EvaluatorDrivableArea()
   }
   self._bark_ml_eval_fns = bark_ml_eval_fns or {
     "collision_functor" : CollisionFunctor(self._params),
     "goal_functor" : GoalFunctor(self._params),
     "low_speed_goal_reached_functor" : LowSpeedGoalFunctor(self._params),
     "drivable_area_functor" : DrivableAreaFunctor(self._params),
     "step_count_functor" : StepCountFunctor(self._params),
     "smoothness_functor" : SmoothnessFunctor(self._params),
     "min_max_vel_functor" : MinMaxVelFunctor(self._params),
     # "pot_center_functor": PotentialCenterlineFunctor(self._params),
     # "pot_vel_functor": PotentialVelocityFunctor(self._params),
     "pot_goal_center_functor": PotentialGoalCenterlineFunctor(self._params),
     # "pot_goal_switch_vel_functor": PotentialGoalSwitchVelocityFunctor(self._params)
     # "state_action_logging_functor": StateActionLoggingFunctor(self._params)
   }
Esempio n. 2
0
 def _add_evaluators(self):
     evaluators = {}
     evaluators["goal_reached"] = EvaluatorGoalReached()
     evaluators["collision"] = EvaluatorCollisionEgoAgent()
     evaluators["step_count"] = EvaluatorStepCount()
     evaluators["drivable_area"] = EvaluatorDrivableArea()
     return evaluators
 def _add_evaluators(self):
     """Evaluators that will be set in the BARK world"""
     self._evaluators["goal_reached"] = EvaluatorGoalReached()
     self._evaluators["collision"] = EvaluatorCollisionEgoAgent()
     self._evaluators["step_count"] = EvaluatorStepCount()
     self._evaluators["drivable_area"] = EvaluatorDrivableArea()
Esempio n. 4
0
    def test_evaluator_drivable_area(self):
        # World Definition
        params = ParameterServer()
        world = World(params)

        # Model Definitions
        behavior_model = BehaviorConstantAcceleration(params)
        execution_model = ExecutionModelInterpolate(params)
        dynamic_model = SingleTrackModel(params)

        # Map Definition
        map_interface = MapInterface()
        xodr_map = MakeXodrMapOneRoadTwoLanes()
        map_interface.SetOpenDriveMap(xodr_map)
        world.SetMap(map_interface)
        #open_drive_map = world.map.GetOpenDriveMap()

        #agent_2d_shape = CarLimousine()
        agent_2d_shape = Polygon2d(
            [1.25, 1, 0],
            [Point2d(-1, -1),
             Point2d(-1, 1),
             Point2d(3, 1),
             Point2d(3, -1)])
        init_state = np.array([0, 3, -1.75, 0, 5])
        agent_params = params.AddChild("agent1")
        goal_polygon = Polygon2d(
            [1, 1, 0],
            [Point2d(0, 0),
             Point2d(0, 2),
             Point2d(2, 2),
             Point2d(2, 0)])
        goal_polygon = goal_polygon.Translate(Point2d(50, -2))

        agent = Agent(
            init_state,
            behavior_model,
            dynamic_model,
            execution_model,
            agent_2d_shape,
            agent_params,
            GoalDefinitionPolygon(goal_polygon),  # goal_lane_id
            map_interface)
        world.AddAgent(agent)

        evaluator = EvaluatorDrivableArea()
        world.AddEvaluator("drivable_area", evaluator)

        info = world.Evaluate()
        self.assertFalse(info["drivable_area"])

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

        # Draw map
        viewer.drawGoalDefinition(goal_polygon,
                                  color=(1, 0, 0),
                                  alpha=0.5,
                                  facecolor=(1, 0, 0))
        viewer.drawWorld(world)
        viewer.drawRoadCorridor(agent.road_corridor)
        viewer.show(block=False)