8 #include <gtest/gtest.h> 17 #include <boost/foreach.hpp> 27 pair<string, string> item;
28 BOOST_FOREACH(item, map)
30 if (value == item.second)
39 TEST(SrHandFinder, hand_absent_test)
52 map<string, vector<string> > hand_joints(hand_finder.
get_joints());
53 ASSERT_EQ(hand_joints.size(), 0);
55 ASSERT_EQ(calibration_path.size(), 0);
57 ASSERT_EQ(controller_tuning.friction_compensation_.size(), 0);
58 ASSERT_EQ(controller_tuning.host_control_.size(), 0);
59 ASSERT_EQ(controller_tuning.motor_control_.size(), 0);
62 TEST(SrHandFinder, one_hand_no_robot_description_finder_test)
80 "FFJ1",
"FFJ2",
"FFJ3",
"FFJ4",
"MFJ1",
"MFJ2",
"MFJ3",
"MFJ4",
81 "RFJ1",
"RFJ2",
"RFJ3",
"RFJ4",
"LFJ1",
"LFJ2",
"LFJ3",
"LFJ4",
"LFJ5",
82 "THJ1",
"THJ2",
"THJ3",
"THJ4",
"THJ5",
"WRJ1",
"WRJ2" 94 ASSERT_GT(hand_finder.
get_joints().count(
"right"), 0);
95 const vector<string> rh_joints = hand_finder.
get_joints().at(
"right");
96 ASSERT_EQ(rh_joints.size(), 24);
97 for (
size_t i = 0; i < rh_joints.size(); ++i)
100 ASSERT_STREQ(rh_joints[i].c_str(), (
"rh_" + joint_names[i]).c_str());
107 ASSERT_STREQ(calibration_path.c_str(), (ethercat_path +
"/calibrations/right/" +
"calibration.yaml").c_str());
112 for (map<string, string>::const_iterator iter = controller_tuning.friction_compensation_.begin();
113 iter != controller_tuning.friction_compensation_.end(); ++iter)
115 ASSERT_STREQ(iter->second.c_str(), (ethercat_path +
"/controls/friction_compensation.yaml").c_str());
118 for (map<string, string>::const_iterator iter = controller_tuning.motor_control_.begin();
119 iter != controller_tuning.motor_control_.end(); ++iter)
121 ASSERT_STREQ(iter->second.c_str(),
122 (ethercat_path +
"/controls/motors/right/motor_board_effort_controllers.yaml").c_str());
125 for (map<
string, vector<string> >::const_iterator iter = controller_tuning.host_control_.begin();
126 iter != controller_tuning.host_control_.end(); ++iter)
128 string host_array[] =
130 "sr_edc_calibration_controllers.yaml",
131 "sr_edc_joint_velocity_controllers_PWM.yaml",
132 "sr_edc_effort_controllers_PWM.yaml",
133 "sr_edc_joint_velocity_controllers.yaml",
134 "sr_edc_effort_controllers.yaml",
135 "sr_edc_mixed_position_velocity_joint_controllers_PWM.yaml",
136 "sr_edc_joint_position_controllers_PWM.yaml",
137 "sr_edc_mixed_position_velocity_joint_controllers.yaml",
138 "sr_edc_joint_position_controllers.yaml" 140 vector<string> host_controller_files(host_array, host_array + 9);
141 ASSERT_EQ(host_controller_files.size(), iter->second.size());
142 for (
size_t i = 0; i != iter->second.size(); ++i)
144 ASSERT_STREQ(iter->second[i].c_str(), (ethercat_path +
"/controls/host/right/" +
145 host_controller_files[i]).c_str());
151 TEST(SrHandFinder, one_hand_no_mapping_no_robot_description_finder_test)
169 "FFJ1",
"FFJ2",
"FFJ3",
"FFJ4",
"MFJ1",
"MFJ2",
"MFJ3",
"MFJ4",
170 "RFJ1",
"RFJ2",
"RFJ3",
"RFJ4",
"LFJ1",
"LFJ2",
"LFJ3",
"LFJ4",
"LFJ5",
171 "THJ1",
"THJ2",
"THJ3",
"THJ4",
"THJ5",
"WRJ1",
"WRJ2" 182 ASSERT_EQ(hand_finder.
get_joints().size(), 1);
183 ASSERT_GT(hand_finder.
get_joints().count(
"1"), 0);
184 const vector<string> rh_joints = hand_finder.
get_joints().at(
"1");
185 ASSERT_EQ(rh_joints.size(), 24);
186 for (
size_t i = 0; i < rh_joints.size(); ++i)
189 ASSERT_STREQ(rh_joints[i].c_str(), (
"rh_" + joint_names[i]).c_str());
196 ASSERT_STREQ(calibration_path.c_str(), (ethercat_path +
"/calibrations/1/" +
"calibration.yaml").c_str());
201 for (map<string, string>::const_iterator iter = controller_tuning.friction_compensation_.begin();
202 iter != controller_tuning.friction_compensation_.end(); ++iter)
204 ASSERT_STREQ(iter->second.c_str(), (ethercat_path +
"/controls/friction_compensation.yaml").c_str());
207 for (map<string, string>::const_iterator iter = controller_tuning.motor_control_.begin();
208 iter != controller_tuning.motor_control_.end(); ++iter)
210 ASSERT_STREQ(iter->second.c_str(),
211 (ethercat_path +
"/controls/motors/1/motor_board_effort_controllers.yaml").c_str());
214 for (map<
string, vector<string> >::const_iterator iter = controller_tuning.host_control_.begin();
215 iter != controller_tuning.host_control_.end(); ++iter)
217 string host_array[] =
219 "sr_edc_calibration_controllers.yaml",
220 "sr_edc_joint_velocity_controllers_PWM.yaml",
221 "sr_edc_effort_controllers_PWM.yaml",
222 "sr_edc_joint_velocity_controllers.yaml",
223 "sr_edc_effort_controllers.yaml",
224 "sr_edc_mixed_position_velocity_joint_controllers_PWM.yaml",
225 "sr_edc_joint_position_controllers_PWM.yaml",
226 "sr_edc_mixed_position_velocity_joint_controllers.yaml",
227 "sr_edc_joint_position_controllers.yaml" 229 vector<string> host_controller_files(host_array, host_array + 9);
230 ASSERT_EQ(host_controller_files.size(), iter->second.size());
231 for (
size_t i = 0; i != iter->second.size(); ++i)
233 ASSERT_STREQ(iter->second[i].c_str(), (ethercat_path +
"/controls/host/1/" + host_controller_files[i]).c_str());
239 TEST(SrHandFinder, one_hand_no_prefix_no_robot_description_finder_test)
257 "FFJ1",
"FFJ2",
"FFJ3",
"FFJ4",
"MFJ1",
"MFJ2",
"MFJ3",
"MFJ4",
258 "RFJ1",
"RFJ2",
"RFJ3",
"RFJ4",
"LFJ1",
"LFJ2",
"LFJ3",
"LFJ4",
"LFJ5",
259 "THJ1",
"THJ2",
"THJ3",
"THJ4",
"THJ5",
"WRJ1",
"WRJ2" 270 ASSERT_EQ(hand_finder.
get_joints().size(), 1);
271 ASSERT_GT(hand_finder.
get_joints().count(
"rh"), 0);
272 const vector<string> rh_joints = hand_finder.
get_joints().at(
"rh");
273 ASSERT_EQ(rh_joints.size(), 24);
274 for (
size_t i = 0; i < rh_joints.size(); ++i)
277 ASSERT_STREQ(rh_joints[i].c_str(), (joint_names[i]).c_str());
284 ASSERT_STREQ(calibration_path.c_str(), (ethercat_path +
"/calibrations/rh/" +
"calibration.yaml").c_str());
289 for (map<string, string>::const_iterator iter = controller_tuning.friction_compensation_.begin();
290 iter != controller_tuning.friction_compensation_.end(); ++iter)
292 ASSERT_STREQ(iter->second.c_str(), (ethercat_path +
"/controls/friction_compensation.yaml").c_str());
295 for (map<string, string>::const_iterator iter = controller_tuning.motor_control_.begin();
296 iter != controller_tuning.motor_control_.end(); ++iter)
298 ASSERT_STREQ(iter->second.c_str(),
299 (ethercat_path +
"/controls/motors/rh/motor_board_effort_controllers.yaml").c_str());
302 for (map<
string, vector<string> >::const_iterator iter = controller_tuning.host_control_.begin();
303 iter != controller_tuning.host_control_.end(); ++iter)
305 string host_array[] =
307 "sr_edc_calibration_controllers.yaml",
308 "sr_edc_joint_velocity_controllers_PWM.yaml",
309 "sr_edc_effort_controllers_PWM.yaml",
310 "sr_edc_joint_velocity_controllers.yaml",
311 "sr_edc_effort_controllers.yaml",
312 "sr_edc_mixed_position_velocity_joint_controllers_PWM.yaml",
313 "sr_edc_joint_position_controllers_PWM.yaml",
314 "sr_edc_mixed_position_velocity_joint_controllers.yaml",
315 "sr_edc_joint_position_controllers.yaml" 317 vector<string> host_controller_files(host_array, host_array + 9);
318 ASSERT_EQ(host_controller_files.size(), iter->second.size());
319 for (
size_t i = 0; i != iter->second.size(); ++i)
321 ASSERT_STREQ(iter->second[i].c_str(), (ethercat_path +
"/controls/host/rh/" + host_controller_files[i]).c_str());
327 TEST(SrHandFinder, one_hand_no_mapping_no_prefix_no_robot_description_finder_test)
345 "FFJ1",
"FFJ2",
"FFJ3",
"FFJ4",
"MFJ1",
"MFJ2",
"MFJ3",
"MFJ4",
346 "RFJ1",
"RFJ2",
"RFJ3",
"RFJ4",
"LFJ1",
"LFJ2",
"LFJ3",
"LFJ4",
"LFJ5",
347 "THJ1",
"THJ2",
"THJ3",
"THJ4",
"THJ5",
"WRJ1",
"WRJ2" 358 ASSERT_EQ(hand_finder.
get_joints().size(), 1);
359 ASSERT_GT(hand_finder.
get_joints().count(
"1"), 0);
360 const vector<string> rh_joints = hand_finder.
get_joints().at(
"1");
361 ASSERT_EQ(rh_joints.size(), 24);
362 for (
size_t i = 0; i < rh_joints.size(); ++i)
365 ASSERT_STREQ(rh_joints[i].c_str(), (joint_names[i]).c_str());
372 ASSERT_STREQ(calibration_path.c_str(), (ethercat_path +
"/calibrations/1/" +
"calibration.yaml").c_str());
377 for (map<string, string>::const_iterator iter = controller_tuning.friction_compensation_.begin();
378 iter != controller_tuning.friction_compensation_.end(); ++iter)
380 ASSERT_STREQ(iter->second.c_str(), (ethercat_path +
"/controls/friction_compensation.yaml").c_str());
383 for (map<string, string>::const_iterator iter = controller_tuning.motor_control_.begin();
384 iter != controller_tuning.motor_control_.end(); ++iter)
386 ASSERT_STREQ(iter->second.c_str(),
387 (ethercat_path +
"/controls/motors/1/motor_board_effort_controllers.yaml").c_str());
390 for (map<
string, vector<string> >::const_iterator iter = controller_tuning.host_control_.begin();
391 iter != controller_tuning.host_control_.end(); ++iter)
393 string host_array[] =
395 "sr_edc_calibration_controllers.yaml",
396 "sr_edc_joint_velocity_controllers_PWM.yaml",
397 "sr_edc_effort_controllers_PWM.yaml",
398 "sr_edc_joint_velocity_controllers.yaml",
399 "sr_edc_effort_controllers.yaml",
400 "sr_edc_mixed_position_velocity_joint_controllers_PWM.yaml",
401 "sr_edc_joint_position_controllers_PWM.yaml",
402 "sr_edc_mixed_position_velocity_joint_controllers.yaml",
403 "sr_edc_joint_position_controllers.yaml" 405 vector<string> host_controller_files(host_array, host_array + 9);
406 ASSERT_EQ(host_controller_files.size(), iter->second.size());
407 for (
size_t i = 0; i != iter->second.size(); ++i)
409 ASSERT_STREQ(iter->second[i].c_str(), (ethercat_path +
"/controls/host/1/" + host_controller_files[i]).c_str());
415 TEST(SrHandFinder, one_hand_robot_description_exists_finger_test)
427 string right_hand_description;
436 "FFJ1",
"FFJ2",
"FFJ3",
"FFJ4",
"MFJ1",
"MFJ2",
"MFJ3",
"MFJ4",
437 "RFJ1",
"RFJ2",
"RFJ3",
"RFJ4",
"LFJ1",
"LFJ2",
"LFJ3",
"LFJ4",
"LFJ5",
438 "THJ1",
"THJ2",
"THJ3",
"THJ4",
"THJ5",
"WRJ1",
"WRJ2" 449 ASSERT_EQ(hand_finder.
get_joints().size(), 1);
450 ASSERT_GT(hand_finder.
get_joints().count(
"right"), 0);
451 const vector<string> rh_joints = hand_finder.
get_joints().at(
"right");
452 ASSERT_EQ(rh_joints.size(), 1);
453 ASSERT_EQ(std::find(rh_joints.begin(), rh_joints.end(),
"rh_FFJ3"), rh_joints.end());
454 ASSERT_NE(std::find(rh_joints.begin(), rh_joints.end(),
"rh_RFJ4"), rh_joints.end());
460 ASSERT_STREQ(calibration_path.c_str(), (ethercat_path +
"/calibrations/right/" +
"calibration.yaml").c_str());
465 for (map<string, string>::const_iterator iter = controller_tuning.friction_compensation_.begin();
466 iter != controller_tuning.friction_compensation_.end(); ++iter)
468 ASSERT_STREQ(iter->second.c_str(), (ethercat_path +
"/controls/friction_compensation.yaml").c_str());
471 for (map<string, string>::const_iterator iter = controller_tuning.motor_control_.begin();
472 iter != controller_tuning.motor_control_.end(); ++iter)
474 ASSERT_STREQ(iter->second.c_str(),
475 (ethercat_path +
"/controls/motors/right/motor_board_effort_controllers.yaml").c_str());
478 for (map<
string, vector<string> >::const_iterator iter = controller_tuning.host_control_.begin();
479 iter != controller_tuning.host_control_.end(); ++iter)
481 string host_array[] =
483 "sr_edc_calibration_controllers.yaml",
484 "sr_edc_joint_velocity_controllers_PWM.yaml",
485 "sr_edc_effort_controllers_PWM.yaml",
486 "sr_edc_joint_velocity_controllers.yaml",
487 "sr_edc_effort_controllers.yaml",
488 "sr_edc_mixed_position_velocity_joint_controllers_PWM.yaml",
489 "sr_edc_joint_position_controllers_PWM.yaml",
490 "sr_edc_mixed_position_velocity_joint_controllers.yaml",
491 "sr_edc_joint_position_controllers.yaml" 493 vector<string> host_controller_files(host_array, host_array + 9);
494 ASSERT_EQ(host_controller_files.size(), iter->second.size());
495 for (
size_t i = 0; i != iter->second.size(); ++i)
497 ASSERT_STREQ(iter->second[i].c_str(), (ethercat_path +
"/controls/host/right/" 498 + host_controller_files[i]).c_str());
504 TEST(SrHandFinder, two_hand_robot_description_exists_finder_test)
521 string two_hands_description;
527 "FFJ1",
"FFJ2",
"FFJ3",
"FFJ4",
"MFJ1",
"MFJ2",
"MFJ3",
"MFJ4",
528 "RFJ1",
"RFJ2",
"RFJ3",
"RFJ4",
"LFJ1",
"LFJ2",
"LFJ3",
"LFJ4",
"LFJ5",
529 "THJ1",
"THJ2",
"THJ3",
"THJ4",
"THJ5",
"WRJ1",
"WRJ2" 533 const string dir[] = {
"left",
"right"};
539 ASSERT_EQ(hand_finder.
get_joints().size(), 2);
548 ASSERT_GT(hand_finder.
get_joints().count(
"right"), 0);
549 const vector<string> rh_joints = hand_finder.
get_joints().at(
"right");
550 ASSERT_EQ(std::find(rh_joints.begin(), rh_joints.end(),
"rh_FFJ3"), rh_joints.end());
551 ASSERT_NE(std::find(rh_joints.begin(), rh_joints.end(),
"rh_RFJ4"), rh_joints.end());
553 ASSERT_GT(hand_finder.
get_joints().count(
"left"), 0);
554 const vector<string> lh_joints = hand_finder.
get_joints().at(
"left");
555 ASSERT_EQ(std::find(lh_joints.begin(), lh_joints.end(),
"lh_FFJ1"), lh_joints.end());
556 ASSERT_NE(std::find(lh_joints.begin(), lh_joints.end(),
"lh_LFJ4"), lh_joints.end());
561 for (map<string, string>::const_iterator iter = calibration_path.begin(); iter != calibration_path.end(); ++iter)
564 ASSERT_STREQ(iter->second.c_str(), (ethercat_path +
"/calibrations/" 565 + dir[idx] +
"/" +
"calibration.yaml").c_str());
570 for (map<string, string>::const_iterator iter = controller_tuning.friction_compensation_.begin();
571 iter != controller_tuning.friction_compensation_.end(); ++iter)
573 ASSERT_STREQ(iter->second.c_str(), (ethercat_path +
"/controls/friction_compensation.yaml").c_str());
578 for (map<string, string>::const_iterator iter = controller_tuning.motor_control_.begin();
579 iter != controller_tuning.motor_control_.end(); ++iter)
581 ASSERT_STREQ(iter->second.c_str(),
582 (ethercat_path +
"/controls/motors/" + dir[idx] +
"/motor_board_effort_controllers.yaml").c_str());
588 for (map<
string, vector<string> >::const_iterator iter = controller_tuning.host_control_.begin();
589 iter != controller_tuning.host_control_.end(); ++iter)
591 string host_array[] =
593 "sr_edc_calibration_controllers.yaml",
594 "sr_edc_joint_velocity_controllers_PWM.yaml",
595 "sr_edc_effort_controllers_PWM.yaml",
596 "sr_edc_joint_velocity_controllers.yaml",
597 "sr_edc_effort_controllers.yaml",
598 "sr_edc_mixed_position_velocity_joint_controllers_PWM.yaml",
599 "sr_edc_joint_position_controllers_PWM.yaml",
600 "sr_edc_mixed_position_velocity_joint_controllers.yaml",
601 "sr_edc_joint_position_controllers.yaml" 603 vector<string> host_controller_files(host_array, host_array + 9);
604 ASSERT_EQ(host_controller_files.size(), iter->second.size());
605 for (
size_t i = 0; i != iter->second.size(); ++i)
607 ASSERT_STREQ(iter->second[i].c_str(), (ethercat_path +
"/controls/host/" 608 + dir[idx] +
"/" + host_controller_files[i]).c_str());
616 int main(
int argc,
char **argv)
618 ros::init(argc, argv,
"test_hand_finder");
620 testing::InitGoogleTest(&argc, argv);
621 return RUN_ALL_TESTS();
TEST(SrHandFinder, hand_absent_test)
HandControllerTuning get_hand_controller_tuning()
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void ASSERT_MAP_HAS_VALUE(const map< string, string > &map, const string &value)
std::map< std::string, std::string > mapping_
ROSCPP_DECL void set(const std::string &key, const XmlRpc::XmlRpcValue &v)
ROSCPP_DECL bool get(const std::string &key, std::string &s)
int main(int argc, char **argv)
HandConfig get_hand_parameters()
ROSCPP_DECL bool has(const std::string &key)
std::map< std::string, std::string > get_calibration_path()
#define ROS_DEBUG_STREAM(args)
std::map< std::string, std::vector< std::string > > get_joints()
ROSLIB_DECL std::string getPath(const std::string &package_name)
ROSCPP_DECL bool del(const std::string &key)
std::map< std::string, std::string > joint_prefix_