Directory: | ./ |
---|---|
File: | include/pinocchio/parsers/mjcf/model.hxx |
Date: | 2024-08-27 18:20:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 20 | 22 | 90.9% |
Branches: | 10 | 20 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2016-2023 CNRS INRIA | ||
3 | // | ||
4 | |||
5 | #ifndef __pinocchio_parsers_mjcf_model_hxx__ | ||
6 | #define __pinocchio_parsers_mjcf_model_hxx__ | ||
7 | |||
8 | #include "pinocchio/parsers/mjcf.hpp" | ||
9 | #include "pinocchio/parsers/mjcf/mjcf-graph.hpp" | ||
10 | |||
11 | namespace pinocchio | ||
12 | { | ||
13 | namespace mjcf | ||
14 | { | ||
15 | template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl> | ||
16 | 8 | ModelTpl<Scalar, Options, JointCollectionTpl> & buildModel( | |
17 | const std::string & filename, | ||
18 | ModelTpl<Scalar, Options, JointCollectionTpl> & model, | ||
19 | const bool verbose) | ||
20 | { | ||
21 | 8 | return buildModelFromXML(filename, model, verbose); | |
22 | } | ||
23 | |||
24 | template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl> | ||
25 | 8 | ModelTpl<Scalar, Options, JointCollectionTpl> & buildModelFromXML( | |
26 | const std::string & xmlStr, | ||
27 | ModelTpl<Scalar, Options, JointCollectionTpl> & model, | ||
28 | const bool verbose) | ||
29 | { | ||
30 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | ::pinocchio::urdf::details::UrdfVisitor<Scalar, Options, JointCollectionTpl> visitor(model); |
31 | |||
32 | typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph; | ||
33 | |||
34 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | MjcfGraph graph(visitor, xmlStr); |
35 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if (verbose) |
36 | ✗ | visitor.log = &std::cout; | |
37 | |||
38 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | graph.parseGraphFromXML(xmlStr); |
39 | |||
40 | // // Use the Mjcf graph to create the model | ||
41 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | graph.parseRootTree(); |
42 | |||
43 | 8 | return model; | |
44 | 8 | } | |
45 | |||
46 | template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl> | ||
47 | 1 | ModelTpl<Scalar, Options, JointCollectionTpl> & buildModel( | |
48 | const std::string & filename, | ||
49 | const typename ModelTpl<Scalar, Options, JointCollectionTpl>::JointModel & rootJoint, | ||
50 | ModelTpl<Scalar, Options, JointCollectionTpl> & model, | ||
51 | const bool verbose) | ||
52 | { | ||
53 | 1 | return buildModelFromXML(filename, rootJoint, model, verbose); | |
54 | } | ||
55 | |||
56 | template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl> | ||
57 | 1 | ModelTpl<Scalar, Options, JointCollectionTpl> & buildModelFromXML( | |
58 | const std::string & xmlStr, | ||
59 | const typename ModelTpl<Scalar, Options, JointCollectionTpl>::JointModel & rootJoint, | ||
60 | ModelTpl<Scalar, Options, JointCollectionTpl> & model, | ||
61 | const bool verbose) | ||
62 | { | ||
63 | ::pinocchio::urdf::details::UrdfVisitorWithRootJoint<Scalar, Options, JointCollectionTpl> | ||
64 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | visitor(model, rootJoint); |
65 | |||
66 | typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph; | ||
67 | |||
68 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | MjcfGraph graph(visitor, xmlStr); |
69 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (verbose) |
70 | ✗ | visitor.log = &std::cout; | |
71 | |||
72 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | graph.parseGraphFromXML(xmlStr); |
73 | |||
74 | // // Use the Mjcf graph to create the model | ||
75 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | graph.parseRootTree(); |
76 | |||
77 | 1 | return model; | |
78 | 1 | } | |
79 | |||
80 | } // namespace mjcf | ||
81 | } // namespace pinocchio | ||
82 | |||
83 | #endif // __pinocchio_parsers_mjcf_model_hxx__ | ||
84 |