def check_battery(robot: cozmo.robot.Robot): global charging global low_battery batt = robot.battery_voltage print("COZMO BATTERY: " + str(batt)) if not charging: if (batt < charge_low): robot.say_text("battery low") low_battery = 1 else: if batt > charge_high: low_battery = 0 charging = 0 robot.say_text("finished charging") networking.sendChargeState(charging)
def set_charging(command, args): global charging global low_battery if extended_command.is_authed(args['name']) == 2: # Owner if len(command) > 1: try: if command[1] == "on": low_battery = 1 if coz.is_on_charger: charging = 1 elif command[1] == "off": low_battery = 0 charging = 0 print("charging set to : %d" % charging) networking.sendChargeState(charging) except ValueError: pass
def sendChargeState(): networking.sendChargeState(isCharging())