Skip to content

Commit

Permalink
added support to boost::timer 1.83+ (#463)
Browse files Browse the repository at this point in the history
* added support to boost::timer 1.83+

* update also the cmake file
  • Loading branch information
efferre79 authored Jun 10, 2024
1 parent faa74b7 commit 03be204
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion orocos_kdl/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ IF(ENABLE_EXAMPLES)
TARGET_LINK_LIBRARIES(trajectory_example orocos-kdl)

add_executable(chainiksolverpos_lma_demo chainiksolverpos_lma_demo.cpp )
TARGET_LINK_LIBRARIES(chainiksolverpos_lma_demo orocos-kdl orocos-kdl-models)
find_package(Boost REQUIRED)
IF(${Boost_VERSION_MACRO} LESS 108300)
TARGET_LINK_LIBRARIES(chainiksolverpos_lma_demo orocos-kdl orocos-kdl-models)
ELSE()
TARGET_LINK_LIBRARIES(chainiksolverpos_lma_demo boost_timer orocos-kdl orocos-kdl-models)
ENDIF()

ENDIF(ENABLE_EXAMPLES)

14 changes: 14 additions & 0 deletions orocos_kdl/examples/chainiksolverpos_lma_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,24 @@ estimate of shortest time per invposkin (ms) 0.155544
#include <chainfksolverpos_recursive.hpp>
#include <utilities/utility.h>

#include <boost/version.hpp>
#if BOOST_VERSION < 108300
#include <boost/timer.hpp>
#else
#include <boost/timer/timer.hpp>
#endif

/**
* tests the inverse kinematics on the given kinematic chain for a
* large number of times and provides statistics on the result.
* \TODO provide other examples.
*/
void test_inverseposkin(KDL::Chain& chain) {
#if BOOST_VERSION < 108300
boost::timer timer;
#else
boost::timer::cpu_timer timer;
#endif
int num_of_trials = 1000000;
int total_number_of_iter = 0;
int n = chain.getNrOfJoints();
Expand Down Expand Up @@ -159,7 +168,12 @@ void test_inverseposkin(KDL::Chain& chain) {
std::cout << "max. trans. difference after solving " << max_trans_diff << std::endl;
std::cout << "min. rot. difference after solving " << min_rot_diff << std::endl;
std::cout << "max. rot. difference after solving " << max_rot_diff << std::endl;
#if BOOST_VERSION < 108300
double el = timer.elapsed();
#else
boost::timer::cpu_times const ct(timer.elapsed());
double el = ct.user / 1e9;
#endif
std::cout << "elapsed time " << el << std::endl;
std::cout << "estimate of average time per invposkin (ms)" << el/num_of_trials*1000 << std::endl;
std::cout << "estimate of longest time per invposkin (ms) " << el/total_number_of_iter*max_num_of_iter *1000 << std::endl;
Expand Down

0 comments on commit 03be204

Please sign in to comment.