Skip to content

Commit 59bce54

Browse files
committedAug 2, 2024
Add map name mapping for L27 and L29. Fix switch_map method
1 parent f564825 commit 59bce54

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
 

‎config/config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
method_mapping:
2+
# <rmf method name>: <kachaka method name>
23
dock: return_home
34
localize: switch_map
5+
mapname_mapping:
6+
# <rmf map name>: <kachaka map name>
7+
27F: L27
8+
29F: L29

‎scripts/connect_openrmf_by_zenoh.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def __init__(self, zenoh_router: str, kachaka_access_point: str, robot_name: str
5252
with open(file_path / "config" / config_file, 'r') as f:
5353
config = yaml.safe_load(f)
5454
self.method_mapping = config.get('method_mapping', {})
55+
self.map_name_mapping = config.get('map_name_mapping', {})
5556
self.kachaka_client = kachaka_api.KachakaApiClient(kachaka_access_point)
5657
self.robot_name = robot_name
5758
self.task_id = None
@@ -120,13 +121,14 @@ async def switch_map(self, args: dict) -> None:
120121
Args:
121122
args (dict): The arguments for the switch_map method.
122123
"""
124+
map_name = self.map_name_mapping.get(args.get('map_name'), args.get('map_name'))
123125
map_list = await self.run_method("get_map_list")
124-
map_id = next((item["id"] for item in map_list if item["name"] == args.get('map_name')), None)
126+
map_id = next((item["id"] for item in map_list if item["name"] == map_name), None)
125127
if map_id is not None:
126128
payload = {"map_id": map_id, "pose": args.get("pose", {"x": 0.0, "y": 0.0, "theta": 0.0})}
127129
await self.run_method("switch_map", payload)
128130
else:
129-
print(f"Map {args.get('map_name')} not found")
131+
print(f"Map {map_name} not found")
130132

131133
async def publish_result(self) -> None:
132134
"""Publish the last command is_completed to Zenoh."""
@@ -219,7 +221,7 @@ def main() -> None:
219221
asyncio.run(node.publish_result())
220222
time.sleep(1)
221223
except KeyboardInterrupt:
222-
node.session.delete(f"kachaka/{robot_name}/**")
224+
node.session.delete(f"robots/{robot_name}/**")
223225
node.session.close()
224226

225227

0 commit comments

Comments
 (0)