From 4054ea1530dc6e6292567109dcb7f8bf80784475 Mon Sep 17 00:00:00 2001 From: h-wata Date: Fri, 2 Aug 2024 15:41:43 +0900 Subject: [PATCH] Add map name mapping for L27 and L29. Fix switch_map method --- config/config.yaml | 3 +++ scripts/connect_openrmf_by_zenoh.py | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 70407d5..35d056f 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,3 +1,6 @@ method_mapping: dock: return_home localize: switch_map +mapname_mapping: + 27F: L27 + 29F: L29 diff --git a/scripts/connect_openrmf_by_zenoh.py b/scripts/connect_openrmf_by_zenoh.py index 24f842c..b8f8e0c 100644 --- a/scripts/connect_openrmf_by_zenoh.py +++ b/scripts/connect_openrmf_by_zenoh.py @@ -52,6 +52,7 @@ def __init__(self, zenoh_router: str, kachaka_access_point: str, robot_name: str with open(file_path / "config" / config_file, 'r') as f: config = yaml.safe_load(f) self.method_mapping = config.get('method_mapping', {}) + self.map_name_mapping = config.get('map_name_mapping', {}) self.kachaka_client = kachaka_api.KachakaApiClient(kachaka_access_point) self.robot_name = robot_name self.task_id = None @@ -120,13 +121,14 @@ async def switch_map(self, args: dict) -> None: Args: args (dict): The arguments for the switch_map method. """ + map_name = self.map_name_mapping.get(args.get('map_name'), args.get('map_name')) map_list = await self.run_method("get_map_list") - map_id = next((item["id"] for item in map_list if item["name"] == args.get('map_name')), None) + map_id = next((item["id"] for item in map_list if item["name"] == map_name), None) if map_id is not None: payload = {"map_id": map_id, "pose": args.get("pose", {"x": 0.0, "y": 0.0, "theta": 0.0})} await self.run_method("switch_map", payload) else: - print(f"Map {args.get('map_name')} not found") + print(f"Map {map_name} not found") async def publish_result(self) -> None: """Publish the last command is_completed to Zenoh.""" @@ -219,7 +221,7 @@ def main() -> None: asyncio.run(node.publish_result()) time.sleep(1) except KeyboardInterrupt: - node.session.delete(f"kachaka/{robot_name}/**") + node.session.delete(f"robots/{robot_name}/**") node.session.close()