GCC Code Coverage Report


Directory: ./
File: bindings/python/parsers/mjcf/model.cpp
Date: 2025-02-12 21:03:38
Exec Total Coverage
Lines: 23 23 100.0%
Branches: 12 24 50.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2024 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 1 Model buildModelFromMJCF(const bp::object & filename)
19 {
20 1 Model model;
21
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 ::pinocchio::mjcf::buildModel(path(filename), model);
22 1 return model;
23 }
24
25 1 Model buildModelFromMJCF(const bp::object & filename, const JointModel & root_joint)
26 {
27 1 Model model;
28
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 ::pinocchio::mjcf::buildModel(path(filename), root_joint, model);
29 1 return model;
30 }
31
32 1 bp::tuple buildModelFromMJCF(
33 const bp::object & filename,
34 const JointModel & root_joint,
35 const std::string & root_joint_name)
36 {
37
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Model model;
38
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(RigidConstraintModel) contact_models;
39
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 ::pinocchio::mjcf::buildModel(
40
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 path(filename), root_joint, root_joint_name, model, contact_models);
41
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 return bp::make_tuple(model, contact_models);
42 1 }
43
44 65 void exposeMJCFModel()
45 {
46
1/2
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
65 bp::def(
47 "buildModelFromMJCF",
48 static_cast<Model (*)(const bp::object &)>(pinocchio::python::buildModelFromMJCF),
49 130 bp::args("mjcf_filename"),
50 "Parse the MJCF file given in input and return a pinocchio Model.");
51
52
1/2
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
65 bp::def(
53 "buildModelFromMJCF",
54 static_cast<Model (*)(const bp::object &, const JointModel &)>(
55 pinocchio::python::buildModelFromMJCF),
56 130 bp::args("mjcf_filename", "root_joint"),
57 "Parse the MJCF file and return a pinocchio Model with the given root Joint.");
58
59
1/2
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
65 bp::def(
60 "buildModelFromMJCF",
61 static_cast<bp::tuple (*)(const bp::object &, const JointModel &, const std::string &)>(
62 pinocchio::python::buildModelFromMJCF),
63 130 bp::args("mjcf_filename", "root_joint", "root_joint_name"),
64 "Parse the MJCF file and return a pinocchio Model with the given root Joint and its "
65 "specified name as well as a constraint list if some are present in the MJCF file.");
66 65 }
67 } // namespace python
68 } // namespace pinocchio
69