test_iksolvers.cpp
Go to the documentation of this file.
1 
21 #include <ctime>
22 
24 {
25  bool found_ik;
27 
28  public:
29  TestIKsolvers();
30  void AddSceneObjects(void);
31  bool TestRandomState(void);
32 };
33 
35 {
36 }
37 
39 {
40  robot_state::RobotStatePtr test_state = group.getCurrentState();
41 
43  geometry_msgs::PoseStamped random_pose = group.getRandomPose();
44 
45  found_ik = test_state->setFromIK(group.getCurrentState()->getRobotModel()->getJointModelGroup(group.getName()),
46  random_pose.pose, 10, 0.1);
47 
48  if (found_ik)
49  {
50  return true;
51  }
52  else
53  {
54  ROS_INFO("Did not find IK solution");
55  ROS_INFO_STREAM("Pose:"<< random_pose.pose);
56  return false;
57  }
58 }
59 
60 int main(int argc, char **argv)
61 {
62  ros::init(argc, argv, "testing iksolvers");
63 
65  spinner.start();
66  int num_succeeded_positions = 0;
67  double maximum = 0.0;
68  double minimum = 100;
69 
70  double elapsed_secs;
71 
72  clock_t global_begin = clock();
73 
74  TestIKsolvers *testIKsolvers = new TestIKsolvers();
75  int total_random_queries = 10000;
76  for (std::size_t i = 0; i < total_random_queries; i++)
77  {
78  clock_t begin = clock();
79  bool succeed = testIKsolvers->TestRandomState();
80  if (succeed)
81  {
82  num_succeeded_positions++;
83  }
84  clock_t end = clock();
85  elapsed_secs = static_cast<double>(end - begin) / CLOCKS_PER_SEC;
86  maximum = (elapsed_secs > maximum)?elapsed_secs:maximum;
87  minimum = (elapsed_secs < minimum)?elapsed_secs:minimum;
88  }
89  clock_t global_end = clock();
90  double global_elapsed_secs = static_cast<double>(global_end - global_begin) / CLOCKS_PER_SEC;
91  ROS_INFO_STREAM("Number of valid ik plans " << num_succeeded_positions << "/" << total_random_queries);
92  ROS_INFO_STREAM("Total time taken " << global_elapsed_secs);
93  ROS_INFO_STREAM("Average time per test " << global_elapsed_secs/total_random_queries);
94  ROS_INFO_STREAM("Maximum time per test " << maximum);
95 
96  ros::shutdown();
97  return 0;
98 }
99 
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void spinner()
#define ROS_INFO(...)
void setStartState(const moveit_msgs::RobotState &start_state)
geometry_msgs::PoseStamped getRandomPose(const std::string &end_effector_link="")
robot_state::RobotStatePtr getCurrentState(double wait=1)
void AddSceneObjects(void)
#define ROS_INFO_STREAM(args)
ROSCPP_DECL void shutdown()
bool TestRandomState(void)
moveit::planning_interface::MoveGroupInterface group


sr_multi_moveit_test
Author(s): Beatriz Leon
autogenerated on Wed Oct 14 2020 04:05:26