> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Publish the battery state with qrb_ros_battery

> The qrb_ros_battery sample application is a package that publishes the battery state data from the system node.

The `qrb_ros_battery` package communicates with the battery service through DBus. The battery service gets the current battery status by accessing the sys nodes.

## Pipeline flow for `qrb_ros_battery`

The following figure shows the pipeline flow for `qrb_ros_battery`.

<Frame caption="The qrb_ros_battery pipeline.">
  <img src="https://mintcdn.com/qualcomm-prod/eHVY1H1lLEVhgq58/SDKs/QIR-SDK-Ubuntu/images/image8.png?fit=max&auto=format&n=eHVY1H1lLEVhgq58&q=85&s=d6100002df1edfbac75dc05d9ceda599" style={{width: "70%"}} alt="QRB ROS Battery node wrapping the battery package, collecting voltage, temperature, current, charge, and capacity, and publishing /battery_stats." width="2216" height="1608" data-path="SDKs/QIR-SDK-Ubuntu/images/image8.png" />
</Frame>

## ROS nodes used in the `qrb_ros_battery` pipeline

The following table lists the ROS nodes used in the `qrb_ros_battery` pipeline and describes what each node does.

| ROS node | Description                                                          |
| -------- | -------------------------------------------------------------------- |
| Battery  | Publishes the battery information through the `battery_stats` topic. |

## ROS topic used in the `qrb_ros_battery` pipeline

The following table lists the ROS topics used in the `qrb_ros_battery` pipeline, with the message type and a description of each topic.

| ROS topic        | Type                               | Description                                                                                |
| ---------------- | ---------------------------------- | ------------------------------------------------------------------------------------------ |
| `/battery_stats` | `<sensor_msgs::msg::BatteryState>` | Battery system information, including voltage, temperature, current, charge, and capacity. |

## Prerequisites

You have set up the device, installed ROS2 Jazzy and the Qualcomm Intelligent Robotics (QIR) SDK on the device according to [Install the QIR SDK](./install-the-qir-sdk).

## Run out-of-the-box `qrb_ros_battery`

<Steps>
  <Step title="Run the battery node">
    ```bash Run the battery node theme={null}
    source /opt/ros/jazzy/setup.bash
    ros2 run qrb_ros_battery battery_node
    ```
  </Step>

  <Step title="Get the topic of this node">
    ```bash List the ROS topics theme={null}
    source /opt/ros/jazzy/setup.bash
    ros2 topic list
    ```
  </Step>

  <Step title="Echo the battery information">
    ```bash Echo the battery topic theme={null}
    source /opt/ros/jazzy/setup.bash
    ros2 topic echo /battery_stats
    ```
  </Step>
</Steps>

### Example output

The following figure shows the terminal output of `ros2 topic echo /battery_stats`.

<Frame>
  <img src="https://mintcdn.com/qualcomm-prod/eHVY1H1lLEVhgq58/SDKs/QIR-SDK-Ubuntu/images/image9.png?fit=max&auto=format&n=eHVY1H1lLEVhgq58&q=85&s=af386081dd1222472c15463959cfc72b" alt="Terminal output of the battery_stats topic listing voltage, temperature, current, charge, capacity, percentage, power supply status, and serial number." width="661" height="554" data-path="SDKs/QIR-SDK-Ubuntu/images/image9.png" />
</Frame>
