Пример #1
0
    def init_traps(self, scenario):
        self._traps.clear()
        trap_configs: Sequence[TrapConfig] = []

        for agent_id in scenario.missions:
            mission = scenario.missions[agent_id]
            mission_planner = MissionPlanner(scenario.waypoints,
                                             scenario.road_network)
            if mission is None:
                mission = mission_planner.random_endless_mission()

            if not mission.entry_tactic:
                mission = replace(mission, entry_tactic=default_entry_tactic())

            if (not isinstance(mission.entry_tactic, TrapEntryTactic)
                    and mission.entry_tactic):
                continue

            mission_planner.plan(mission)

            trap_config = self._mission2trap(scenario.road_network, mission)
            trap_configs.append((agent_id, trap_config))

        for agent_id, tc in trap_configs:
            trap = Trap(
                geometry=tc.zone.to_geometry(scenario.road_network),
                mission=tc.mission,
                exclusion_prefixes=tc.exclusion_prefixes,
                reactivation_time=tc.reactivation_time,
                remaining_time_to_reactivation=tc.activation_delay,
                patience=tc.patience,
            )
            self.add_trap_for_agent_id(agent_id, trap)
Пример #2
0
    def init_traps(self, road_network, waypoints, missions):
        self._traps.clear()

        for agent_id, mission in missions.items():
            mission_planner = MissionPlanner(waypoints, road_network)
            if mission is None:
                mission = mission_planner.random_endless_mission()

            if not mission.entry_tactic:
                mission = replace(mission, entry_tactic=default_entry_tactic())

            if (not isinstance(mission.entry_tactic, TrapEntryTactic)
                    and mission.entry_tactic):
                continue

            mission = mission_planner.plan(mission)

            trap = self._mission2trap(road_network, mission)
            self.add_trap_for_agent_id(agent_id, trap)