This ROS package provides a simple battery checking service. The service calculates whether the robot has enough battery to start a mission and returns:
- Remaining battery percentage
- Status message (Start mission / Recharge battery)
service_pkg/
├── srv/
│ └── check_b.srv
├── src/
│ ├── navigation_client.cpp
│ └── power_manager_server.cpp
├── CMakeLists.txt
└── package.xmlThe server receives the robot’s current battery level and the mission power consumption, then calculates the remaining battery. Based on the result, it returns one of two status messages:
- “Start your mission” — if battery is sufficient
- “Battery low, please recharge” — if battery is below the threshold
check_b.srv
float32 mission_consumption
float32 battery_level
---
string status
float32 after_battery_level- Receives battery level + mission consumption
- Calculates remaining battery
- Returns mission status message
rosrun service_pkg power_manager_server- Sends request to service
- Prints remaining battery
- Prints mission status
rosrun service_pkg req_blevel_client <battery_level> <mission_consumption>rosrun service_pkg req_blevel_client 70 25Status: Start your mission
Battery Level After Mission: 45.00%request: battery level before start = 70.00%, and mission consumption = 25.00%
sending back response: [Start your mission], Battery level after mission: 45.00%