Skip to content

Commit

Permalink
Update getting battery level from robot in Zenoh connection.- Get act…
Browse files Browse the repository at this point in the history
…ual battery level from robot- Use battery info from 'get_battery_info' method
  • Loading branch information
h-wata committed May 31, 2024
1 parent e060ebf commit 3b7dff7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scripts/connect_openrmf_by_zenoh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()


Expand Down

0 comments on commit 3b7dff7

Please sign in to comment.