tree-broadphase.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2022 INRIA
3 //
4 
5 #include <iostream>
6 
12 
14 
15 #include <vector>
16 #include <boost/test/unit_test.hpp>
17 
18 using namespace pinocchio;
19 
20 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
21 
22 BOOST_AUTO_TEST_CASE(test_tree_broadphase_with_empty_models)
23 {
24  Model model;
27 
30 
31  BOOST_CHECK(broadphase_manager.check());
32 }
33 
34 BOOST_AUTO_TEST_CASE(test_collisions)
35 {
36  const std::string filename =
38  + std::string("/example-robot-data/robots/romeo_description/urdf/romeo_small.urdf");
39  std::vector<std::string> packageDirs;
40  const std::string meshDir = PINOCCHIO_MODEL_DIR;
41  packageDirs.push_back(meshDir);
42  const std::string srdf_filename =
44  + std::string("/example-robot-data/robots/romeo_description/srdf/romeo.srdf");
45 
46  Model model;
50  geom_model.addAllCollisionPairs();
52 
53  Data data(model), data_broadphase(model);
54  GeometryData geom_data(geom_model), geom_data_broadphase(geom_model);
55 
57  Eigen::VectorXd q = model.referenceConfigurations["half_sitting"];
58 
60  pinocchio::updateGeometryPlacements(model, data_broadphase, geom_model, geom_data_broadphase, q);
61 
62  BOOST_CHECK(computeCollisions(geom_model, geom_data) == false);
63  BOOST_CHECK(computeCollisions(geom_model, geom_data, false) == false);
64 
66  &model, &geom_model, &geom_data_broadphase);
67  BOOST_CHECK(computeCollisions(broadphase_manager) == false);
68  BOOST_CHECK(computeCollisions(broadphase_manager, false) == false);
69  BOOST_CHECK(computeCollisions(model, data_broadphase, broadphase_manager, q) == false);
70  BOOST_CHECK(computeCollisions(model, data_broadphase, broadphase_manager, q, false) == false);
71 
72  const int num_configs = 1000;
73  for (int i = 0; i < num_configs; ++i)
74  {
75  Eigen::VectorXd q_rand = randomConfiguration(model);
76  q_rand.head<7>() = q.head<7>();
77 
78  BOOST_CHECK(
79  computeCollisions(model, data_broadphase, broadphase_manager, q_rand)
81  }
82 }
83 
84 BOOST_AUTO_TEST_SUITE_END()
broadphase_dynamic_AABB_tree.h
pinocchio::DataTpl
Definition: context/generic.hpp:25
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:17
setup.data
data
Definition: cmake/cython/setup.in.py:48
pinocchio::JointModelFreeFlyerTpl
Definition: multibody/joint/fwd.hpp:110
pinocchio::GeometryData
Definition: multibody/geometry.hpp:233
broadphase.hpp
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:315
tree-broadphase-manager.hpp
collision.hpp
pinocchio::TreeBroadPhaseManagerTpl
Definition: collision/pool/fwd.hpp:38
filename
filename
urdf.hpp
srdf.hpp
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_tree_broadphase_with_empty_models)
Definition: tree-broadphase.cpp:22
pinocchio::urdf::buildModel
ModelTpl< Scalar, Options, JointCollectionTpl > & buildModel(const std::string &filename, const typename ModelTpl< Scalar, Options, JointCollectionTpl >::JointModel &rootJoint, const std::string &rootJointName, 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...
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 ...
pinocchio::TreeBroadPhaseManagerTpl::check
bool check() const
Check whether the base broad phase manager is aligned with the current collision_objects.
collisions.srdf_filename
string srdf_filename
Definition: collisions.py:25
append-urdf-model-with-another-model.geom_model
geom_model
Definition: append-urdf-model-with-another-model.py:26
pinocchio::q
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
Definition: joint-configuration.hpp:1083
collisions.geom_data
geom_data
Definition: collisions.py:42
pinocchio::srdf::loadReferenceConfigurations
void loadReferenceConfigurations(ModelTpl< Scalar, Options, JointCollectionTpl > &model, const std::string &filename, const bool verbose=false)
Get the reference configurations of a given model associated to a SRDF file. It throws if the SRDF fi...
pinocchio::GeometryModel
Definition: multibody/geometry.hpp:50
pinocchio::COLLISION
@ COLLISION
Definition: multibody/geometry-object.hpp:27
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio::model
JointCollectionTpl & model
Definition: joint-configuration.hpp:1082
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
PINOCCHIO_MODEL_DIR
#define PINOCCHIO_MODEL_DIR
Definition: build-reduced-model.cpp:11
pinocchio::srdf::removeCollisionPairs
void removeCollisionPairs(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, GeometryModel &geom_model, const std::string &filename, const bool verbose=false)
Deactive all possible collision pairs mentioned in the SRDF file. It throws if the SRDF file is incor...


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:33