set_configuration_params.cpp
Go to the documentation of this file.
2 
3 int main(int argc, char** argv)
4 {
5  ros::init(argc, argv, "set_configuration_params");
6 
8 
10 
11  config.setupInputCommands(n);
12 
13  ros::ServiceClient client = n.serviceClient<muse_v2_driver::SetConfigurationParams>("set_configuration_params");
14 
15  if (config.input_command == config.default_command_list) {
16  ROS_ERROR("No request found.");
17  ros::shutdown();
18  return -1;
19  }
20 
21  muse_v2_driver::SetConfigurationParams srv;
22 
23  if (config.input_command.gyroscope_full_scale != 0) {
24  srv.request.set_gyroscope_full_scale = true;
25  srv.request.gyroscope_full_scale = config.input_command.gyroscope_full_scale;
26  }
27 
28  if (config.input_command.accelerometer_full_scale != 0) {
29  srv.request.set_accelerometer_full_scale = true;
30  srv.request.accelerometer_full_scale = config.input_command.accelerometer_full_scale;
31  }
32 
34  srv.request.set_accelerometer_hdr_full_scale = true;
35  srv.request.accelerometer_hdr_full_scale = config.input_command.accelerometer_hdr_full_scale;
36  }
37 
38  if (config.input_command.magnetometer_full_scale != 0) {
39  srv.request.set_magnetometer_full_scale = true;
40  srv.request.magnetometer_full_scale = config.input_command.magnetometer_full_scale;
41  }
42 
43  if (config.input_command.log_mode != UINT8_MAX) {
44  srv.request.set_log_mode = true;
45  srv.request.log_mode = config.input_command.log_mode;
46  }
47 
48  if (config.input_command.log_frequency != UINT8_MAX) {
49  srv.request.set_log_frequency = true;
50  srv.request.log_frequency = config.input_command.log_frequency;
51  }
52 
53  if (client.call(srv))
54  {
55  if (srv.request.set_gyroscope_full_scale)
56  ROS_INFO("Gyroscope Full-Scale value changed: %s", srv.response.gyroscope_full_scale_changed ? "true" : "false");
57 
58  if (srv.request.set_accelerometer_full_scale)
59  ROS_INFO("Accelerometer Full-Scale value changed: %s", srv.response.accelerometer_full_scale_changed ? "true" : "false");
60 
61  if (srv.request.set_accelerometer_hdr_full_scale)
62  ROS_INFO("Accelerometer HDR Full-Scale value changed: %s", srv.response.accelerometer_hdr_full_scale_changed ? "true" : "false");
63 
64  if (srv.request.set_magnetometer_full_scale)
65  ROS_INFO("Magnetometer Full-Scale value changed: %s", srv.response.magnetometer_full_scale_changed ? "true" : "false");
66 
67  if (srv.request.set_log_mode)
68  ROS_INFO("Log Mode changed: %s", srv.response.log_mode_changed ? "true" : "false");
69 
70  if (srv.request.set_log_frequency)
71  ROS_INFO("Log Frequency changed: %s", srv.response.log_frequency_changed ? "true" : "false");
72  }
73  else
74  {
75  ROS_ERROR("Failed to call Set Configuration Params service.");
76  return 1;
77  }
78 
79  return 0;
80 }
muse_v2_driver::Configuration::CommandList::gyroscope_full_scale
uint16_t gyroscope_full_scale
Definition: Configuration.h:23
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
muse_v2_driver::Configuration::CommandList::log_mode
uint8_t log_mode
Definition: Configuration.h:27
muse_v2_driver::Configuration::CommandList::log_frequency
uint8_t log_frequency
Definition: Configuration.h:28
ros::NodeHandle::serviceClient
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
muse_v2_driver::Configuration::default_command_list
struct muse_v2_driver::Configuration::CommandList default_command_list
ros::shutdown
ROSCPP_DECL void shutdown()
muse_v2_driver::Configuration::CommandList::accelerometer_full_scale
uint8_t accelerometer_full_scale
Definition: Configuration.h:24
muse_v2_driver::Configuration::input_command
CommandList input_command
Definition: Configuration.h:48
ros::ServiceClient
muse_v2_driver::Configuration::CommandList::magnetometer_full_scale
uint8_t magnetometer_full_scale
Definition: Configuration.h:26
main
int main(int argc, char **argv)
Definition: set_configuration_params.cpp:3
muse_v2_driver::Configuration::setupInputCommands
void setupInputCommands(ros::NodeHandle &node)
Definition: Configuration.cpp:3
ROS_ERROR
#define ROS_ERROR(...)
ros::ServiceClient::call
bool call(const MReq &req, MRes &resp, const std::string &service_md5sum)
ROS_INFO
#define ROS_INFO(...)
muse_v2_driver::Configuration
Definition: Configuration.h:10
muse_v2_driver::Configuration::CommandList::accelerometer_hdr_full_scale
uint16_t accelerometer_hdr_full_scale
Definition: Configuration.h:25
Configuration.h
ros::NodeHandle


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