Skip to content

Commit

Permalink
Add map name mapping for L27 and L29. Fix switch_map method
Browse files Browse the repository at this point in the history
  • Loading branch information
h-wata committed Aug 2, 2024
1 parent f564825 commit 4054ea1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
method_mapping:
dock: return_home
localize: switch_map
mapname_mapping:
27F: L27
29F: L29
8 changes: 5 additions & 3 deletions scripts/connect_openrmf_by_zenoh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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()


Expand Down

0 comments on commit 4054ea1

Please sign in to comment.