61#ifndef YARP_ROSMSG_sensor_msgs_BatteryState_h
62#define YARP_ROSMSG_sensor_msgs_BatteryState_h
78 static const std::uint8_t POWER_SUPPLY_STATUS_UNKNOWN = 0;
79 static const std::uint8_t POWER_SUPPLY_STATUS_CHARGING = 1;
80 static const std::uint8_t POWER_SUPPLY_STATUS_DISCHARGING = 2;
81 static const std::uint8_t POWER_SUPPLY_STATUS_NOT_CHARGING = 3;
82 static const std::uint8_t POWER_SUPPLY_STATUS_FULL = 4;
83 static const std::uint8_t POWER_SUPPLY_HEALTH_UNKNOWN = 0;
84 static const std::uint8_t POWER_SUPPLY_HEALTH_GOOD = 1;
85 static const std::uint8_t POWER_SUPPLY_HEALTH_OVERHEAT = 2;
86 static const std::uint8_t POWER_SUPPLY_HEALTH_DEAD = 3;
87 static const std::uint8_t POWER_SUPPLY_HEALTH_OVERVOLTAGE = 4;
88 static const std::uint8_t POWER_SUPPLY_HEALTH_UNSPEC_FAILURE = 5;
89 static const std::uint8_t POWER_SUPPLY_HEALTH_COLD = 6;
90 static const std::uint8_t POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE = 7;
91 static const std::uint8_t POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE = 8;
92 static const std::uint8_t POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0;
93 static const std::uint8_t POWER_SUPPLY_TECHNOLOGY_NIMH = 1;
94 static const std::uint8_t POWER_SUPPLY_TECHNOLOGY_LION = 2;
95 static const std::uint8_t POWER_SUPPLY_TECHNOLOGY_LIPO = 3;
96 static const std::uint8_t POWER_SUPPLY_TECHNOLOGY_LIFE = 4;
97 static const std::uint8_t POWER_SUPPLY_TECHNOLOGY_NICD = 5;
98 static const std::uint8_t POWER_SUPPLY_TECHNOLOGY_LIMN = 6;
106 std::uint8_t power_supply_status;
107 std::uint8_t power_supply_health;
108 std::uint8_t power_supply_technology;
110 std::vector<yarp::conf::float32_t> cell_voltage;
111 std::string location;
112 std::string serial_number;
120 design_capacity(0.0f),
122 power_supply_status(0),
123 power_supply_health(0),
124 power_supply_technology(0),
192 design_capacity = 0.0f;
198 power_supply_status = 0;
201 power_supply_health = 0;
204 power_supply_technology = 0;
210 cell_voltage.clear();
222 if (!header.
read(connection)) {
245 power_supply_status = connection.
expectInt8();
248 power_supply_health = connection.
expectInt8();
251 power_supply_technology = connection.
expectInt8();
260 cell_voltage.resize(len);
267 location.resize(len);
268 if (!connection.
expectBlock((
char*)location.c_str(), len)) {
274 serial_number.resize(len);
275 if (!connection.
expectBlock((
char*)serial_number.c_str(), len)) {
291 if (!header.
read(connection)) {
320 power_supply_technology = reader.
expectInt8();
330 cell_voltage.resize(len);
331 for (
int i=0; i<len; i++) {
351 return (connection.
isBareMode() ? readBare(connection)
352 : readBottle(connection));
358 if (!header.
write(connection)) {
387 connection.
appendInt8(power_supply_technology);
394 if (cell_voltage.size()>0) {
415 if (!header.
write(connection)) {
453 connection.
appendInt8(power_supply_technology);
462 for (
size_t i=0; i<cell_voltage.size(); i++) {
483 return (connection.
isBareMode() ? writeBare(connection)
484 : writeBottle(connection));
493 static constexpr const char* typeName =
"sensor_msgs/BatteryState";
496 static constexpr const char* typeChecksum =
"476f837fa6771f6e16e3bf4ef96f8770";
499 static constexpr const char* typeText =
"\
501# Constants are chosen to match the enums in the linux kernel\n\
502# defined in include/linux/power_supply.h as of version 3.7\n\
503# The one difference is for style reasons the constants are\n\
504# all uppercase not mixed case.\n\
506# Power supply status constants\n\
507uint8 POWER_SUPPLY_STATUS_UNKNOWN = 0\n\
508uint8 POWER_SUPPLY_STATUS_CHARGING = 1\n\
509uint8 POWER_SUPPLY_STATUS_DISCHARGING = 2\n\
510uint8 POWER_SUPPLY_STATUS_NOT_CHARGING = 3\n\
511uint8 POWER_SUPPLY_STATUS_FULL = 4\n\
513# Power supply health constants\n\
514uint8 POWER_SUPPLY_HEALTH_UNKNOWN = 0\n\
515uint8 POWER_SUPPLY_HEALTH_GOOD = 1\n\
516uint8 POWER_SUPPLY_HEALTH_OVERHEAT = 2\n\
517uint8 POWER_SUPPLY_HEALTH_DEAD = 3\n\
518uint8 POWER_SUPPLY_HEALTH_OVERVOLTAGE = 4\n\
519uint8 POWER_SUPPLY_HEALTH_UNSPEC_FAILURE = 5\n\
520uint8 POWER_SUPPLY_HEALTH_COLD = 6\n\
521uint8 POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE = 7\n\
522uint8 POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE = 8\n\
524# Power supply technology (chemistry) constants\n\
525uint8 POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0\n\
526uint8 POWER_SUPPLY_TECHNOLOGY_NIMH = 1\n\
527uint8 POWER_SUPPLY_TECHNOLOGY_LION = 2\n\
528uint8 POWER_SUPPLY_TECHNOLOGY_LIPO = 3\n\
529uint8 POWER_SUPPLY_TECHNOLOGY_LIFE = 4\n\
530uint8 POWER_SUPPLY_TECHNOLOGY_NICD = 5\n\
531uint8 POWER_SUPPLY_TECHNOLOGY_LIMN = 6\n\
534float32 voltage # Voltage in Volts (Mandatory)\n\
535float32 current # Negative when discharging (A) (If unmeasured NaN)\n\
536float32 charge # Current charge in Ah (If unmeasured NaN)\n\
537float32 capacity # Capacity in Ah (last full capacity) (If unmeasured NaN)\n\
538float32 design_capacity # Capacity in Ah (design capacity) (If unmeasured NaN)\n\
539float32 percentage # Charge percentage on 0 to 1 range (If unmeasured NaN)\n\
540uint8 power_supply_status # The charging status as reported. Values defined above\n\
541uint8 power_supply_health # The battery health metric. Values defined above\n\
542uint8 power_supply_technology # The battery chemistry. Values defined above\n\
543bool present # True if the battery is present\n\
545float32[] cell_voltage # An array of individual cell voltages for each cell in the pack\n\
546 # If individual voltages unknown but number of cells known set each to NaN\n\
547string location # The location into which the battery is inserted. (slot number or plug)\n\
548string serial_number # The best approximation of the battery serial number\n\
550================================================================================\n\
551MSG: std_msgs/Header\n\
552# Standard metadata for higher-level stamped data types.\n\
553# This is generally used to communicate timestamped data \n\
554# in a particular coordinate frame.\n\
556# sequence ID: consecutively increasing ID \n\
558#Two-integer timestamp that is expressed as:\n\
559# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
560# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
561# time-handling sugar is provided by the client library\n\
563#Frame this data is associated with\n\
#define BOTTLE_TAG_STRING
#define BOTTLE_TAG_FLOAT32
An interface for reading from a network connection.
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
virtual yarp::conf::float32_t expectFloat32()=0
Read a 32-bit floating point number from the network connection.
virtual bool isError() const =0
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
An interface for writing to a network connection.
virtual bool isError() const =0
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
static Type byName(const char *name)
Type & addProperty(const char *key, const Value &val)
A single value (typically within a Bottle).
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
virtual bool read(yarp::os::idl::WireReader &reader)
virtual bool write(const yarp::os::idl::WireWriter &writer) const
IDL-friendly connection reader.
bool readString(std::string &str, bool *is_vocab=nullptr)
yarp::conf::float32_t expectFloat32()
yarp::rosmsg::sensor_msgs::BatteryState BatteryState
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
The main, catch-all namespace for YARP.