9 #include "pinocchio/multibody/model.hpp" 10 #include "pinocchio/parsers/urdf.hpp" 12 #ifdef PINOCCHIO_WITH_HPP_FCL 13 #include <hpp/fcl/collision_object.h> 14 #endif // PINOCCHIO_WITH_HPP_FCL 16 #include <boost/test/unit_test.hpp> 18 #include <urdf_parser/urdf_parser.h> 21 BOOST_AUTO_TEST_SUITE ( BOOST_TEST_MODULE )
25 const std::string filename =
PINOCCHIO_MODEL_DIR + std::string(
"/example-robot-data/robots/romeo_description/urdf/romeo_small.urdf");
33 BOOST_CHECK(model.
nq == 31);
44 BOOST_CHECK_EQUAL(model.
nq, 29);
49 BOOST_CHECK_EQUAL(geomModel.
ngeoms, 2);
51 #ifdef PINOCCHIO_WITH_HPP_FCL 53 #ifdef PINOCCHIO_URDFDOM_COLLISION_WITH_GROUP_NAME 54 BOOST_CHECK_EQUAL(geomModel.
geometryObjects[0].geometry->getNodeType(), hpp::fcl::GEOM_CYLINDER);
55 #else // PINOCCHIO_URDFDOM_COLLISION_WITH_GROUP_NAME 56 BOOST_CHECK_EQUAL(geomModel.
geometryObjects[0].geometry->getNodeType(), hpp::fcl::GEOM_CAPSULE);
59 #if ( HPP_FCL_MAJOR_VERSION>1 || ( HPP_FCL_MAJOR_VERSION==1 && \ 60 ( HPP_FCL_MINOR_VERSION>1 || ( HPP_FCL_MINOR_VERSION==1 && \ 61 HPP_FCL_PATCH_VERSION>3)))) 62 # define PINOCCHIO_HPP_FCL_SUPERIOR_TO_1_1_3 65 #if defined(PINOCCHIO_HPP_FCL_SUPERIOR_TO_1_1_3) && !defined(PINOCCHIO_URDFDOM_COLLISION_WITH_GROUP_NAME) 66 BOOST_CHECK_EQUAL(geomModel.
geometryObjects[1].geometry->getNodeType(), hpp::fcl::GEOM_CONVEX);
67 #undef PINOCCHIO_HPP_FCL_SUPERIOR_TO_1_1_3 68 #else // PINOCCHIO_HPP_FCL_SUPERIOR_TO_1_1_3 && !PINOCCHIO_URDFDOM_COLLISION_WITH_GROUP_NAME 69 BOOST_CHECK_EQUAL(geomModel.
geometryObjects[1].geometry->getObjectType(), hpp::fcl::OT_BVH);
70 #endif // PINOCCHIO_HPP_FCL_SUPERIOR_TO_1_1_3 && !PINOCCHIO_URDFDOM_COLLISION_WITH_GROUP_NAME 71 #endif // PINOCCHIO_WITH_HPP_FCL 76 BOOST_CHECK(model_ff.nq == 36);
81 const std::string filename =
PINOCCHIO_MODEL_DIR + std::string(
"/example-robot-data/robots/romeo_description/urdf/romeo_small.urdf");
85 file.open(filename.c_str());
86 std::string filestr((std::istreambuf_iterator<char>(file)),
87 std::istreambuf_iterator<char>());
92 BOOST_CHECK(model.
nq == 31);
99 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 100 "<robot name=\"test\">" 101 " <link name=\"base_link\"/>" 102 " <link name=\"link_1\"/>" 103 " <link name=\"link_2\"/>" 104 " <joint name=\"joint_1\" type=\"fixed\">" 105 " <origin xyz=\"1 0 0\"/>" 106 " <axis xyz=\"0 0 1\"/>" 107 " <parent link=\"base_link\"/>" 108 " <child link=\"link_1\"/>" 110 " <joint name=\"joint_2\" type=\"fixed\">" 111 " <origin xyz=\"0 1 0\"/>" 112 " <axis xyz=\"0 0 1\"/>" 113 " <parent link=\"link_1\"/>" 114 " <child link=\"link_2\"/>" 129 BOOST_CHECK_EQUAL(base_link_id, model.
frames[joint1_id].previousFrame);
130 BOOST_CHECK_EQUAL(joint1_id , model.
frames[link1_id ].previousFrame);
131 BOOST_CHECK_EQUAL(link1_id , model.
frames[joint2_id].previousFrame);
132 BOOST_CHECK_EQUAL(joint2_id , model.
frames[link2_id ].previousFrame);
137 const std::string filename =
PINOCCHIO_MODEL_DIR + std::string(
"/example-robot-data/robots/romeo_description/urdf/romeo_small.urdf");
139 ::urdf::ModelInterfaceSharedPtr urdfTree = ::urdf::parseURDFFile(filename);
144 BOOST_CHECK(model.
nq == 31);
149 const std::string filename =
PINOCCHIO_MODEL_DIR + std::string(
"/example-robot-data/robots/romeo_description/urdf/romeo_small.urdf");
158 BOOST_CHECK(model.
nq == 38);
163 const std::string filename =
PINOCCHIO_MODEL_DIR + std::string(
"/example-robot-data/robots/romeo_description/urdf/romeo_small.urdf");
167 file.open(filename.c_str());
168 std::string filestr((std::istreambuf_iterator<char>(file)),
169 std::istreambuf_iterator<char>());
174 BOOST_CHECK(model.
nq == 38);
179 const std::string filename =
PINOCCHIO_MODEL_DIR + std::string(
"/example-robot-data/robots/romeo_description/urdf/romeo_small.urdf");
181 ::urdf::ModelInterfaceSharedPtr urdfTree = ::urdf::parseURDFFile(filename);
186 BOOST_CHECK(model.
nq == 38);
196 BOOST_CHECK(model.
njoints == 30);
197 const int nframes = model.
nframes;
198 const std::string filestr(
199 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 200 "<robot name=\"test\">" 201 " <link name=\"box\"/>" 206 BOOST_CHECK(model.
njoints == 30);
207 BOOST_CHECK(nframes + 1 == model.
nframes);
217 BOOST_CHECK(model.
njoints == 31);
218 const std::string filestr(
219 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 220 "<robot name=\"test\">" 221 " <link name=\"box\"/>" 227 std::invalid_argument);
238 BOOST_AUTO_TEST_SUITE_END()
int njoints
Number of joints.
FrameVector frames
Vector of operational frames registered on the model.
#define PINOCCHIO_MODEL_DIR
int nframes
Number of operational frames.
GeometryObjectVector geometryObjects
Vector of GeometryObjects used for collision computations.
FrameIndex getFrameId(const std::string &name, const FrameType &type=(FrameType)(JOINT|FIXED_JOINT|BODY|OP_FRAME|SENSOR)) const
Returns the index of a frame given by its name.
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...
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 ...
Index ngeoms
The number of GeometryObjects.
ModelTpl< Scalar, Options, JointCollectionTpl > & buildModelFromXML(const std::string &xml_stream, const typename ModelTpl< Scalar, Options, JointCollectionTpl >::JointModel &rootJoint, ModelTpl< Scalar, Options, JointCollectionTpl > &model, const bool verbose=false)
Build the model from an XML stream with a particular joint as root of the model tree inside the model...
BOOST_AUTO_TEST_CASE(build_model)
int nq
Dimension of the configuration vector representation.