59 #include <boost/version.hpp> 
   60 #if BOOST_VERSION < 108300 
   61 #include <boost/timer.hpp> 
   63 #include <boost/timer/timer.hpp> 
   72 #if BOOST_VERSION < 108300 
   75     boost::timer::cpu_timer timer;
 
   77     int num_of_trials = 1000000;
 
   78     int total_number_of_iter = 0;
 
   80     int nrofresult_ok = 0;
 
   81     int nrofresult_minus1=0;
 
   82     int nrofresult_minus2=0;
 
   83     int nrofresult_minus3=0;
 
   84     int min_num_of_iter = 10000000;
 
   85     int max_num_of_iter = 0;
 
   86     double min_diff = 1E10;
 
   88     double min_trans_diff = 1E10;
 
   89     double max_trans_diff = 0;
 
   90     double min_rot_diff = 1E10;
 
   91     double max_rot_diff = 0;
 
   92     Eigen::Matrix<double,6,1> L;
 
   94     L(3)=0.01;L(4)=0.01;L(5)=0.01;
 
  100     for (
int trial=0;trial<num_of_trials;++trial) {
 
  103         q_init.
data.setRandom();
 
  110         retval = solver.
CartToJnt(q_init,pos_goal,q_sol);
 
  139             std::cout << 
"jacobian of solved values ";
 
  157     std::cout << 
"------------------ statistics ------------------------------"<<
std::endl;
 
  162     std::cout << 
"average number of iter " << (double)total_number_of_iter/(
double)num_of_trials << 
std::endl;
 
  171 #if BOOST_VERSION < 108300 
  172     double el = timer.elapsed();
 
  174     boost::timer::cpu_times 
const ct(timer.elapsed());
 
  175     double el = ct.user / 1e9;
 
  178     std::cout << 
"estimate of average time per invposkin (ms)" << el/num_of_trials*1000 << 
std::endl;
 
  179     std::cout << 
"estimate of longest time per invposkin (ms) " << el/total_number_of_iter*max_num_of_iter *1000 << 
std::endl;
 
  180     std::cout << 
"estimate of shortest time per invposkin (ms) " << el/total_number_of_iter*min_num_of_iter *1000 << 
std::endl;
 
  183 int main(
int argc,
char* argv[]) {
 
  184     std::cout << 
" This example generates random joint positions, applies a forward kinematic transformation,\n" 
  185               <<  
" and calls ChainIkSolverPos_LMA on the resulting pose.  In this way we are sure that\n" 
  186               <<  
" the resulting pose is reachable.  However, some percentage of the trials will be at\n" 
  187               <<  
" near singular position, where it is more difficult to achieve convergence and accuracy\n" 
  188               <<  
" The initial position given to the algorithm is also a random joint position\n" 
  189               <<  
" This routine asks for an accuracy of 10 micrometer, one order of magnitude better than a\n" 
  190               <<  
" a typical industrial robot.\n" 
  191               <<  
" This routine can take more then 6 minutes to execute. It then gives statistics on execution times\n" 
  192               <<  
" and failures.\n" 
  193               <<  
" Typically when executed 1 000 000 times, you will still see some small amount of failures\n" 
  194               <<  
" Typically these failures are in the neighbourhood of singularities.  Most failures of type -2 still\n" 
  195               <<  
" reach an accuracy better than 1E-4.\n" 
  196               <<  
" This is much better than ChainIkSolverPos_NR, which fails a few times per 100 trials.\n";