电池#
介绍#
The battery class is derived from the brain base class and provides access to the IQ (2nd gen) Brain’s battery, allowing your robot to monitor capacity, voltage, current draw, power usage, temperature, and efficiency.
使用权#
Brain.Battery
成员功能#
The battery class includes the following member functions:
capacity— Returns the brain’s remaining battery capacity.voltage— Returns the battery voltage.current— Returns the battery current draw.
Before calling any battery member functions, a brain instance must be created, as shown below:
// Create the Brain
brain Brain = brain();
容量#
返回 IQ(第二代)大脑电池的剩余电量。
Available Functionsuint32_t capacity( percentUnits units = percentUnits::pct );
范围 |
类型 |
描述 |
|---|---|---|
|
|
Optional. The unit used to represent battery capacity: |
Returns a uint32_t representing the remaining battery capacity as a percentage from 0 to 100.
电压#
返回 IQ(第二代)大脑电池的电压。电压是指施加在电池上的电压力,可以帮助您检查电池电量是否充足,以确保机器人能够可靠运行。
Available Functionsdouble voltage( voltageUnits units = voltageUnits::volt );
范围 |
类型 |
描述 |
|---|---|---|
|
|
Optional. The unit used to represent voltage: |
Returns a double representing the battery voltage in the specified units, ranging from 7.0 to 8.0 V or 7000 to 8000 mV.
当前的#
返回从 IQ(第二代)大脑电池汲取的电流。电流值表示机器人从电池消耗的电量,可以帮助您了解机器人的工作强度或电机是否承受过大负载。
Available Functionsdouble current( currentUnits units = currentUnits::amp );
范围 |
类型 |
描述 |
|---|---|---|
|
|
Optional. The unit used to represent current: |
Returns a double representing the electrical current drawn from the IQ (2nd gen) Brain battery in amperes, ranging from 0.0 to 15.0 Amps.