|
18 | 18 | #include <lifecycle_msgs/msg/state.hpp> |
19 | 19 | #include <lifecycle_msgs/msg/transition_event.hpp> |
20 | 20 |
|
21 | | -#include <boost/program_options.hpp> |
22 | | - |
23 | 21 | #include <chrono> |
24 | 22 | #include <memory> |
25 | 23 | #include <string> |
@@ -49,66 +47,16 @@ using system_modes::msg::ModeEvent; |
49 | 47 | using lifecycle_msgs::msg::State; |
50 | 48 | using lifecycle_msgs::msg::TransitionEvent; |
51 | 49 |
|
52 | | -using boost::program_options::value; |
53 | | -using boost::program_options::bool_switch; |
54 | | -using boost::program_options::variables_map; |
55 | | -using boost::program_options::command_line_parser; |
56 | | -using boost::program_options::options_description; |
57 | | -using boost::program_options::positional_options_description; |
58 | | - |
59 | 50 | using rcl_interfaces::msg::ParameterType; |
60 | 51 | using rcl_interfaces::msg::ParameterEvent; |
61 | 52 |
|
62 | 53 | string modelfile, loglevel; |
63 | 54 | bool debug = false; |
64 | 55 | unsigned int rate = 1000; |
65 | 56 | bool verbose = false; |
66 | | -options_description options("Allowed options"); |
67 | 57 |
|
68 | 58 | shared_ptr<system_modes::ModeMonitor> monitor; |
69 | 59 |
|
70 | | -bool parseOptions(int argc, char * argv[]) |
71 | | -{ |
72 | | - options.add_options()("help", "Help message and options")( |
73 | | - "modelfile", |
74 | | - value<string>(&modelfile), "Path to yaml model file")( |
75 | | - "__log_level", |
76 | | - value<string>(&loglevel), "ROS 2 log level")( |
77 | | - "debug,d", bool_switch(&debug)->default_value(false), |
78 | | - "Debug mode (don't clear screen)")( |
79 | | - "rate,r", value<unsigned int>(&rate)->default_value(1000), |
80 | | - "Update rate in milliseconds")( |
81 | | - "verbose,v", bool_switch(&verbose)->default_value(false), |
82 | | - "Verbose (displays mode parameters)")( |
83 | | - "ros-args", value<vector<string>>()->multitoken(), |
84 | | - "ROS args")( |
85 | | - "params-file", value<vector<string>>()->multitoken(), |
86 | | - "ROS params file"); |
87 | | - |
88 | | - positional_options_description positional_options; |
89 | | - positional_options.add("modelfile", 1); |
90 | | - positional_options.add("debug", 0); |
91 | | - positional_options.add("rate", 1); |
92 | | - positional_options.add("verbose", 0); |
93 | | - |
94 | | - variables_map map; |
95 | | - store( |
96 | | - command_line_parser(argc, argv) |
97 | | - .options(options) |
98 | | - .positional(positional_options) |
99 | | - .run(), map); |
100 | | - notify(map); |
101 | | - |
102 | | - if (map.count("help")) { |
103 | | - return true; |
104 | | - } |
105 | | - |
106 | | - // if (modelfile.empty()) { |
107 | | - // throw invalid_argument("Need path to model file."); |
108 | | - // } |
109 | | - return false; |
110 | | -} |
111 | | - |
112 | 60 | void transition_callback( |
113 | 61 | const TransitionEvent::SharedPtr msg, |
114 | 62 | const string & node_name) |
@@ -169,22 +117,6 @@ int main(int argc, char * argv[]) |
169 | 117 | { |
170 | 118 | using namespace std::placeholders; |
171 | 119 |
|
172 | | - // Handle commandline arguments. |
173 | | - try { |
174 | | - if (parseOptions(argc, argv)) { |
175 | | - cout << "Usage: mode_monitor MODELFILE" << endl; |
176 | | - cout << options; |
177 | | - cout << "Or specify the MODELFILE by ROS parameter 'modelfile'." << std::endl << std::endl; |
178 | | - return EXIT_SUCCESS; |
179 | | - } |
180 | | - } catch (const exception & e) { |
181 | | - cerr << "Error parsing command line: " << e.what() << endl; |
182 | | - cout << "Usage: mode_monitor MODELFILE" << endl; |
183 | | - cout << options; |
184 | | - cout << "Or specify the MODELFILE by ROS parameter 'modelfile'." << std::endl << std::endl; |
185 | | - return EXIT_FAILURE; |
186 | | - } |
187 | | - |
188 | 120 | setvbuf(stdout, NULL, _IONBF, BUFSIZ); |
189 | 121 | rclcpp::init(argc, argv); |
190 | 122 |
|
|
0 commit comments