I’m interested in getting a boolean value indicating whether the robot is charging or not. I thought I might be able to do this by looking at the ROS /battery
topic, but whether the robot is plugged in or not, this returns a positive value for the current. I also checked stretch_robot_battery_check.py
, but I assume that comes from the same source as the result is the same.
I also had a look at how the battery state is being published and there’s a check based on robot_status['pimu']['charger_connected']
, but this always seems to be false.
Looking a bit more at the way the battery message in ROS is populated, I noticed that the hardware ID I get from pimu_hardware_id = self.robot.pimu.board_info['hardware_id']
in stretch_ros/stretch_driver at 16bba2f2608dec249bf159b42d9a0000505f2a86 · hello-robot/stretch_ros · GitHub returns 2, but that’s not included in the if statements.
I fixed that, but the charging state history and almost never contains values which indicate charging or discharging, and so the charging state is never set to anything.
Is there some other method of getting the state of charge, or should I just rely on using the pimu charger connected flag?
For the time being I replaced the lines which added to the voltage history and computed the filtered state with
if robot_status['pimu']['charger_connected']:
self.charging_state = BatteryState.POWER_SUPPLY_STATUS_CHARGING
elif not robot_status['pimu']['charger_connected']:
self.charging_state = BatteryState.POWER_SUPPLY_STATUS_DISCHARGING