sr_hand_autodetect_node.cpp
Go to the documentation of this file.
1 /*
2 * Copyright 2020 Shadow Robot Company Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 
17 #include <iostream>
18 #include <string>
19 #include <ros/package.h>
21 
22 namespace
23 {
24  const std::string DETECTED_HANDS_FILE = "/tmp/sr_hand_detector.yaml";
25  const std::string HAND_CONFIG_PATH = "";
26 }
27 
28 int main(int argc, char* argv[])
29 {
30  int result = system("sr_hand_detector_node");
31  if (result != 0) return result;
32 
33  int iter = 1;
34  std::string first_arg = argv[iter];
36 
37  if (("--right-only" == first_arg) || ("-r" == first_arg))
38  {
39  forced_hand_side = sr_hand_detector::ForcedHandSide::right;
40  iter++;
41  }
42  else if (("--left-only" == first_arg) || ("-l" == first_arg))
43  {
44  forced_hand_side = sr_hand_detector::ForcedHandSide::left;
45  iter++;
46  }
47 
48  std::string command_string = "";
49  for (int i = iter; i < argc; ++i)
50  {
51  command_string += argv[i];
52  if (!(argc - 1 == i))
53  {
54  command_string += " ";
55  }
56  }
57 
58  sr_hand_detector::SrHandAutodetect sr_hand_autodetect(DETECTED_HANDS_FILE,
59  HAND_CONFIG_PATH,
60  forced_hand_side);
61  sr_hand_autodetect.run();
62 
63  command_string += sr_hand_autodetect.get_command_suffix();
64  std::cout << "Actual command run: " << command_string << std::endl;
65  return system(command_string.c_str());
66 }
sr_hand_detector::SrHandAutodetect::run
void run()
Definition: sr_hand_autodetect.cpp:59
sr_hand_detector::SrHandAutodetect::get_command_suffix
std::string get_command_suffix()
Definition: sr_hand_autodetect.cpp:66
sr_hand_detector::SrHandAutodetect
Definition: sr_hand_autodetect.h:32
main
int main(int argc, char *argv[])
Definition: sr_hand_autodetect_node.cpp:28
package.h
sr_hand_detector::ForcedHandSide::right
@ right
sr_hand_detector::ForcedHandSide::left
@ left
sr_hand_detector::ForcedHandSide::none
@ none
sr_hand_autodetect.h
sr_hand_detector::ForcedHandSide
ForcedHandSide
Definition: sr_hand_autodetect.h:30


sr_hand_detector
Author(s):
autogenerated on Sat Sep 24 2022 02:26:10