sr_hand_autodetect.h
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 #ifndef SR_HAND_DETECTOR_SR_HAND_AUTODETECT_H
18 #define SR_HAND_DETECTOR_SR_HAND_AUTODETECT_H
19 
20 #include <string>
21 #include <map>
22 #include <vector>
23 
25 #include "yaml-cpp/yaml.h"
26 
28 {
29 
30 enum class ForcedHandSide {none, right, left};
31 
33 {
34  public:
35  explicit SrHandAutodetect(std::string detected_hands_file = "/tmp/sr_hand_detector.yaml",
36  std::string hand_config_path = "",
37  ForcedHandSide forced_hand_side = ForcedHandSide::none);
39  void run();
40  std::string get_command_suffix();
41 
42  private:
44  YAML::Node get_hand_general_info(int serial);
45  void detect_hands();
50  std::string vector_to_xacro_string(const std::vector<std::string> &vec);
51  std::string map_to_xacro_string(const std::map<std::string, std::string> &map);
52  std::vector<std::string> yaml_node_list_to_std_vector(const YAML::Node &node);
53  std::map<std::string, std::string> yaml_node_map_to_std_map(const YAML::Node &node_map);
54  std::string command_suffix_bimanual_per_hand(const YAML::Node &hand_info);
55  std::string hand_side_to_prefix(const std::string &side);
56 
59  std::string sr_hand_config_path_;
60  std::string detected_hands_file_;
61  std::string command_suffix_;
62  std::map<int, std::string> hand_serial_and_port_map_;
63 };
64 } // namespace sr_hand_detector
65 
66 #endif // SR_HAND_DETECTOR_SR_HAND_AUTODETECT_H
sr_hand_detector::SrHandAutodetect::map_to_xacro_string
std::string map_to_xacro_string(const std::map< std::string, std::string > &map)
Definition: sr_hand_autodetect.cpp:266
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::hand_serial_and_port_map_
std::map< int, std::string > hand_serial_and_port_map_
Definition: sr_hand_autodetect.h:62
sr_hand_detector::SrHandAutodetect::yaml_node_list_to_std_vector
std::vector< std::string > yaml_node_list_to_std_vector(const YAML::Node &node)
Definition: sr_hand_autodetect.cpp:281
sr_hand_detector::SrHandAutodetect::forced_hand_side_
ForcedHandSide forced_hand_side_
Definition: sr_hand_autodetect.h:57
sr_hand_detector::SrHandAutodetect
Definition: sr_hand_autodetect.h:32
sr_hand_detector::SrHandAutodetect::command_suffix_bimanual_per_hand
std::string command_suffix_bimanual_per_hand(const YAML::Node &hand_info)
Definition: sr_hand_autodetect.cpp:213
sr_hand_detector::SrHandAutodetect::detect_hands
void detect_hands()
Definition: sr_hand_autodetect.cpp:85
sr_hand_detector::SrHandAutodetect::hand_side_to_prefix
std::string hand_side_to_prefix(const std::string &side)
Definition: sr_hand_autodetect.cpp:237
sr_hand_detector
Definition: sr_hand_autodetect.h:27
sr_hand_detector::SrHandAutodetect::compose_command_suffix_unimanual
void compose_command_suffix_unimanual()
Definition: sr_hand_autodetect.cpp:152
sr_hand_detector.h
sr_hand_detector::SrHandAutodetect::yaml_node_map_to_std_map
std::map< std::string, std::string > yaml_node_map_to_std_map(const YAML::Node &node_map)
Definition: sr_hand_autodetect.cpp:293
sr_hand_detector::SrHandAutodetect::command_suffix_
std::string command_suffix_
Definition: sr_hand_autodetect.h:61
sr_hand_detector::SrHandAutodetect::compose_command_suffix
void compose_command_suffix()
Definition: sr_hand_autodetect.cpp:130
sr_hand_detector::SrHandAutodetect::get_path_to_sr_hand_config
void get_path_to_sr_hand_config()
Definition: sr_hand_autodetect.cpp:50
sr_hand_detector::SrHandAutodetect::compose_command_suffix_bimanual
void compose_command_suffix_bimanual()
Definition: sr_hand_autodetect.cpp:179
sr_hand_detector::SrHandAutodetect::detected_hands_file_
std::string detected_hands_file_
Definition: sr_hand_autodetect.h:60
sr_hand_detector::ForcedHandSide::right
@ right
sr_hand_detector::SrHandAutodetect::SrHandAutodetect
SrHandAutodetect(std::string detected_hands_file="/tmp/sr_hand_detector.yaml", std::string hand_config_path="", ForcedHandSide forced_hand_side=ForcedHandSide::none)
Definition: sr_hand_autodetect.cpp:30
sr_hand_detector::SrHandAutodetect::vector_to_xacro_string
std::string vector_to_xacro_string(const std::vector< std::string > &vec)
Definition: sr_hand_autodetect.cpp:251
sr_hand_detector::ForcedHandSide::left
@ left
sr_hand_detector::SrHandAutodetect::number_of_detected_hands_
int number_of_detected_hands_
Definition: sr_hand_autodetect.h:58
sr_hand_detector::ForcedHandSide::none
@ none
sr_hand_detector::SrHandAutodetect::sr_hand_config_path_
std::string sr_hand_config_path_
Definition: sr_hand_autodetect.h:59
sr_hand_detector::SrHandAutodetect::~SrHandAutodetect
~SrHandAutodetect()
Definition: sr_hand_autodetect.cpp:46
sr_hand_detector::ForcedHandSide
ForcedHandSide
Definition: sr_hand_autodetect.h:30
sr_hand_detector::SrHandAutodetect::filter_hands_if_side_forced
void filter_hands_if_side_forced()
Definition: sr_hand_autodetect.cpp:95
sr_hand_detector::SrHandAutodetect::get_hand_general_info
YAML::Node get_hand_general_info(int serial)
Definition: sr_hand_autodetect.cpp:71


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