Skip to content

Commit

Permalink
added check to get_battery_states_fropom_state() to throw a pop up wa…
Browse files Browse the repository at this point in the history
…rning when spot battery is <= 10%
  • Loading branch information
tcappellari-bdai committed Feb 1, 2024
1 parent 1ffa10e commit a756449
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spot_driver/spot_driver/ros_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from rclpy.node import Node
from sensor_msgs.msg import CameraInfo, CompressedImage, Image, JointState
from tf2_msgs.msg import TFMessage
from tkinter import messagebox

from spot_driver.conversions import convert_proto_to_bosdyn_msgs_manipulator_state
from spot_msgs.msg import ( # type: ignore
Expand Down Expand Up @@ -556,6 +557,14 @@ def get_battery_states_from_state(state: robot_state_pb2.RobotState, spot_wrappe
battery_msg.status = battery.status
battery_states_array_msg.battery_states.append(battery_msg)

if battery_msg.charge_percentage <= 0.1:
messagebox.showwarning(
title="Warning: Low Battery {}".format(battery_msg.identifier),
message=(
"Battery is at {}. Approximately {} minutes remaining.\n Please charge your Spot soon."
).format(battery_msg.charge_percentage * 100, battery_msg.estimated_runtime.sec / 60),
)

return battery_states_array_msg


Expand Down

0 comments on commit a756449

Please sign in to comment.