From 66f71484dd5385ba329803c5b934f8acaeacbf32 Mon Sep 17 00:00:00 2001 From: shima004 Date: Fri, 29 Nov 2024 20:03:19 +0900 Subject: [PATCH 1/2] feat: add office agents for ambulance, fire, and police --- .../cli/template/config/module.yaml | 18 +-- adf_core_python/core/agent/office/office.py | 103 ++++++++++++++++++ .../core/agent/office/office_ambulance.py | 31 ++++++ .../core/agent/office/office_fire.py | 31 ++++++ .../core/agent/office/office_police.py | 31 ++++++ .../core/launcher/agent_launcher.py | 29 ++--- ...entre.py => connector_ambulance_center.py} | 38 ++++--- .../connect/connector_fire_station.py | 29 +++-- .../connect/connector_police_office.py | 31 ++++-- .../default_tactics_ambulance_center.py | 5 +- .../tactics/default_tactics_fire_station.py | 5 +- .../tactics/default_tactics_police_office.py | 5 +- adf_core_python/launcher.py | 24 ++++ config/launcher.yaml | 6 +- config/module.yaml | 18 +-- 15 files changed, 320 insertions(+), 84 deletions(-) create mode 100644 adf_core_python/core/agent/office/office.py create mode 100644 adf_core_python/core/agent/office/office_ambulance.py create mode 100644 adf_core_python/core/agent/office/office_fire.py create mode 100644 adf_core_python/core/agent/office/office_police.py rename adf_core_python/core/launcher/connect/{connector_ambulance_centre.py => connector_ambulance_center.py} (65%) diff --git a/adf_core_python/cli/template/config/module.yaml b/adf_core_python/cli/template/config/module.yaml index 280129b9..efec4c66 100644 --- a/adf_core_python/cli/template/config/module.yaml +++ b/adf_core_python/cli/template/config/module.yaml @@ -22,17 +22,17 @@ DefaultTacticsPoliceForce: CommandExecutorPolice: adf_core_python.implement.centralized.DefaultCommandExecutorPolice CommandExecutorScout: adf_core_python.implement.centralized.DefaultCommandExecutorScoutPolice -# DefaultTacticsAmbulanceCentre: -# TargetAllocator: sample_team.module.complex.SampleAmbulanceTargetAllocator -# CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerAmbulance +DefaultTacticsAmbulanceCenter: + TargetAllocator: adf_core_python.implement.module.complex.default_ambulance_target_allocator.DefaultAmbulanceTargetAllocator + # CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerAmbulance -# DefaultTacticsFireStation: -# TargetAllocator: sample_team.module.complex.SampleFireTargetAllocator -# CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerFire +DefaultTacticsFireStation: + TargetAllocator: adf_core_python.implement.module.complex.default_fire_target_allocator.DefaultFireTargetAllocator + # CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerFire -# DefaultTacticsPoliceOffice: -# TargetAllocator: sample_team.module.complex.SamplePoliceTargetAllocator -# CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerPolice +DefaultTacticsPoliceOffice: + TargetAllocator: adf_core_python.implement.module.complex.default_police_target_allocator.DefaultPoliceTargetAllocator + # CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerPolice SampleSearch: PathPlanning: adf_core_python.implement.module.algorithm.a_star_path_planning.AStarPathPlanning diff --git a/adf_core_python/core/agent/office/office.py b/adf_core_python/core/agent/office/office.py new file mode 100644 index 00000000..4c43c4b2 --- /dev/null +++ b/adf_core_python/core/agent/office/office.py @@ -0,0 +1,103 @@ +from adf_core_python.core.agent.agent import Agent +from adf_core_python.core.agent.config.module_config import ModuleConfig +from adf_core_python.core.agent.develop.develop_data import DevelopData +from adf_core_python.core.agent.info.scenario_info import Mode +from adf_core_python.core.agent.module.module_manager import ModuleManager +from adf_core_python.core.agent.precompute.precompute_data import PrecomputeData +from adf_core_python.core.component.tactics.tactics_center import TacticsCenter +from adf_core_python.core.logger.logger import get_agent_logger + + +class Office(Agent): + def __init__( + self, + tactics_center: TacticsCenter, + team_name: str, + is_precompute: bool, + is_debug: bool, + data_storage_name: str, + module_config: ModuleConfig, + develop_data: DevelopData, + ) -> None: + super().__init__( + is_precompute, + self.__class__.__qualname__, + is_debug, + team_name, + data_storage_name, + module_config, + develop_data, + ) + self._tactics_center = tactics_center + self._team_name = team_name + self._is_precompute = is_precompute + self._is_debug = is_debug + self._data_storage_name = data_storage_name + self._module_config = module_config + self._develop_data = develop_data + + def post_connect(self) -> None: + super().post_connect() + self.precompute_data: PrecomputeData = PrecomputeData(self._data_storage_name) + + self._logger = get_agent_logger( + f"{self.__class__.__module__}.{self.__class__.__qualname__}", + self._agent_info, + ) + + self._module_manager: ModuleManager = ModuleManager( + self._agent_info, + self._world_info, + self._scenario_info, + self._module_config, + self._develop_data, + ) + + self._message_manager.set_channel_subscriber( + self._module_manager.get_channel_subscriber( + "MessageManager.PlatoonChannelSubscriber", + "adf_core_python.implement.module.communication.default_channel_subscriber.DefaultChannelSubscriber", + ) + ) + self._message_manager.set_message_coordinator( + self._module_manager.get_message_coordinator( + "MessageManager.PlatoonMessageCoordinator", + "adf_core_python.implement.module.communication.default_message_coordinator.DefaultMessageCoordinator", + ) + ) + + self._tactics_center.initialize( + self._agent_info, + self._world_info, + self._scenario_info, + self._module_manager, + self._precompute_data, + self._message_manager, + self._develop_data, + ) + + match self._scenario_info.get_mode(): + case Mode.PRECOMPUTATION: + pass + case Mode.PRECOMPUTED: + pass + case Mode.NON_PRECOMPUTE: + self._tactics_center.prepare( + self._agent_info, + self._world_info, + self._scenario_info, + self._module_manager, + self.precompute_data, + self._develop_data, + ) + + def think(self) -> None: + self._tactics_center.think( + self._agent_info, + self._world_info, + self._scenario_info, + self._module_manager, + self._precompute_data, + self._message_manager, + self._develop_data, + ) diff --git a/adf_core_python/core/agent/office/office_ambulance.py b/adf_core_python/core/agent/office/office_ambulance.py new file mode 100644 index 00000000..fc8b9b73 --- /dev/null +++ b/adf_core_python/core/agent/office/office_ambulance.py @@ -0,0 +1,31 @@ +from rcrs_core.connection.URN import Entity as EntityURN + +from adf_core_python.core.agent.office.office import Office + + +class OfficeAmbulance(Office): + def __init__( + self, + tactics_center, + team_name, + is_precompute, + is_debug, + data_storage_name, + module_config, + develop_data, + ) -> None: + super().__init__( + tactics_center, + team_name, + is_precompute, + is_debug, + data_storage_name, + module_config, + develop_data, + ) + + def post_connect(self) -> None: + super().post_connect() + + def get_requested_entities(self) -> list[EntityURN]: + return [EntityURN.AMBULANCE_CENTRE] diff --git a/adf_core_python/core/agent/office/office_fire.py b/adf_core_python/core/agent/office/office_fire.py new file mode 100644 index 00000000..214734b4 --- /dev/null +++ b/adf_core_python/core/agent/office/office_fire.py @@ -0,0 +1,31 @@ +from rcrs_core.connection.URN import Entity as EntityURN + +from adf_core_python.core.agent.office.office import Office + + +class OfficeFire(Office): + def __init__( + self, + tactics_center, + team_name, + is_precompute, + is_debug, + data_storage_name, + module_config, + develop_data, + ) -> None: + super().__init__( + tactics_center, + team_name, + is_precompute, + is_debug, + data_storage_name, + module_config, + develop_data, + ) + + def post_connect(self) -> None: + super().post_connect() + + def get_requested_entities(self) -> list[EntityURN]: + return [EntityURN.FIRE_STATION] diff --git a/adf_core_python/core/agent/office/office_police.py b/adf_core_python/core/agent/office/office_police.py new file mode 100644 index 00000000..61ce7b83 --- /dev/null +++ b/adf_core_python/core/agent/office/office_police.py @@ -0,0 +1,31 @@ +from rcrs_core.connection.URN import Entity as EntityURN + +from adf_core_python.core.agent.office.office import Office + + +class OfficePolice(Office): + def __init__( + self, + tactics_center, + team_name, + is_precompute, + is_debug, + data_storage_name, + module_config, + develop_data, + ) -> None: + super().__init__( + tactics_center, + team_name, + is_precompute, + is_debug, + data_storage_name, + module_config, + develop_data, + ) + + def post_connect(self) -> None: + super().post_connect() + + def get_requested_entities(self) -> list[EntityURN]: + return [EntityURN.POLICE_OFFICE] diff --git a/adf_core_python/core/launcher/agent_launcher.py b/adf_core_python/core/launcher/agent_launcher.py index e7884fb5..9b275f65 100644 --- a/adf_core_python/core/launcher/agent_launcher.py +++ b/adf_core_python/core/launcher/agent_launcher.py @@ -4,31 +4,26 @@ from adf_core_python.core.component.abstract_loader import AbstractLoader from adf_core_python.core.config.config import Config from adf_core_python.core.launcher.config_key import ConfigKey - -# from rcrs_core.connection.componentLauncher import ComponentLauncher from adf_core_python.core.launcher.connect.component_launcher import ComponentLauncher from adf_core_python.core.launcher.connect.connector import Connector - -# from adf_core_python.core.launcher.connect.connector_ambulance_centre import ( -# ConnectorAmbulanceCentre, -# ) +from adf_core_python.core.launcher.connect.connector_ambulance_center import ( + ConnectorAmbulanceCenter, +) from adf_core_python.core.launcher.connect.connector_ambulance_team import ( ConnectorAmbulanceTeam, ) from adf_core_python.core.launcher.connect.connector_fire_brigade import ( ConnectorFireBrigade, ) - -# from adf_core_python.core.launcher.connect.connector_fire_station import ( -# ConnectorFireStation, -# ) +from adf_core_python.core.launcher.connect.connector_fire_station import ( + ConnectorFireStation, +) from adf_core_python.core.launcher.connect.connector_police_force import ( ConnectorPoliceForce, ) - -# from adf_core_python.core.launcher.connect.connector_police_office import ( -# ConnectorPoliceOffice, -# ) +from adf_core_python.core.launcher.connect.connector_police_office import ( + ConnectorPoliceOffice, +) from adf_core_python.core.logger.logger import get_logger @@ -53,11 +48,11 @@ def init_connector(self) -> None: ) self.connectors.append(ConnectorAmbulanceTeam()) - # self.connectors.append(ConnectorAmbulanceCentre()) + self.connectors.append(ConnectorAmbulanceCenter()) self.connectors.append(ConnectorFireBrigade()) - # self.connectors.append(ConnectorFireStation()) + self.connectors.append(ConnectorFireStation()) self.connectors.append(ConnectorPoliceForce()) - # self.connectors.append(ConnectorPoliceOffice()) + self.connectors.append(ConnectorPoliceOffice()) def launch(self) -> None: host: str = self.config.get_value(ConfigKey.KEY_KERNEL_HOST, "localhost") diff --git a/adf_core_python/core/launcher/connect/connector_ambulance_centre.py b/adf_core_python/core/launcher/connect/connector_ambulance_center.py similarity index 65% rename from adf_core_python/core/launcher/connect/connector_ambulance_centre.py rename to adf_core_python/core/launcher/connect/connector_ambulance_center.py index 8004fb9d..98e02d8a 100644 --- a/adf_core_python/core/launcher/connect/connector_ambulance_centre.py +++ b/adf_core_python/core/launcher/connect/connector_ambulance_center.py @@ -1,10 +1,12 @@ import threading -from rcrs_core.agents.ambulanceCenterAgent import AmbulanceCenterAgent - from adf_core_python.core.agent.config.module_config import ModuleConfig from adf_core_python.core.agent.develop.develop_data import DevelopData +from adf_core_python.core.agent.office.office_ambulance import OfficeAmbulance from adf_core_python.core.component.abstract_loader import AbstractLoader +from adf_core_python.core.component.tactics.tactics_ambulance_center import ( + TacticsAmbulanceCenter, +) from adf_core_python.core.config.config import Config from adf_core_python.core.launcher.config_key import ConfigKey from adf_core_python.core.launcher.connect.component_launcher import ComponentLauncher @@ -12,7 +14,7 @@ from adf_core_python.core.logger.logger import get_logger -class ConnectorAmbulanceCentre(Connector): +class ConnectorAmbulanceCenter(Connector): def __init__(self) -> None: super().__init__() self.logger = get_logger(__name__) @@ -30,22 +32,21 @@ def connect( threads: list[threading.Thread] = [] for _ in range(count): - # tactics_ambulance_centre: TacticsAmbulanceCentre - if loader.get_tactics_ambulance_center() is not None: + if loader.get_tactics_ambulance_center() is None: self.logger.error("Cannot load ambulance centre tactics") - # tactics_ambulance_centre = loader.get_tactics_ambulance_centre() - else: - # tactics_ambulance_centre = DummyTacticsAmbulanceCentre() - pass - module_config: ModuleConfig = ModuleConfig( # noqa: F841 + tactics_ambulance_center: TacticsAmbulanceCenter = ( + loader.get_tactics_ambulance_center() + ) + + module_config: ModuleConfig = ModuleConfig( config.get_value( ConfigKey.KEY_MODULE_CONFIG_FILE_NAME, ModuleConfig.DEFAULT_CONFIG_FILE_NAME, ) ) - develop_data: DevelopData = DevelopData( # noqa: F841 + develop_data: DevelopData = DevelopData( config.get_value(ConfigKey.KEY_DEBUG_FLAG, False), config.get_value( ConfigKey.KEY_DEVELOP_DATA_FILE_NAME, DevelopData.DEFAULT_FILE_NAME @@ -53,18 +54,23 @@ def connect( ) request_id: int = component_launcher.generate_request_id() - # TODO: component_launcher.generate_request_ID can cause race condition thread = threading.Thread( target=component_launcher.connect, args=( - AmbulanceCenterAgent( + OfficeAmbulance( + tactics_ambulance_center, + "ambulance_center", config.get_value(ConfigKey.KEY_PRECOMPUTE, False), - ), # type: ignore + config.get_value(ConfigKey.KEY_DEBUG_FLAG, False), + "test", + module_config, + develop_data, + ), request_id, ), - name=f"AmbulanceCentreAgent-{request_id}", + name=f"AmbulanceCenterAgent-{request_id}", ) threads.append(thread) - self.logger.info("Connected ambulance centre (count: %d)" % count) + self.logger.info("Connected ambulance center (count: %d)" % count) return threads diff --git a/adf_core_python/core/launcher/connect/connector_fire_station.py b/adf_core_python/core/launcher/connect/connector_fire_station.py index cd5632e4..f9f4abc0 100644 --- a/adf_core_python/core/launcher/connect/connector_fire_station.py +++ b/adf_core_python/core/launcher/connect/connector_fire_station.py @@ -1,10 +1,12 @@ import threading -from rcrs_core.agents.fireStationAgent import FireStationAgent - from adf_core_python.core.agent.config.module_config import ModuleConfig from adf_core_python.core.agent.develop.develop_data import DevelopData +from adf_core_python.core.agent.office.office_fire import OfficeFire from adf_core_python.core.component.abstract_loader import AbstractLoader +from adf_core_python.core.component.tactics.tactics_fire_station import ( + TacticsFireStation, +) from adf_core_python.core.config.config import Config from adf_core_python.core.launcher.config_key import ConfigKey from adf_core_python.core.launcher.connect.component_launcher import ComponentLauncher @@ -30,22 +32,19 @@ def connect( threads: list[threading.Thread] = [] for _ in range(count): - # tactics_fire_station: TacticsFireStation - if loader.get_tactics_fire_station() is not None: + if loader.get_tactics_fire_station() is None: self.logger.error("Cannot load fire station tactics") - # tactics_fire_station = loader.get_tactics_fire_station() - else: - # tactics_fire_station = DummyTacticsFireStation() - pass - module_config: ModuleConfig = ModuleConfig( # noqa: F841 + tactics_fire_station: TacticsFireStation = loader.get_tactics_fire_station() + + module_config: ModuleConfig = ModuleConfig( config.get_value( ConfigKey.KEY_MODULE_CONFIG_FILE_NAME, ModuleConfig.DEFAULT_CONFIG_FILE_NAME, ) ) - develop_data: DevelopData = DevelopData( # noqa: F841 + develop_data: DevelopData = DevelopData( config.get_value(ConfigKey.KEY_DEBUG_FLAG, False), config.get_value( ConfigKey.KEY_DEVELOP_DATA_FILE_NAME, DevelopData.DEFAULT_FILE_NAME @@ -56,9 +55,15 @@ def connect( thread = threading.Thread( target=component_launcher.connect, args=( - FireStationAgent( + OfficeFire( + tactics_fire_station, + "fire_station", config.get_value(ConfigKey.KEY_PRECOMPUTE, False), - ), # type: ignore + config.get_value(ConfigKey.KEY_DEBUG_FLAG, False), + "test", + module_config, + develop_data, + ), request_id, ), name=f"FireStationAgent-{request_id}", diff --git a/adf_core_python/core/launcher/connect/connector_police_office.py b/adf_core_python/core/launcher/connect/connector_police_office.py index b20da2e4..01601fc8 100644 --- a/adf_core_python/core/launcher/connect/connector_police_office.py +++ b/adf_core_python/core/launcher/connect/connector_police_office.py @@ -1,10 +1,12 @@ import threading -from rcrs_core.agents.policeOfficeAgent import PoliceOfficeAgent - from adf_core_python.core.agent.config.module_config import ModuleConfig from adf_core_python.core.agent.develop.develop_data import DevelopData +from adf_core_python.core.agent.office.office_police import OfficePolice from adf_core_python.core.component.abstract_loader import AbstractLoader +from adf_core_python.core.component.tactics.tactics_police_office import ( + TacticsPoliceOffice, +) from adf_core_python.core.config.config import Config from adf_core_python.core.launcher.config_key import ConfigKey from adf_core_python.core.launcher.connect.component_launcher import ComponentLauncher @@ -30,22 +32,21 @@ def connect( threads: list[threading.Thread] = [] for _ in range(count): - # tactics_police_office: TacticsPoliceOffice - if loader.get_tactics_police_office() is not None: + if loader.get_tactics_police_office() is None: self.logger.error("Cannot load police office tactics") - # tactics_police_office = loader.get_tactics_police_office() - else: - # tactics_police_office = DummyTacticsPoliceOffice() - pass - module_config: ModuleConfig = ModuleConfig( # noqa: F841 + tactics_police_office: TacticsPoliceOffice = ( + loader.get_tactics_police_office() + ) + + module_config: ModuleConfig = ModuleConfig( config.get_value( ConfigKey.KEY_MODULE_CONFIG_FILE_NAME, ModuleConfig.DEFAULT_CONFIG_FILE_NAME, ) ) - develop_data: DevelopData = DevelopData( # noqa: F841 + develop_data: DevelopData = DevelopData( config.get_value(ConfigKey.KEY_DEBUG_FLAG, False), config.get_value( ConfigKey.KEY_DEVELOP_DATA_FILE_NAME, DevelopData.DEFAULT_FILE_NAME @@ -56,9 +57,15 @@ def connect( thread = threading.Thread( target=component_launcher.connect, args=( - PoliceOfficeAgent( + OfficePolice( + tactics_police_office, + "police_office", config.get_value(ConfigKey.KEY_PRECOMPUTE, False), - ), # type: ignore + config.get_value(ConfigKey.KEY_DEBUG_FLAG, False), + "test", + module_config, + develop_data, + ), request_id, ), name=f"PoliceOfficeAgent-{request_id}", diff --git a/adf_core_python/implement/tactics/default_tactics_ambulance_center.py b/adf_core_python/implement/tactics/default_tactics_ambulance_center.py index 7fbb294d..909f448f 100644 --- a/adf_core_python/implement/tactics/default_tactics_ambulance_center.py +++ b/adf_core_python/implement/tactics/default_tactics_ambulance_center.py @@ -32,7 +32,7 @@ def initialize( TargetAllocator, module_manager.get_module( "DefaultTacticsAmbulanceCenter.TargetAllocator", - "adf_core_python.implement.module.complex.DefaultTargetAllocator", + "adf_core_python.implement.module.complex.default_ambulance_target_allocator.DefaultAmbulanceTargetAllocator", ), ) self.register_module(self._allocator) @@ -70,4 +70,5 @@ def think( message_manager: MessageManager, develop_data: DevelopData, ) -> None: - raise NotImplementedError + # TODO: implement + pass diff --git a/adf_core_python/implement/tactics/default_tactics_fire_station.py b/adf_core_python/implement/tactics/default_tactics_fire_station.py index 41f5ccc0..63693d78 100644 --- a/adf_core_python/implement/tactics/default_tactics_fire_station.py +++ b/adf_core_python/implement/tactics/default_tactics_fire_station.py @@ -32,7 +32,7 @@ def initialize( TargetAllocator, module_manager.get_module( "DefaultTacticsFireStation.TargetAllocator", - "adf_core_python.implement.module.complex.DefaultFireTargetAllocator", + "adf_core_python.implement.module.complex.default_fire_target_allocator.DefaultFireTargetAllocator", ), ) self.register_module(self._allocator) @@ -70,4 +70,5 @@ def think( message_manager: MessageManager, develop_data: DevelopData, ) -> None: - raise NotImplementedError + # TODO: implement + pass diff --git a/adf_core_python/implement/tactics/default_tactics_police_office.py b/adf_core_python/implement/tactics/default_tactics_police_office.py index bf06a371..f2d54c95 100644 --- a/adf_core_python/implement/tactics/default_tactics_police_office.py +++ b/adf_core_python/implement/tactics/default_tactics_police_office.py @@ -32,7 +32,7 @@ def initialize( TargetAllocator, module_manager.get_module( "DefaultTacticsPoliceOffice.TargetAllocator", - "adf_core_python.implement.module.complex.DefaultPoliceTargetAllocator", + "adf_core_python.implement.module.complex.default_police_target_allocator.DefaultPoliceTargetAllocator", ), ) self.register_module(self._allocator) @@ -70,4 +70,5 @@ def think( message_manager: MessageManager, develop_data: DevelopData, ) -> None: - raise NotImplementedError + # TODO: implement + pass diff --git a/adf_core_python/launcher.py b/adf_core_python/launcher.py index a7105ca0..e523a1f3 100644 --- a/adf_core_python/launcher.py +++ b/adf_core_python/launcher.py @@ -51,6 +51,27 @@ def __init__( help="number of policeforce agents(Default: all policeforce)", metavar="", ) + parser.add_argument( + "-ac", + "--ambulancecenter", + type=int, + help="number of ambulance center agents(Default: all ambulance center)", + metavar="", + ) + parser.add_argument( + "-fs", + "--firestation", + type=int, + help="number of fire station agents(Default: all fire station)", + metavar="", + ) + parser.add_argument( + "-po", + "--policeoffice", + type=int, + help="number of police office agents(Default: all police office)", + metavar="", + ) parser.add_argument( "--precompute", type=bool, @@ -66,6 +87,9 @@ def __init__( ConfigKey.KEY_AMBULANCE_TEAM_COUNT: args.ambulanceteam, ConfigKey.KEY_FIRE_BRIGADE_COUNT: args.firebrigade, ConfigKey.KEY_POLICE_FORCE_COUNT: args.policeforce, + ConfigKey.KEY_AMBULANCE_CENTRE_COUNT: args.ambulancecenter, + ConfigKey.KEY_FIRE_STATION_COUNT: args.firestation, + ConfigKey.KEY_POLICE_OFFICE_COUNT: args.policeoffice, ConfigKey.KEY_PRECOMPUTE: args.precompute, ConfigKey.KEY_DEBUG_FLAG: args.debug, } diff --git a/config/launcher.yaml b/config/launcher.yaml index 07de1caa..1b6bdfd3 100644 --- a/config/launcher.yaml +++ b/config/launcher.yaml @@ -28,8 +28,8 @@ adf: count: 100 office: ambulance: - count: -1 + count: 5 fire: - count: -1 + count: 5 police: - count: -1 + count: 5 diff --git a/config/module.yaml b/config/module.yaml index 2697130e..75c15a0b 100644 --- a/config/module.yaml +++ b/config/module.yaml @@ -22,17 +22,17 @@ DefaultTacticsPoliceForce: CommandExecutorPolice: adf_core_python.implement.centralized.DefaultCommandExecutorPolice CommandExecutorScout: adf_core_python.implement.centralized.DefaultCommandExecutorScoutPolice -# DefaultTacticsAmbulanceCentre: -# TargetAllocator: sample_team.module.complex.SampleAmbulanceTargetAllocator -# CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerAmbulance +DefaultTacticsAmbulanceCenter: + TargetAllocator: adf_core_python.implement.module.complex.default_ambulance_target_allocator.DefaultAmbulanceTargetAllocator + # CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerAmbulance -# DefaultTacticsFireStation: -# TargetAllocator: sample_team.module.complex.SampleFireTargetAllocator -# CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerFire +DefaultTacticsFireStation: + TargetAllocator: adf_core_python.implement.module.complex.default_fire_target_allocator.DefaultFireTargetAllocator + # CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerFire -# DefaultTacticsPoliceOffice: -# TargetAllocator: sample_team.module.complex.SamplePoliceTargetAllocator -# CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerPolice +DefaultTacticsPoliceOffice: + TargetAllocator: adf_core_python.implement.module.complex.default_police_target_allocator.DefaultPoliceTargetAllocator + # CommandPicker: adf_core_python.implement.centralized.DefaultCommandPickerPolice DefaultSearch: PathPlanning: adf_core_python.implement.module.algorithm.a_star_path_planning.AStarPathPlanning From 59704ee1cfc24391416204f25d28aba8be7112d3 Mon Sep 17 00:00:00 2001 From: shima004 Date: Fri, 29 Nov 2024 20:21:06 +0900 Subject: [PATCH 2/2] feat: update office agents to include type hints and refactor precompute method --- .../core/agent/office/office_ambulance.py | 21 +++++++++++-------- .../core/agent/office/office_fire.py | 21 +++++++++++-------- .../core/agent/office/office_police.py | 21 +++++++++++-------- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/adf_core_python/core/agent/office/office_ambulance.py b/adf_core_python/core/agent/office/office_ambulance.py index fc8b9b73..4076f67a 100644 --- a/adf_core_python/core/agent/office/office_ambulance.py +++ b/adf_core_python/core/agent/office/office_ambulance.py @@ -1,18 +1,21 @@ from rcrs_core.connection.URN import Entity as EntityURN +from adf_core_python.core.agent.config.module_config import ModuleConfig +from adf_core_python.core.agent.develop.develop_data import DevelopData from adf_core_python.core.agent.office.office import Office +from adf_core_python.core.component.tactics.tactics_center import TacticsCenter class OfficeAmbulance(Office): def __init__( self, - tactics_center, - team_name, - is_precompute, - is_debug, - data_storage_name, - module_config, - develop_data, + tactics_center: TacticsCenter, + team_name: str, + is_precompute: bool, + is_debug: bool, + data_storage_name: str, + module_config: ModuleConfig, + develop_data: DevelopData, ) -> None: super().__init__( tactics_center, @@ -24,8 +27,8 @@ def __init__( develop_data, ) - def post_connect(self) -> None: - super().post_connect() + def precompute(self) -> None: + pass def get_requested_entities(self) -> list[EntityURN]: return [EntityURN.AMBULANCE_CENTRE] diff --git a/adf_core_python/core/agent/office/office_fire.py b/adf_core_python/core/agent/office/office_fire.py index 214734b4..bcd19460 100644 --- a/adf_core_python/core/agent/office/office_fire.py +++ b/adf_core_python/core/agent/office/office_fire.py @@ -1,18 +1,21 @@ from rcrs_core.connection.URN import Entity as EntityURN +from adf_core_python.core.agent.config.module_config import ModuleConfig +from adf_core_python.core.agent.develop.develop_data import DevelopData from adf_core_python.core.agent.office.office import Office +from adf_core_python.core.component.tactics.tactics_center import TacticsCenter class OfficeFire(Office): def __init__( self, - tactics_center, - team_name, - is_precompute, - is_debug, - data_storage_name, - module_config, - develop_data, + tactics_center: TacticsCenter, + team_name: str, + is_precompute: bool, + is_debug: bool, + data_storage_name: str, + module_config: ModuleConfig, + develop_data: DevelopData, ) -> None: super().__init__( tactics_center, @@ -24,8 +27,8 @@ def __init__( develop_data, ) - def post_connect(self) -> None: - super().post_connect() + def precompute(self) -> None: + pass def get_requested_entities(self) -> list[EntityURN]: return [EntityURN.FIRE_STATION] diff --git a/adf_core_python/core/agent/office/office_police.py b/adf_core_python/core/agent/office/office_police.py index 61ce7b83..ccfcbca9 100644 --- a/adf_core_python/core/agent/office/office_police.py +++ b/adf_core_python/core/agent/office/office_police.py @@ -1,18 +1,21 @@ from rcrs_core.connection.URN import Entity as EntityURN +from adf_core_python.core.agent.config.module_config import ModuleConfig +from adf_core_python.core.agent.develop.develop_data import DevelopData from adf_core_python.core.agent.office.office import Office +from adf_core_python.core.component.tactics.tactics_center import TacticsCenter class OfficePolice(Office): def __init__( self, - tactics_center, - team_name, - is_precompute, - is_debug, - data_storage_name, - module_config, - develop_data, + tactics_center: TacticsCenter, + team_name: str, + is_precompute: bool, + is_debug: bool, + data_storage_name: str, + module_config: ModuleConfig, + develop_data: DevelopData, ) -> None: super().__init__( tactics_center, @@ -24,8 +27,8 @@ def __init__( develop_data, ) - def post_connect(self) -> None: - super().post_connect() + def precompute(self) -> None: + pass def get_requested_entities(self) -> list[EntityURN]: return [EntityURN.POLICE_OFFICE]