3 #include <boost/program_options.hpp> 12 std::vector<RobotDynamics::Math::VectorNd, Eigen::aligned_allocator<RobotDynamics::Math::VectorNd>>
q_vec;
13 std::vector<RobotDynamics::Math::VectorNd, Eigen::aligned_allocator<RobotDynamics::Math::VectorNd>>
qdot_vec;
14 std::vector<RobotDynamics::Math::VectorNd, Eigen::aligned_allocator<RobotDynamics::Math::VectorNd>>
qddot_vec;
15 std::vector<RobotDynamics::Math::VectorNd, Eigen::aligned_allocator<RobotDynamics::Math::VectorNd>>
tau_vec;
26 for(
unsigned int i = 0; i < num_samples; i++)
28 for(
unsigned int j = 0; j < q_size; j++)
30 q[j] = (
static_cast<double>(rand()) / static_cast<double>(RAND_MAX)) * 2. - 1.;
33 for(
unsigned int j = 0; j < qdot_size; j++)
35 qdot[j] = (
static_cast<double>(rand()) / static_cast<double>(RAND_MAX)) * 2. - 1.;
36 qddot[j] = (
static_cast<double>(rand()) / static_cast<double>(RAND_MAX)) * 2. - 1.;
37 tau[j] = (
static_cast<double>(rand()) / static_cast<double>(RAND_MAX)) * 2. - 1.;
40 samples.
q_vec.push_back(q);
49 int main(
int argc,
char *argv[])
51 std::string urdf_file;
52 unsigned int num_samples;
54 boost::program_options::options_description description(
"Command line options kinematics benchmark");
56 description.add_options()(
"help,h",
"Display help options")(
"urdf", boost::program_options::value<std::string>(&urdf_file),
57 "Path to the urdf")(
"samples", boost::program_options::value<unsigned int>(&num_samples),
58 "Number of benchmark samples to run");
60 boost::program_options::variables_map command_line_args;
61 boost::program_options::store(boost::program_options::parse_command_line(argc, argv, description), command_line_args);
62 boost::program_options::notify(command_line_args);
64 if (command_line_args.count(
"help"))
66 std::cout << description << std::endl;
70 if (command_line_args.count(
"urdf"))
72 urdf_file = command_line_args[
"urdf"].as<std::string>();
75 num_samples = command_line_args.count(
"samples") ? command_line_args[
"samples"].as<
unsigned int>() : 10000;
80 std::cerr <<
"Error reading urdf file" << std::endl;
90 for(
unsigned int i = 0; i < num_samples; i++)
97 std::cout <<
"Kinematics for " << num_samples <<
" took " << duration <<
"s. Average calculation is " << duration/num_samples << std::endl;
101 for(
unsigned int i = 0; i < num_samples; i++)
108 std::cout <<
"Parallel kinematics for " << num_samples <<
" took " << duration <<
"s. Average calculation is " << duration/num_samples << std::endl;
112 for(
unsigned int i = 0; i < num_samples; i++)
119 std::cout <<
"Kinematics custom of only q/qdot for " << num_samples <<
" took " << duration <<
"s. Average calculation is " << duration/num_samples << std::endl;
123 for(
unsigned int i = 0; i < num_samples; i++)
130 std::cout <<
"Parallel kinematics custom of only q/qdot for " << num_samples <<
" took " << duration <<
"s. Average calculation is " << duration/num_samples << std::endl;
Samples fillRandom(unsigned int q_size, unsigned int qdot_size, unsigned int num_samples)
std::shared_ptr< Model > ModelPtr
std::vector< RobotDynamics::Math::VectorNd, Eigen::aligned_allocator< RobotDynamics::Math::VectorNd > > tau_vec
double timer_stop(TimerInfo *timer)
void updateKinematicsParallel(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot)
void updateKinematics(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot)
void timer_start(TimerInfo *timer)
std::vector< RobotDynamics::Math::VectorNd, Eigen::aligned_allocator< RobotDynamics::Math::VectorNd > > q_vec
void updateKinematicsCustom(Model &model, const Math::VectorNd *Q, const Math::VectorNd *QDot=nullptr, const Math::VectorNd *QDDot=nullptr)
std::vector< RobotDynamics::Math::VectorNd, Eigen::aligned_allocator< RobotDynamics::Math::VectorNd > > qddot_vec
bool urdfReadFromFile(const char *filename, ModelPtr model, bool floating_base, bool verbose=false)
std::vector< RobotDynamics::Math::VectorNd, Eigen::aligned_allocator< RobotDynamics::Math::VectorNd > > qdot_vec
void updateKinematicsCustomParallel(Model &model, const Math::VectorNd *Q, const Math::VectorNd *QDot=nullptr, const Math::VectorNd *QDDot=nullptr)
int main(int argc, char *argv[])