| Directory: | ./ |
|---|---|
| File: | bindings/python/parsers/mjcf/geometry.cpp |
| Date: | 2025-02-12 21:03:38 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 10 | 14 | 71.4% |
| Branches: | 4 | 12 | 33.3% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2015-2022 CNRS INRIA | ||
| 3 | // | ||
| 4 | |||
| 5 | #include "pinocchio/parsers/mjcf.hpp" | ||
| 6 | #include "pinocchio/bindings/python/parsers/mjcf.hpp" | ||
| 7 | #include "pinocchio/bindings/python/utils/path.hpp" | ||
| 8 | |||
| 9 | #include <boost/python.hpp> | ||
| 10 | |||
| 11 | namespace pinocchio | ||
| 12 | { | ||
| 13 | namespace python | ||
| 14 | { | ||
| 15 | |||
| 16 | namespace bp = boost::python; | ||
| 17 | |||
| 18 | GeometryModel | ||
| 19 | 6 | buildGeomFromMJCF(Model & model, const bp::object & filename, const GeometryType & type) | |
| 20 | { | ||
| 21 | 6 | GeometryModel geometry_model; | |
| 22 |
2/4✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
|
6 | ::pinocchio::mjcf::buildGeom(model, path(filename), type, geometry_model); |
| 23 | 6 | return geometry_model; | |
| 24 | } | ||
| 25 | |||
| 26 | ✗ | GeometryModel buildGeomFromMJCF( | |
| 27 | Model & model, | ||
| 28 | const bp::object & filename, | ||
| 29 | const GeometryType & type, | ||
| 30 | ::hpp::fcl::MeshLoaderPtr & meshLoader) | ||
| 31 | { | ||
| 32 | ✗ | GeometryModel geometry_model; | |
| 33 | ✗ | ::pinocchio::mjcf::buildGeom(model, path(filename), type, geometry_model, meshLoader); | |
| 34 | ✗ | return geometry_model; | |
| 35 | } | ||
| 36 | |||
| 37 | 65 | void exposeMJCFGeom() | |
| 38 | { | ||
| 39 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
| 40 | "buildGeomFromMJCF", | ||
| 41 | static_cast<GeometryModel (*)(Model &, const bp::object &, const GeometryType &)>( | ||
| 42 | pinocchio::python::buildGeomFromMJCF), | ||
| 43 | 130 | bp::args("model", "mjcf_filename", "geom_type"), | |
| 44 | "Parse the Mjcf file given as input looking for the geometry of the given input model and\n" | ||
| 45 | "return a GeometryModel containing either the collision geometries " | ||
| 46 | "(GeometryType.COLLISION) or the visual geometries (GeometryType.VISUAL).\n" | ||
| 47 | "Parameters:\n" | ||
| 48 | "\tmodel: model of the robot\n" | ||
| 49 | "\tfilename: path to the mjcf file containing the model of the robot\n" | ||
| 50 | "\tgeom_type: type of geometry to extract from the mjcf file (either the VISUAL for " | ||
| 51 | "display or the COLLISION for collision detection).\n"); | ||
| 52 | |||
| 53 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
| 54 | "buildGeomFromMJCF", | ||
| 55 | static_cast<GeometryModel (*)( | ||
| 56 | Model &, const bp::object &, const GeometryType &, ::hpp::fcl::MeshLoaderPtr &)>( | ||
| 57 | pinocchio::python::buildGeomFromMJCF), | ||
| 58 | 130 | bp::args("model", "mjcf_filename", "geom_type", "mesh_loader"), | |
| 59 | "Parse the Mjcf file given as input looking for the geometry of the given input model and\n" | ||
| 60 | "return a GeometryModel containing either the collision geometries " | ||
| 61 | "(GeometryType.COLLISION) or the visual geometries (GeometryType.VISUAL).\n" | ||
| 62 | "Parameters:\n" | ||
| 63 | "\tmodel: model of the robot\n" | ||
| 64 | "\tfilename: path to the mjcf file containing the model of the robot\n" | ||
| 65 | "\tgeom_type: type of geometry to extract from the mjcf file (either the VISUAL for " | ||
| 66 | "display or the COLLISION for collision detection).\n" | ||
| 67 | "\tmesh_loader: an hpp-fcl mesh loader (to load only once the related geometries).\n"); | ||
| 68 | 65 | } | |
| 69 | } // namespace python | ||
| 70 | } // namespace pinocchio | ||
| 71 |