timings-geometry.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2019 CNRS INRIA
3 //
4 
8 #ifdef PINOCCHIO_WITH_HPP_FCL
10 #endif // PINOCCHIO_WITH_HPP_FCL
15 
16 #include <iostream>
17 
18 int main()
19 {
20  using namespace Eigen;
21  using namespace pinocchio;
22 
24 #ifdef NDEBUG
25  const unsigned int NBT = 1000 * 100;
26  const unsigned int NBD = 1000; // for heavy tests, like computeDistances()
27 #else
28  const unsigned int NBT = 1;
29  const unsigned int NBD = 1;
30  std::cout << "(the time score in debug mode is not relevant) " << std::endl;
31 #endif
32 
33  std::string romeo_filename =
35  + std::string("/example-robot-data/robots/romeo_description/urdf/romeo_small.urdf");
36  std::vector<std::string> package_dirs;
37  std::string romeo_meshDir = PINOCCHIO_MODEL_DIR + std::string("/example-robot-data/robots");
38  package_dirs.push_back(romeo_meshDir);
39 
44 #ifdef PINOCCHIO_WITH_HPP_FCL
45  geom_model.addAllCollisionPairs();
46 #endif // PINOCCHIO_WITH_HPP_FCL
47 
48  Data data(model);
50  VectorXd qmax = Eigen::VectorXd::Ones(model.nq);
51 
52  PINOCCHIO_ALIGNED_STD_VECTOR(VectorXd) qs_romeo(NBT);
53  PINOCCHIO_ALIGNED_STD_VECTOR(VectorXd) qdots_romeo(NBT);
54  PINOCCHIO_ALIGNED_STD_VECTOR(VectorXd) qddots_romeo(NBT);
55  for (size_t i = 0; i < NBT; ++i)
56  {
57  qs_romeo[i] = randomConfiguration(model, -qmax, qmax);
58  qdots_romeo[i] = Eigen::VectorXd::Random(model.nv);
59  qddots_romeo[i] = Eigen::VectorXd::Random(model.nv);
60  }
61 
62  timer.tic();
63  SMOOTH(NBT)
64  {
65  forwardKinematics(model, data, qs_romeo[_smooth]);
66  }
67  double geom_time = timer.toc(PinocchioTicToc::US) / NBT;
68 
69  timer.tic();
70  SMOOTH(NBT)
71  {
73  }
74  double update_col_time = timer.toc(PinocchioTicToc::US) / NBT - geom_time;
75  std::cout << "Update Collision Geometry < false > = \t" << update_col_time << " "
77 
78 #ifdef PINOCCHIO_WITH_HPP_FCL
79  timer.tic();
80  SMOOTH(NBT)
81  {
83  for (std::vector<pinocchio::CollisionPair>::iterator it = geom_model.collisionPairs.begin();
84  it != geom_model.collisionPairs.end(); ++it)
85  {
86  computeCollision(geom_model, geom_data, std::size_t(it - geom_model.collisionPairs.begin()));
87  }
88  }
89  double collideTime = timer.toc(PinocchioTicToc::US) / NBT - (update_col_time + geom_time);
90  std::cout << "Collision test between two geometry objects (mean time) = \t"
91  << collideTime / double(geom_model.collisionPairs.size())
93 
94  timer.tic();
95  SMOOTH(NBT)
96  {
98  }
99  double is_colliding_time = timer.toc(PinocchioTicToc::US) / NBT - (update_col_time + geom_time);
100  std::cout << "Collision Test : robot in collision? = \t" << is_colliding_time
102 
103  timer.tic();
104  SMOOTH(NBD)
105  {
106  computeDistances(model, data, geom_model, geom_data, qs_romeo[_smooth]);
107  }
108  double computeDistancesTime =
109  timer.toc(PinocchioTicToc::US) / NBD - (update_col_time + geom_time);
110  std::cout << "Compute distance between two geometry objects (mean time) = \t"
111  << computeDistancesTime / double(geom_model.collisionPairs.size()) << " "
113  << geom_model.collisionPairs.size() << " col pairs" << std::endl;
114 
115 #endif // PINOCCHIO_WITH_HPP_FCL
116 
117  return 0;
118 }
PinocchioTicToc::toc
double toc()
Definition: timer.hpp:88
Eigen
pinocchio::DataTpl
Definition: context/generic.hpp:25
pinocchio::forwardKinematics
void forwardKinematics(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Update the joint placements according to the current joint configuration.
pinocchio::computeCollisions
bool computeCollisions(BroadPhaseManagerBase< BroadPhaseManagerDerived > &broadphase_manager, CollisionCallBackBase *callback)
Calls computeCollision for every active pairs of GeometryData. This function assumes that updateGeome...
Definition: broadphase.hpp:34
pinocchio::updateGeometryPlacements
void updateGeometryPlacements(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const GeometryModel &geom_model, GeometryData &geom_data, const Eigen::MatrixBase< ConfigVectorType > &q)
Apply a forward kinematics and update the placement of the geometry objects.
inverse-kinematics.i
int i
Definition: inverse-kinematics.py:20
kinematics.hpp
setup.data
data
Definition: cmake/cython/setup.in.py:48
pinocchio::JointModelFreeFlyerTpl
Definition: multibody/joint/fwd.hpp:110
PinocchioTicToc::unitName
static std::string unitName(Unit u)
Definition: timer.hpp:58
pinocchio::GeometryData
Definition: multibody/geometry.hpp:233
pinocchio::randomConfiguration
void randomConfiguration(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorIn1 > &lowerLimits, const Eigen::MatrixBase< ConfigVectorIn2 > &upperLimits, const Eigen::MatrixBase< ReturnType > &qout)
Generate a configuration vector uniformly sampled among provided limits.
Definition: joint-configuration.hpp:325
collision.hpp
timer.hpp
main
int main()
Definition: timings-geometry.cpp:18
anymal-simulation.model
model
Definition: anymal-simulation.py:12
SMOOTH
#define SMOOTH(s)
Definition: timer.hpp:38
joint-configuration.hpp
geometry.hpp
pinocchio::urdf::buildModel
ModelTpl< Scalar, Options, JointCollectionTpl > & buildModel(const std::string &filename, const typename ModelTpl< Scalar, Options, JointCollectionTpl >::JointModel &rootJoint, ModelTpl< Scalar, Options, JointCollectionTpl > &model, const bool verbose=false)
Build the model from a URDF file with a particular joint as root of the model tree inside the model g...
append-urdf-model-with-another-model.package_dirs
package_dirs
Definition: append-urdf-model-with-another-model.py:20
urdf.hpp
geometry.hpp
pinocchio::computeCollision
bool computeCollision(const GeometryModel &geom_model, GeometryData &geom_data, const PairIndex pair_id, fcl::CollisionRequest &collision_request)
Compute the collision status between a SINGLE collision pair. The result is store in the collisionRes...
pinocchio::computeDistances
std::size_t computeDistances(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const GeometryModel &geom_model, GeometryData &geom_data)
pinocchio::urdf::buildGeom
GeometryModel & buildGeom(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const std::string &filename, const GeometryType type, GeometryModel &geom_model, const std::vector< std::string > &package_paths=std::vector< std::string >(), ::hpp::fcl::MeshLoaderPtr mesh_loader=::hpp::fcl::MeshLoaderPtr())
Build The GeometryModel from a URDF file. Search for meshes in the directories specified by the user ...
append-urdf-model-with-another-model.geom_model
geom_model
Definition: append-urdf-model-with-another-model.py:26
PinocchioTicToc::US
@ US
Definition: timer.hpp:53
collisions.geom_data
geom_data
Definition: collisions.py:45
pinocchio::GeometryModel
Definition: multibody/geometry.hpp:50
PINOCCHIO_ALIGNED_STD_VECTOR
#define PINOCCHIO_ALIGNED_STD_VECTOR(Type)
Definition: container/aligned-vector.hpp:11
pinocchio::COLLISION
@ COLLISION
Definition: multibody/geometry-object.hpp:27
sample-models.hpp
pinocchio::ModelTpl
Definition: context/generic.hpp:20
PinocchioTicToc
Definition: timer.hpp:47
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
PINOCCHIO_MODEL_DIR
#define PINOCCHIO_MODEL_DIR
Definition: build-reduced-model.cpp:11
PinocchioTicToc::tic
void tic()
Definition: timer.hpp:82


pinocchio
Author(s):
autogenerated on Sat Jun 1 2024 02:40:38