battery.cpp
Go to the documentation of this file.
2 #include <muse_v2_driver/Battery.h>
3 
4 int main(int argc, char** argv)
5 {
6  ros::init(argc, argv, "battery");
7 
9 
11 
12  misc.setupInputCommands(n);
13 
14  ros::ServiceClient client = n.serviceClient<muse_v2_driver::Battery>("battery");
15 
16  if (misc.input_command == misc.default_command_list) {
17  ROS_ERROR("No request found.");
18  ros::shutdown();
19  return -1;
20  }
21 
22  muse_v2_driver::Battery srv;
23 
25  srv.request.get_battery_charge = true;
26 
28  srv.request.get_battery_voltage = true;
29 
30  if (client.call(srv))
31  {
32  if (srv.request.get_battery_charge)
33  ROS_INFO("Battery charge (%%): %.2f", srv.response.battery_charge);
34 
35  if (srv.request.get_battery_voltage)
36  ROS_INFO("Battery voltage: %.2f", srv.response.battery_voltage);
37  }
38  else
39  {
40  ROS_ERROR("Failed to call battery service.");
41  return 1;
42  }
43 
44  return 0;
45 }
muse_v2_driver::Miscellaneous
Definition: Miscellaneous.h:9
muse_v2_driver::Miscellaneous::default_command_list
struct muse_v2_driver::Miscellaneous::CommandList default_command_list
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
main
int main(int argc, char **argv)
Definition: battery.cpp:4
Miscellaneous.h
muse_v2_driver::Miscellaneous::CommandList::get_battery_charge
bool get_battery_charge
Definition: Miscellaneous.h:15
ros::NodeHandle::serviceClient
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
ros::shutdown
ROSCPP_DECL void shutdown()
muse_v2_driver::Miscellaneous::setupInputCommands
void setupInputCommands(ros::NodeHandle &node)
Definition: Miscellaneous.cpp:3
ros::ServiceClient
muse_v2_driver::Miscellaneous::input_command
CommandList input_command
Definition: Miscellaneous.h:27
ROS_ERROR
#define ROS_ERROR(...)
ros::ServiceClient::call
bool call(const MReq &req, MRes &resp, const std::string &service_md5sum)
muse_v2_driver::Miscellaneous::CommandList::get_battery_voltage
bool get_battery_voltage
Definition: Miscellaneous.h:16
ROS_INFO
#define ROS_INFO(...)
ros::NodeHandle


muse_v2_driver
Author(s): Elisa Tosello , Roberto Bortoletto
autogenerated on Thu Jan 20 2022 03:24:53