Skip to content

Commit 231ebed

Browse files
committed
Fix battery power monitoring
1 parent 4af7d2e commit 231ebed

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/bitbots_motion/bitbots_hcm/bitbots_hcm/humanoid_control_module.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
from rclpy.time import Time
2020
from ros2_numpy import numpify
2121
from sensor_msgs.msg import Imu, JointState
22-
from std_msgs.msg import Bool
22+
from std_msgs.msg import Bool, Float32
2323
from std_srvs.srv import SetBool
24-
from livelybot_msg.msg import PowerDetect
2524

2625
from bitbots_hcm import hcm_dsd
2726
from bitbots_hcm.hcm_dsd.hcm_blackboard import HcmBlackboard
@@ -78,7 +77,7 @@ def __init__(self, use_sim_time, simulation_active, visualization_active):
7877
self.hcm_deactivated = False
7978

8079
# Create subscribers
81-
self.node.create_subscription(PowerDetect, "power_detect_state", self.power_detect_cb, 1)
80+
self.node.create_subscription(Float32, "battery_voltage", self.voltage_cb, 1)
8281
self.node.create_subscription(Bool, "hcm_deactivate", self.deactivate_cb, 1)
8382
self.node.create_subscription(DiagnosticArray, "diagnostics_agg", self.diag_cb, 1)
8483
self.node.create_subscription(Bool, "game_controller/stop_msg", self.stop_cb, 1)
@@ -142,9 +141,9 @@ def set_manual_penalize_mode_callback(self, req: ManualPenalize.Request, resp: M
142141
resp.success = True
143142
return resp
144143

145-
def power_detect_cb(self, msg: PowerDetect):
146-
"""Recives data send by the battery management system."""
147-
self.blackboard.battery_voltage = msg.voltage
144+
def voltage_cb(self, msg: Float32):
145+
"""Receives data sent by the battery management system."""
146+
self.blackboard.battery_voltage = msg.data
148147

149148
def diag_cb(self, msg: DiagnosticArray):
150149
"""Updates the diagnostic state."""

src/bitbots_motion/bitbots_hcm/config/hcm_wolfgang.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@
4747

4848
# Battery
4949
battery:
50-
voltage_threshold: 6.0 # Voltage under which the battery is considered low
50+
voltage_threshold: 19.0 # Voltage under which the battery is considered low
5151
debounce_time: 5.0 # Time the battery has to be under the threshold to be considered low [s]
5252

0 commit comments

Comments
 (0)