Class BatteryStateMsg
ROS sensor_msgs/BatteryState message.
Implements
Inherited Members
Namespace: Unity.SimulationPro.Foundation.SensorMessages
Assembly: Unity.SimulationPro.Foundation.dll
Syntax
[Serializable]
public class BatteryStateMsg : IMessage
Constructors
BatteryStateMsg()
Initializes a new instance with default values.
Declaration
public BatteryStateMsg()
BatteryStateMsg(HeaderMsg, float, float, float, float, float, float, float, byte, byte, byte, bool, float[], float[], string, string)
Initializes a new instance with the specified values.
Declaration
public BatteryStateMsg(HeaderMsg header, float voltage, float temperature, float current, float charge, float capacity, float design_capacity, float percentage, byte power_supply_status, byte power_supply_health, byte power_supply_technology, bool present, float[] cell_voltage, float[] cell_temperature, string location, string serial_number)
Parameters
| Type | Name | Description |
|---|---|---|
| HeaderMsg | header | ROS message header containing timestamp and coordinate frame identifier. |
| float | voltage | Battery terminal voltage in Volts. |
| float | temperature | Measured temperature in degrees Celsius. |
| float | current | Instantaneous current draw in Amperes; negative when discharging. |
| float | charge | Remaining charge in Ampere-hours (NaN if unmeasured). |
| float | capacity | Total capacity in Ampere-hours (NaN if unmeasured). |
| float | design_capacity | Design capacity of the battery in Ampere-hours. |
| float | percentage | Charge percentage (0.0-1.0), or NaN if unmeasured. |
| byte | power_supply_status | Battery charging status code. |
| byte | power_supply_health | Battery health status code. |
| byte | power_supply_technology | Battery chemistry/technology code. |
| bool | present | Whether the battery is physically present. |
| float[] | cell_voltage | Array of individual cell voltages. |
| float[] | cell_temperature | Array of individual cell temperatures. |
| string | location | Free-form string describing the battery location. |
| string | serial_number | Battery serial number string. |
Fields
POWER_SUPPLY_HEALTH_COLD
Constant value for POWER_SUPPLY_HEALTH_COLD.
Declaration
public const byte POWER_SUPPLY_HEALTH_COLD = 6
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_HEALTH_DEAD
Constant value for POWER_SUPPLY_HEALTH_DEAD.
Declaration
public const byte POWER_SUPPLY_HEALTH_DEAD = 3
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_HEALTH_GOOD
Constant value for POWER_SUPPLY_HEALTH_GOOD.
Declaration
public const byte POWER_SUPPLY_HEALTH_GOOD = 1
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_HEALTH_OVERHEAT
Constant value for POWER_SUPPLY_HEALTH_OVERHEAT.
Declaration
public const byte POWER_SUPPLY_HEALTH_OVERHEAT = 2
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_HEALTH_OVERVOLTAGE
Constant value for POWER_SUPPLY_HEALTH_OVERVOLTAGE.
Declaration
public const byte POWER_SUPPLY_HEALTH_OVERVOLTAGE = 4
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE
Constant value for POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE.
Declaration
public const byte POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE = 8
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_HEALTH_UNKNOWN
Power supply health constants
Declaration
public const byte POWER_SUPPLY_HEALTH_UNKNOWN = 0
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_HEALTH_UNSPEC_FAILURE
Constant value for POWER_SUPPLY_HEALTH_UNSPEC_FAILURE.
Declaration
public const byte POWER_SUPPLY_HEALTH_UNSPEC_FAILURE = 5
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE
Constant value for POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE.
Declaration
public const byte POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE = 7
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_STATUS_CHARGING
Constant value for POWER_SUPPLY_STATUS_CHARGING.
Declaration
public const byte POWER_SUPPLY_STATUS_CHARGING = 1
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_STATUS_DISCHARGING
Constant value for POWER_SUPPLY_STATUS_DISCHARGING.
Declaration
public const byte POWER_SUPPLY_STATUS_DISCHARGING = 2
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_STATUS_FULL
Constant value for POWER_SUPPLY_STATUS_FULL.
Declaration
public const byte POWER_SUPPLY_STATUS_FULL = 4
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_STATUS_NOT_CHARGING
Constant value for POWER_SUPPLY_STATUS_NOT_CHARGING.
Declaration
public const byte POWER_SUPPLY_STATUS_NOT_CHARGING = 3
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_STATUS_UNKNOWN
Constants are chosen to match the enums in the linux kernel defined in include/linux/power_supply.h as of version 3.7 The one difference is for style reasons the constants are all uppercase not mixed case. Power supply status constants
Declaration
public const byte POWER_SUPPLY_STATUS_UNKNOWN = 0
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_TECHNOLOGY_LIFE
Constant value for POWER_SUPPLY_TECHNOLOGY_LIFE.
Declaration
public const byte POWER_SUPPLY_TECHNOLOGY_LIFE = 4
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_TECHNOLOGY_LIMN
Constant value for POWER_SUPPLY_TECHNOLOGY_LIMN.
Declaration
public const byte POWER_SUPPLY_TECHNOLOGY_LIMN = 6
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_TECHNOLOGY_LION
Constant value for POWER_SUPPLY_TECHNOLOGY_LION.
Declaration
public const byte POWER_SUPPLY_TECHNOLOGY_LION = 2
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_TECHNOLOGY_LIPO
Constant value for POWER_SUPPLY_TECHNOLOGY_LIPO.
Declaration
public const byte POWER_SUPPLY_TECHNOLOGY_LIPO = 3
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_TECHNOLOGY_NICD
Constant value for POWER_SUPPLY_TECHNOLOGY_NICD.
Declaration
public const byte POWER_SUPPLY_TECHNOLOGY_NICD = 5
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_TECHNOLOGY_NIMH
Constant value for POWER_SUPPLY_TECHNOLOGY_NIMH.
Declaration
public const byte POWER_SUPPLY_TECHNOLOGY_NIMH = 1
Field Value
| Type | Description |
|---|---|
| byte |
POWER_SUPPLY_TECHNOLOGY_UNKNOWN
Power supply technology (chemistry) constants
Declaration
public const byte POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0
Field Value
| Type | Description |
|---|---|
| byte |
capacity
Capacity in Ah (last full capacity) (If unmeasured NaN)
Declaration
public float capacity
Field Value
| Type | Description |
|---|---|
| float |
cell_temperature
An array of individual cell temperatures for each cell in the pack If individual temperatures unknown but number of cells known set each to NaN
Declaration
public float[] cell_temperature
Field Value
| Type | Description |
|---|---|
| float[] |
cell_voltage
An array of individual cell voltages for each cell in the pack If individual voltages unknown but number of cells known set each to NaN
Declaration
public float[] cell_voltage
Field Value
| Type | Description |
|---|---|
| float[] |
charge
Current charge in Ah (If unmeasured NaN)
Declaration
public float charge
Field Value
| Type | Description |
|---|---|
| float |
current
Negative when discharging (A) (If unmeasured NaN)
Declaration
public float current
Field Value
| Type | Description |
|---|---|
| float |
design_capacity
Capacity in Ah (design capacity) (If unmeasured NaN)
Declaration
public float design_capacity
Field Value
| Type | Description |
|---|---|
| float |
header
Header field.
Declaration
public HeaderMsg header
Field Value
| Type | Description |
|---|---|
| HeaderMsg |
k_MessageTypeId
Identifier for this message type.
Declaration
public static readonly MessageTypeId k_MessageTypeId
Field Value
| Type | Description |
|---|---|
| MessageTypeId |
k_MessageTypeName
The ROS message type name string used for serialization and topic matching.
Declaration
public const string k_MessageTypeName = "sensor_msgs/BatteryState"
Field Value
| Type | Description |
|---|---|
| string |
location
The location into which the battery is inserted. (slot number or plug)
Declaration
public string location
Field Value
| Type | Description |
|---|---|
| string |
percentage
Charge percentage on 0 to 1 range (If unmeasured NaN)
Declaration
public float percentage
Field Value
| Type | Description |
|---|---|
| float |
power_supply_health
The battery health metric. Values defined above
Declaration
public byte power_supply_health
Field Value
| Type | Description |
|---|---|
| byte |
power_supply_status
The charging status as reported. Values defined above
Declaration
public byte power_supply_status
Field Value
| Type | Description |
|---|---|
| byte |
power_supply_technology
The battery chemistry. Values defined above
Declaration
public byte power_supply_technology
Field Value
| Type | Description |
|---|---|
| byte |
present
True if the battery is present
Declaration
public bool present
Field Value
| Type | Description |
|---|---|
| bool |
serial_number
The best approximation of the battery serial number
Declaration
public string serial_number
Field Value
| Type | Description |
|---|---|
| string |
temperature
Temperature in Degrees Celsius (If unmeasured NaN)
Declaration
public float temperature
Field Value
| Type | Description |
|---|---|
| float |
voltage
Voltage in Volts (Mandatory)
Declaration
public float voltage
Field Value
| Type | Description |
|---|---|
| float |
Properties
MessageTypeId
Gets the unique runtime identifier for this message type.
Declaration
public MessageTypeId MessageTypeId { get; }
Property Value
| Type | Description |
|---|---|
| MessageTypeId |
MessageTypeName
Gets the ROS message type name for this message.
Declaration
public string MessageTypeName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
Deserialize(IMessageDeserializer)
Deserializes a BatteryStateMsg from the given deserializer.
Declaration
public static BatteryStateMsg Deserialize(IMessageDeserializer deserializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IMessageDeserializer | deserializer | The deserializer. |
Returns
| Type | Description |
|---|---|
| BatteryStateMsg | A new BatteryStateMsg instance. |
Register()
Registers this message type with the MessageTypeRegistry.
Declaration
[InitializeOnLoadMethod]
public static void Register()
ToString()
Returns a human-readable string representation of this message.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string representation of this instance. |
Overrides
WriteTo(IMessageSerializer)
Serializes this message to the given serializer.
Declaration
public void WriteTo(IMessageSerializer serializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IMessageSerializer | serializer | The serializer. |