Directory: | ./ |
---|---|
File: | include/pinocchio/algorithm/geometry.hxx |
Date: | 2024-08-27 18:20:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 13 | 32 | 40.6% |
Branches: | 7 | 28 | 25.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2015-2022 CNRS INRIA | ||
3 | // | ||
4 | |||
5 | #ifndef __pinocchio_algo_geometry_hxx__ | ||
6 | #define __pinocchio_algo_geometry_hxx__ | ||
7 | |||
8 | #include <boost/foreach.hpp> | ||
9 | #include <sstream> | ||
10 | |||
11 | namespace pinocchio | ||
12 | { | ||
13 | /* --- GEOMETRY PLACEMENTS -------------------------------------------------------- */ | ||
14 | /* --- GEOMETRY PLACEMENTS -------------------------------------------------------- */ | ||
15 | /* --- GEOMETRY PLACEMENTS -------------------------------------------------------- */ | ||
16 | template< | ||
17 | typename Scalar, | ||
18 | int Options, | ||
19 | template<typename, int> | ||
20 | class JointCollectionTpl, | ||
21 | typename ConfigVectorType> | ||
22 | 4023 | inline void updateGeometryPlacements( | |
23 | const ModelTpl<Scalar, Options, JointCollectionTpl> & model, | ||
24 | DataTpl<Scalar, Options, JointCollectionTpl> & data, | ||
25 | const GeometryModel & geom_model, | ||
26 | GeometryData & geom_data, | ||
27 | const Eigen::MatrixBase<ConfigVectorType> & q) | ||
28 | { | ||
29 |
1/2✓ Branch 1 taken 4023 times.
✗ Branch 2 not taken.
|
4023 | assert(model.check(data) && "data is not consistent with model."); |
30 | |||
31 | 4023 | forwardKinematics(model, data, q); | |
32 | 4023 | updateGeometryPlacements(model, data, geom_model, geom_data); | |
33 | 4023 | } | |
34 | |||
35 | template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl> | ||
36 | 4030 | inline void updateGeometryPlacements( | |
37 | const ModelTpl<Scalar, Options, JointCollectionTpl> & model, | ||
38 | const DataTpl<Scalar, Options, JointCollectionTpl> & data, | ||
39 | const GeometryModel & geom_model, | ||
40 | GeometryData & geom_data) | ||
41 | { | ||
42 | PINOCCHIO_UNUSED_VARIABLE(model); | ||
43 |
1/2✓ Branch 1 taken 4030 times.
✗ Branch 2 not taken.
|
4030 | assert(model.check(data) && "data is not consistent with model."); |
44 | |||
45 |
2/2✓ Branch 0 taken 80601 times.
✓ Branch 1 taken 4030 times.
|
84631 | for (GeomIndex i = 0; i < (GeomIndex)geom_model.ngeoms; ++i) |
46 | { | ||
47 | 80601 | const Model::JointIndex joint_id = geom_model.geometryObjects[i].parentJoint; | |
48 |
2/2✓ Branch 0 taken 80588 times.
✓ Branch 1 taken 13 times.
|
80601 | if (joint_id > 0) |
49 |
1/2✓ Branch 5 taken 80588 times.
✗ Branch 6 not taken.
|
80588 | geom_data.oMg[i] = (data.oMi[joint_id] * geom_model.geometryObjects[i].placement); |
50 | else | ||
51 | 13 | geom_data.oMg[i] = geom_model.geometryObjects[i].placement; | |
52 | } | ||
53 | 4030 | } | |
54 | |||
55 | /* --- APPEND GEOMETRY MODEL ----------------------------------------------------------- */ | ||
56 | |||
57 | ✗ | inline void appendGeometryModel(GeometryModel & geom_model1, const GeometryModel & geom_model2) | |
58 | { | ||
59 | ✗ | assert(geom_model1.ngeoms == geom_model1.geometryObjects.size()); | |
60 | ✗ | Index nGeom1 = geom_model1.geometryObjects.size(); | |
61 | ✗ | Index nColPairs1 = geom_model1.collisionPairs.size(); | |
62 | ✗ | assert(geom_model2.ngeoms == geom_model2.geometryObjects.size()); | |
63 | ✗ | Index nGeom2 = geom_model2.geometryObjects.size(); | |
64 | ✗ | Index nColPairs2 = geom_model2.collisionPairs.size(); | |
65 | |||
66 | /// Append the geometry objects and geometry positions | ||
67 | ✗ | geom_model1.geometryObjects.insert( | |
68 | ✗ | geom_model1.geometryObjects.end(), geom_model2.geometryObjects.begin(), | |
69 | geom_model2.geometryObjects.end()); | ||
70 | ✗ | geom_model1.ngeoms += nGeom2; | |
71 | |||
72 | /// 1. copy the collision pairs and update geom_data1 accordingly. | ||
73 | ✗ | geom_model1.collisionPairs.reserve(nColPairs1 + nColPairs2 + nGeom1 * nGeom2); | |
74 | ✗ | for (Index i = 0; i < nColPairs2; ++i) | |
75 | { | ||
76 | ✗ | const CollisionPair & cp = geom_model2.collisionPairs[i]; | |
77 | ✗ | geom_model1.collisionPairs.push_back(CollisionPair(cp.first + nGeom1, cp.second + nGeom1)); | |
78 | } | ||
79 | |||
80 | /// 2. add the collision pairs between geom_model1 and geom_model2. | ||
81 | ✗ | for (Index i = 0; i < nGeom1; ++i) | |
82 | { | ||
83 | ✗ | Index parent_i = geom_model1.geometryObjects[i].parentJoint; | |
84 | ✗ | for (Index j = nGeom1; j < nGeom1 + nGeom2; ++j) | |
85 | { | ||
86 | ✗ | if (parent_i != geom_model1.geometryObjects[j].parentJoint) | |
87 | ✗ | geom_model1.collisionPairs.push_back(CollisionPair(i, j)); | |
88 | } | ||
89 | } | ||
90 | } | ||
91 | |||
92 | } // namespace pinocchio | ||
93 | |||
94 | #endif // ifnded __pinocchio_algo_geometry_hxx__ | ||
95 |