From 3b7dff73828da083c531798e4e1642217ce8cf07 Mon Sep 17 00:00:00 2001 From: h-wata Date: Fri, 24 May 2024 14:53:51 +0900 Subject: [PATCH] Update getting battery level from robot in Zenoh connection.- Get actual battery level from robot- Use battery info from 'get_battery_info' method --- scripts/connect_openrmf_by_zenoh.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/connect_openrmf_by_zenoh.py b/scripts/connect_openrmf_by_zenoh.py index a479dc0..1908f0a 100644 --- a/scripts/connect_openrmf_by_zenoh.py +++ b/scripts/connect_openrmf_by_zenoh.py @@ -104,8 +104,9 @@ async def publish_pose(self) -> None: async def publish_battery(self) -> None: """Publish the current robot battery to Zenoh.""" - # TODO Get the actual battery level from the robot - battery = 0.8 + res = await self.run_method("get_battery_info") + if isinstance(res, (list, tuple)) and len(res) > 0: + battery = res[0] / 100.0 self.battery_pub.put(json.dumps(battery).encode(), encoding=zenoh.Encoding.APP_JSON()) async def publish_map_name(self) -> None: @@ -203,7 +204,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()