/power/battery_level#

Caution

This documentation page has been auto-generated.

It may be missing some details.

/power/battery_level Quick Facts

Category

Robot management

Message type

std_msgs/Float32

Direction

➡️ you normally subscribe to this topic.

Quick snippets#

Check the publication rate#
$ rostopic hz /power/battery_level
Display the data published on the topic#
$ rostopic echo /power/battery_level

How to use in your code#

Subscribe to the topic using Python#
 1import rospy
 2from std_msgs.msg import Float32
 3
 4def on_data(msg):
 5
 6   # see http://docs.ros.org/en/api/std_msgs/html/msg/Float32.html
 7   # for the msg structure
 8   print(msg)
 9
10if __name__ == "__main__":
11
12  rospy.init_node("subscriber")
13
14  rospy.Subscriber("/power/battery_level", Float32, on_data)
15
16  rospy.spin()
Subscribe to the topic using C++#
 1#include <ros/ros.h>
 2#include <std_msgs/Float32.h>
 3
 4void on_data(const std_msgs::Float32::ConstPrt& msg)
 5{
 6   // see http://docs.ros.org/en/api/std_msgs/html/msg/Float32.html
 7   // for the msg structure
 8   ROS_INFO_STREAM("Got " << msg);
 9}
10
11int main(int argc, char **argv)
12{
13  ros::init(argc, argv, "subscriber");
14  ros::NodeHandle n;
15
16  ros::Subscriber sub = n.subscribe("/power/battery_level", 10, on_data);
17
18  ros::spin();
19  return 0;
20}