Skip to content

Commit

Permalink
Merge pull request #9 from sbgisen/feature/pub_battery
Browse files Browse the repository at this point in the history
Update getting battery level from robot in Zenoh connection.- Get act…
  • Loading branch information
MikhailBertrand authored Jun 14, 2024
2 parents e060ebf + 3b7dff7 commit b46ac34
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 b46ac34

Please sign in to comment.