|
| 1 | +:github_url: https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/battery_state_broadcaster/doc/userdoc.rst |
| 2 | + |
| 3 | +.. _battery_state_broadcaster_userdoc: |
| 4 | + |
| 5 | +Battery State Broadcaster |
| 6 | +-------------------------------- |
| 7 | +The *Battery State Broadcaster* is a ROS 2 controller that publishes battery status information as ``sensor_msgs/msg/BatteryState`` messages. |
| 8 | + |
| 9 | +It reads battery-related state interfaces from one or more joints and exposes them in a standard ROS 2 message format. This allows easy integration with monitoring tools, logging systems, and higher-level decision-making nodes. |
| 10 | + |
| 11 | +Interfaces |
| 12 | +^^^^^^^^^^^ |
| 13 | + |
| 14 | +The broadcaster can read the following state interfaces from each configured joint: |
| 15 | + |
| 16 | +- ``battery_voltage`` *(mandatory)* (double) |
| 17 | +- ``battery_temperature`` *(optional)* (double) |
| 18 | +- ``battery_current`` *(optional)* (double) |
| 19 | +- ``battery_charge`` *(optional)* (double) |
| 20 | +- ``battery_percentage`` *(optional)* (double) |
| 21 | +- ``battery_power_supply_status`` *(optional)* (double) |
| 22 | +- ``battery_power_supply_health`` *(optional)* (double) |
| 23 | +- ``battery_present`` *(optional)* (bool) |
| 24 | + |
| 25 | +Published Topics |
| 26 | +^^^^^^^^^^^^^^^^^^ |
| 27 | + |
| 28 | +The broadcaster publishes two topics: |
| 29 | + |
| 30 | +- ``~/raw_battery_states`` (``control_msgs/msg/BatteryStates``) |
| 31 | + Publishes **per-joint battery state messages**, containing the raw values for each configured joint. |
| 32 | + |
| 33 | +- ``~/battery_state`` (``sensor_msgs/msg/BatteryState``) |
| 34 | + Publishes a **single aggregated battery message** representing the combined status across all joints. |
| 35 | + |
| 36 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 37 | +| Field | ``battery_state`` | ``raw_battery_states`` | |
| 38 | ++=============================+======================================================================+=============================================================================================================================================+ |
| 39 | +| ``header.frame_id`` | Empty | Joint name | |
| 40 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 41 | +| ``voltage`` | Mean across all joints | From joint's ``battery_voltage`` interface if enabled, otherwise nan | |
| 42 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 43 | +| ``temperature`` | Mean across joints reporting temperature | From joint's ``battery_temperature`` interface if enabled, otherwise nan. | |
| 44 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 45 | +| ``current`` | Mean across joints reporting current | From joint's ``battery_current`` interface if enabled, otherwise nan. | |
| 46 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 47 | +| ``charge`` | Sum across all joints | From joint's ``battery_charge`` interface if enabled, otherwise nan. | |
| 48 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 49 | +| ``capacity`` | Sum across all joints | From joint's ``capacity`` parameter if provided, otherwise nan. | |
| 50 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 51 | +| ``design_capacity`` | Sum across all joints | From joint's ``design_capacity`` parameter if provided, otherwise nan. | |
| 52 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 53 | +| ``percentage`` | Mean across joints reporting/calculating percentage | From joint's ``battery_percentage`` interface if enabled, otherwise calculated from joint's ``min_voltage`` and ``max_voltage`` parameters. | |
| 54 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 55 | +| ``power_supply_status`` | Highest reported enum value | From joint's ``battery_power_supply_status`` interface if enabled, otherwise 0 (unknown). | |
| 56 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 57 | +| ``power_supply_health`` | Highest reported enum value | From joint's ``battery_power_supply_health`` interface if enabled, otherwise 0 (unknown). | |
| 58 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 59 | +| ``power_supply_technology`` | Reported as-is if same across all joints, otherwise set to *Unknown* | From joint's ``power_supply_technology`` parameter if provided, otherwise 0 (unknown). | |
| 60 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 61 | +| ``present`` | True | From joint's ``battery_present`` interface if enabled, otherwise true if joint's voltage values is valid. | |
| 62 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 63 | +| ``cell_voltage`` | Empty | Empty | |
| 64 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 65 | +| ``cell_temperature`` | Empty | Empty | |
| 66 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 67 | +| ``location`` | All joint locations appended | From joint's ``location`` parameter if provided, otherwise empty. | |
| 68 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 69 | +| ``serial_number`` | All joint serial numbers appended | From joint's ``serial_number`` parameter if provided, otherwise empty. | |
| 70 | ++-----------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ |
| 71 | + |
| 72 | + |
| 73 | +Parameters |
| 74 | +^^^^^^^^^^^ |
| 75 | +This controller uses the `generate_parameter_library <https://github.com/PickNikRobotics/generate_parameter_library>`_ to manage parameters. |
| 76 | +The parameter `definition file <https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/battery_state_broadcaster/src/battery_state_broadcaster_parameters.yaml>`_ contains the full list and descriptions. |
| 77 | + |
| 78 | +List of parameters |
| 79 | +========================= |
| 80 | +.. generate_parameter_library_details:: ../src/battery_state_broadcaster_parameters.yaml |
| 81 | + |
| 82 | +Example Parameter File |
| 83 | +========================= |
| 84 | + |
| 85 | +An example parameter file for this controller is available in the `test directory <https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/battery_state_broadcaster/test/battery_state_broadcaster_params.yaml>`_: |
| 86 | + |
| 87 | +.. literalinclude:: ../test/battery_state_broadcaster_params.yaml |
| 88 | + :language: yaml |
0 commit comments