Skip to content

Commit 03be204

Browse files
authored
added support to boost::timer 1.83+ (#463)
* added support to boost::timer 1.83+ * update also the cmake file
1 parent faa74b7 commit 03be204

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

orocos_kdl/examples/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ IF(ENABLE_EXAMPLES)
88
TARGET_LINK_LIBRARIES(trajectory_example orocos-kdl)
99

1010
add_executable(chainiksolverpos_lma_demo chainiksolverpos_lma_demo.cpp )
11-
TARGET_LINK_LIBRARIES(chainiksolverpos_lma_demo orocos-kdl orocos-kdl-models)
11+
find_package(Boost REQUIRED)
12+
IF(${Boost_VERSION_MACRO} LESS 108300)
13+
TARGET_LINK_LIBRARIES(chainiksolverpos_lma_demo orocos-kdl orocos-kdl-models)
14+
ELSE()
15+
TARGET_LINK_LIBRARIES(chainiksolverpos_lma_demo boost_timer orocos-kdl orocos-kdl-models)
16+
ENDIF()
1217

1318
ENDIF(ENABLE_EXAMPLES)
1419

orocos_kdl/examples/chainiksolverpos_lma_demo.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,24 @@ estimate of shortest time per invposkin (ms) 0.155544
5656
#include <chainfksolverpos_recursive.hpp>
5757
#include <utilities/utility.h>
5858

59+
#include <boost/version.hpp>
60+
#if BOOST_VERSION < 108300
5961
#include <boost/timer.hpp>
62+
#else
63+
#include <boost/timer/timer.hpp>
64+
#endif
6065

6166
/**
6267
* tests the inverse kinematics on the given kinematic chain for a
6368
* large number of times and provides statistics on the result.
6469
* \TODO provide other examples.
6570
*/
6671
void test_inverseposkin(KDL::Chain& chain) {
72+
#if BOOST_VERSION < 108300
6773
boost::timer timer;
74+
#else
75+
boost::timer::cpu_timer timer;
76+
#endif
6877
int num_of_trials = 1000000;
6978
int total_number_of_iter = 0;
7079
int n = chain.getNrOfJoints();
@@ -159,7 +168,12 @@ void test_inverseposkin(KDL::Chain& chain) {
159168
std::cout << "max. trans. difference after solving " << max_trans_diff << std::endl;
160169
std::cout << "min. rot. difference after solving " << min_rot_diff << std::endl;
161170
std::cout << "max. rot. difference after solving " << max_rot_diff << std::endl;
171+
#if BOOST_VERSION < 108300
162172
double el = timer.elapsed();
173+
#else
174+
boost::timer::cpu_times const ct(timer.elapsed());
175+
double el = ct.user / 1e9;
176+
#endif
163177
std::cout << "elapsed time " << el << std::endl;
164178
std::cout << "estimate of average time per invposkin (ms)" << el/num_of_trials*1000 << std::endl;
165179
std::cout << "estimate of longest time per invposkin (ms) " << el/total_number_of_iter*max_num_of_iter *1000 << std::endl;

0 commit comments

Comments
 (0)