17 #include <gtest/gtest.h>
24 #include "yaml-cpp/exceptions.h"
27 TEST(SrHandAutodetect, test_run_unimanual)
29 std::string expected_command_suffix =
" eth_port:=eth0 hand_serial:=1130 side:=right"
30 " hand_type:=hand_e_plus hand_version:=E3M5 fingers:=th,ff,mf,rf,lf"
31 " tip_sensors:=ff=bt_sp,lf=bt_sp,mf=bt_sp,rf=bt_sp,th=bt_sp mid_sensors:=none"
32 " prox_sensors:=none palm_sensor:=none";
34 std::string detected_hands_file =
ros::package::getPath(
"sr_hand_detector") +
"/test/config/test_unimanual.yaml";
37 sr_hand_autodetect.
run();
41 TEST(SrHandAutodetect, test_run_unimanual_additional_params)
43 std::string expected_command_suffix =
" eth_port:=eth0 hand_serial:=634 side:=right"
44 " hand_type:=hand_e hand_version:=E3M5 fingers:=th,ff,mf,rf,lf"
45 " tip_sensors:=ff=pst,lf=pst,mf=pst,rf=pst,th=pst mid_sensors:=none"
46 " prox_sensors:=none palm_sensor:=none";
48 expected_command_suffix +=
" mapping_path:=" + expected_mapping_path;
52 "/test/config/test_unimanual_additional_params.yaml";
55 sr_hand_autodetect.
run();
59 TEST(SrHandAutodetect, test_run_bimanual)
61 std::string expected_rh_mapping_path =
ros::package::getPath(
"sr_hand_detector") +
"/rh_mapping.yaml";
62 std::string expected_lh_mapping_path =
ros::package::getPath(
"sr_hand_detector") +
"/lh_mapping.yaml";
63 std::string expected_command_suffix =
" eth_port:=eth0_eth1 rh_serial:=634 lh_serial:=2346 right_hand_type:=hand_e"
64 " right_hand_version:=E3M5 right_fingers:=th,ff,mf,rf,lf"
65 " right_tip_sensors:=ff=pst,lf=pst,mf=pst,rf=pst,th=pst"
66 " right_mid_sensors:=none right_prox_sensors:=none right_palm_sensor:=none"
67 " rh_mapping_path:=" + expected_rh_mapping_path +
68 " left_hand_type:=hand_e left_hand_version:=E3M5 left_fingers:=th,ff,mf,rf,lf"
69 " left_tip_sensors:=ff=bt_sp,lf=bt_sp,mf=bt_sp,rf=bt_sp,th=bt_sp"
70 " left_mid_sensors:=none left_prox_sensors:=none left_palm_sensor:=none"
71 " lh_mapping_path:=" + expected_lh_mapping_path;
74 std::string detected_hands_file =
ros::package::getPath(
"sr_hand_detector") +
"/test/config/test_bimanual.yaml";
77 sr_hand_autodetect.
run();
81 TEST(SrHandAutodetect, test_run_bimanual_forced_side)
83 std::string expected_command_suffix =
" eth_port:=eth0 hand_serial:=634 side:=right"
84 " hand_type:=hand_e hand_version:=E3M5 fingers:=th,ff,mf,rf,lf"
85 " tip_sensors:=ff=pst,lf=pst,mf=pst,rf=pst,th=pst mid_sensors:=none"
86 " prox_sensors:=none palm_sensor:=none";
88 expected_command_suffix +=
" mapping_path:=" + expected_mapping_path;
91 std::string detected_hands_file =
ros::package::getPath(
"sr_hand_detector") +
"/test/config/test_bimanual.yaml";
95 sr_hand_autodetect.
run();
99 TEST(SrHandAutodetect, test_run_no_hands)
101 std::string expected_command_suffix =
"";
103 std::string detected_hands_file =
ros::package::getPath(
"sr_hand_detector") +
"/test/config/test_no_hands.yaml";
106 sr_hand_autodetect.
run();
110 TEST(SrHandAutodetect, test_run_non_existing_hand)
114 "/test/config/test_non_existing_hand.yaml";
116 ASSERT_THROW(sr_hand_autodetect.
run(), YAML::BadFile);
119 int main(
int argc,
char **argv)
121 ros::init(argc, argv,
"test_sr_hand_autodetect");
123 testing::InitGoogleTest(&argc, argv);
124 return RUN_ALL_TESTS();