Power service

The power service provides the function of robot power management. Through PowerManager, you can control the robot to sleep, wake up, query power status, shutdown and make it turn on at a set time.

Get PowerManager through the [RobotContext[ object.

PowerManager powerManager = robotContext.getSystemService(PowerManager.SERVICE);

Turn on at a set time.

  • Set a time to turn on

java Promise<Void, PowerException> scheduleStartupPromise = powerManager.scheduleStartup(waitSeconds);/* [1] */

[1]The method that returns Promise is an asynchronous method. You can obtain the execution result by registering a callback, or you can execute the get () method to convert it to a synchronous method. For details, see async.

  • Cancel the scheduled turn on

java Promise<Void, PowerException> cancelStartupSchedulePromise = powerManager.cancelStartupSchedule();

Turn off

When not in use, the robot can be actively turned off.

Promise<Void, PowerException> shutdownPromise = powerManager.shutdown();

Sleep and wake up

  • sleep

In sleep mode, power consumption will be reduced.

java Promise<Void, PowerException> sleepPromise = powerManager.sleep();

  • wake up

In sleep mode, you can wake up the robot by calling WakeUp ().

java Promise<Void, PowerException> wakeUpPromise = powerManager.wakeUp();

  • Get the sleeping status

java boolean isSleeping = powerManager.isSleeping();

Power status

Get the power status

BatteryProperties batteryProperties=powerManager.getBatteryProperties();/* [1] */

[1] BatteryProperties power status

Type Attributes Descriptions
int level power
boolean chargerAcOnline Whether it is charging with AC power
boolean chargingStationOnline Whether it is charging at the charging station
int chargingVoltage Charging voltage
boolean full Whether the battery is fully charged
int temperature Power temperature

Monitor power status

  • Register the monitoring

java BatteryListener batteryListener=new BatteryListener() { @Override public void onBatteryChanged(BatteryProperties batteryProperties) { //the power status has changed } }; powerManager.registerBatteryListener(batteryListener);

  • Cancel monitoring

java powerManager.unregisterBatteryListener(batteryListener);