| Directory: | ./ |
|---|---|
| File: | unittest/visitor.cpp |
| Date: | 2025-02-12 21:03:38 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 96 | 96 | 100.0% |
| Branches: | 222 | 428 | 51.9% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2015-2019 CNRS INRIA | ||
| 3 | // | ||
| 4 | |||
| 5 | #include "pinocchio/multibody/model.hpp" | ||
| 6 | #include "pinocchio/multibody/data.hpp" | ||
| 7 | #include "pinocchio/multibody/visitor.hpp" | ||
| 8 | |||
| 9 | #include <iostream> | ||
| 10 | |||
| 11 | #include <boost/test/unit_test.hpp> | ||
| 12 | #include <boost/utility/binary.hpp> | ||
| 13 | |||
| 14 | namespace bf = boost::fusion; | ||
| 15 | |||
| 16 | struct SimpleUnaryVisitor1 : public pinocchio::fusion::JointUnaryVisitorBase<SimpleUnaryVisitor1> | ||
| 17 | { | ||
| 18 | |||
| 19 | typedef bf::vector<const pinocchio::Model &, pinocchio::Data &, pinocchio::JointIndex> ArgsType; | ||
| 20 | |||
| 21 | template<typename JointModel> | ||
| 22 | 52 | static void algo( | |
| 23 | const pinocchio::JointModelBase<JointModel> & jmodel, | ||
| 24 | pinocchio::JointDataBase<typename JointModel::JointDataDerived> & jdata, | ||
| 25 | const pinocchio::Model & model, | ||
| 26 | pinocchio::Data & data, | ||
| 27 | pinocchio::JointIndex jindex) | ||
| 28 | { | ||
| 29 | PINOCCHIO_UNUSED_VARIABLE(jdata); | ||
| 30 | PINOCCHIO_UNUSED_VARIABLE(model); | ||
| 31 | PINOCCHIO_UNUSED_VARIABLE(data); | ||
| 32 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 26 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 26 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 26 times.
|
52 | BOOST_CHECK(jindex == jmodel.id()); |
| 33 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint name: " << jmodel.shortname() << std::endl; |
| 34 | 52 | } | |
| 35 | }; | ||
| 36 | |||
| 37 | struct SimpleUnaryVisitor2 : public pinocchio::fusion::JointUnaryVisitorBase<SimpleUnaryVisitor2> | ||
| 38 | { | ||
| 39 | |||
| 40 | typedef bf::vector<const pinocchio::Model &, pinocchio::Data &, pinocchio::JointIndex> ArgsType; | ||
| 41 | |||
| 42 | template<typename JointModel> | ||
| 43 | 52 | static void algo( | |
| 44 | const pinocchio::JointModelBase<JointModel> & jmodel, | ||
| 45 | const pinocchio::Model & model, | ||
| 46 | pinocchio::Data & data, | ||
| 47 | pinocchio::JointIndex jindex) | ||
| 48 | { | ||
| 49 | PINOCCHIO_UNUSED_VARIABLE(model); | ||
| 50 | PINOCCHIO_UNUSED_VARIABLE(data); | ||
| 51 | PINOCCHIO_UNUSED_VARIABLE(jindex); | ||
| 52 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 26 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 26 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 26 times.
|
52 | BOOST_CHECK(jindex == jmodel.id()); |
| 53 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint name: " << jmodel.shortname() << std::endl; |
| 54 | 52 | } | |
| 55 | }; | ||
| 56 | |||
| 57 | struct SimpleUnaryVisitor3 : public pinocchio::fusion::JointUnaryVisitorBase<SimpleUnaryVisitor3> | ||
| 58 | { | ||
| 59 | |||
| 60 | template<typename JointModel> | ||
| 61 | 52 | static void algo(const pinocchio::JointModelBase<JointModel> & jmodel) | |
| 62 | { | ||
| 63 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 16 taken 26 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 26 times.
✗ Branch 20 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 26 times.
|
52 | BOOST_CHECK(!jmodel.shortname().empty()); |
| 64 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint name: " << jmodel.shortname() << std::endl; |
| 65 | 52 | } | |
| 66 | }; | ||
| 67 | |||
| 68 | struct SimpleUnaryVisitor4 : public pinocchio::fusion::JointUnaryVisitorBase<SimpleUnaryVisitor4> | ||
| 69 | { | ||
| 70 | |||
| 71 | template<typename JointModel> | ||
| 72 | 52 | static void algo( | |
| 73 | const pinocchio::JointModelBase<JointModel> & jmodel, | ||
| 74 | pinocchio::JointDataBase<typename JointModel::JointDataDerived> & jdata) | ||
| 75 | { | ||
| 76 | PINOCCHIO_UNUSED_VARIABLE(jdata); | ||
| 77 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 16 taken 26 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 26 times.
✗ Branch 20 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 26 times.
|
52 | BOOST_CHECK(!jmodel.shortname().empty()); |
| 78 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint name: " << jmodel.shortname() << std::endl; |
| 79 | 52 | } | |
| 80 | }; | ||
| 81 | |||
| 82 | struct SimpleBinaryVisitor1 : public pinocchio::fusion::JointBinaryVisitorBase<SimpleBinaryVisitor1> | ||
| 83 | { | ||
| 84 | |||
| 85 | typedef bf::vector<const pinocchio::Model &, pinocchio::Data &, pinocchio::JointIndex> ArgsType; | ||
| 86 | |||
| 87 | template<typename JointModel1, typename JointModel2> | ||
| 88 | 52 | static void algo( | |
| 89 | const pinocchio::JointModelBase<JointModel1> & jmodel1, | ||
| 90 | const pinocchio::JointModelBase<JointModel2> & jmodel2, | ||
| 91 | pinocchio::JointDataBase<typename JointModel1::JointDataDerived> & jdata1, | ||
| 92 | pinocchio::JointDataBase<typename JointModel2::JointDataDerived> & jdata2, | ||
| 93 | const pinocchio::Model & model, | ||
| 94 | pinocchio::Data & data, | ||
| 95 | pinocchio::JointIndex jindex) | ||
| 96 | { | ||
| 97 | PINOCCHIO_UNUSED_VARIABLE(jdata1); | ||
| 98 | PINOCCHIO_UNUSED_VARIABLE(jdata2); | ||
| 99 | PINOCCHIO_UNUSED_VARIABLE(model); | ||
| 100 | PINOCCHIO_UNUSED_VARIABLE(data); | ||
| 101 | PINOCCHIO_UNUSED_VARIABLE(jindex); | ||
| 102 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 26 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 26 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 26 times.
|
52 | BOOST_CHECK(jindex == jmodel1.id()); |
| 103 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 26 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 26 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 26 times.
|
52 | BOOST_CHECK(jindex == jmodel2.id()); |
| 104 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint1 name: " << jmodel1.shortname() << std::endl; |
| 105 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint2 name: " << jmodel2.shortname() << std::endl; |
| 106 | } | ||
| 107 | }; | ||
| 108 | |||
| 109 | struct SimpleBinaryVisitor2 : public pinocchio::fusion::JointBinaryVisitorBase<SimpleBinaryVisitor2> | ||
| 110 | { | ||
| 111 | |||
| 112 | typedef bf::vector<const pinocchio::Model &, pinocchio::Data &, pinocchio::JointIndex> ArgsType; | ||
| 113 | |||
| 114 | template<typename JointModel1, typename JointModel2> | ||
| 115 | 52 | static void algo( | |
| 116 | const pinocchio::JointModelBase<JointModel1> & jmodel1, | ||
| 117 | const pinocchio::JointModelBase<JointModel2> & jmodel2, | ||
| 118 | const pinocchio::Model & model, | ||
| 119 | pinocchio::Data & data, | ||
| 120 | pinocchio::JointIndex jindex) | ||
| 121 | { | ||
| 122 | PINOCCHIO_UNUSED_VARIABLE(model); | ||
| 123 | PINOCCHIO_UNUSED_VARIABLE(data); | ||
| 124 | PINOCCHIO_UNUSED_VARIABLE(jindex); | ||
| 125 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 26 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 26 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 26 times.
|
52 | BOOST_CHECK(jindex == jmodel1.id()); |
| 126 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 26 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 26 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 26 times.
|
52 | BOOST_CHECK(jindex == jmodel2.id()); |
| 127 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint1 name: " << jmodel1.shortname() << std::endl; |
| 128 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint2 name: " << jmodel2.shortname() << std::endl; |
| 129 | } | ||
| 130 | }; | ||
| 131 | |||
| 132 | struct SimpleBinaryVisitor3 : public pinocchio::fusion::JointBinaryVisitorBase<SimpleBinaryVisitor3> | ||
| 133 | { | ||
| 134 | template<typename JointModel1, typename JointModel2> | ||
| 135 | 52 | static void algo( | |
| 136 | const pinocchio::JointModelBase<JointModel1> & jmodel1, | ||
| 137 | const pinocchio::JointModelBase<JointModel2> & jmodel2) | ||
| 138 | { | ||
| 139 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 16 taken 26 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 26 times.
✗ Branch 20 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 26 times.
|
52 | BOOST_CHECK(!jmodel1.shortname().empty()); |
| 140 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 16 taken 26 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 26 times.
✗ Branch 20 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 26 times.
|
52 | BOOST_CHECK(!jmodel2.shortname().empty()); |
| 141 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint1 name: " << jmodel1.shortname() << std::endl; |
| 142 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint2 name: " << jmodel2.shortname() << std::endl; |
| 143 | } | ||
| 144 | }; | ||
| 145 | |||
| 146 | struct SimpleBinaryVisitor4 : public pinocchio::fusion::JointBinaryVisitorBase<SimpleBinaryVisitor4> | ||
| 147 | { | ||
| 148 | template<typename JointModel1, typename JointModel2> | ||
| 149 | 52 | static void algo( | |
| 150 | const pinocchio::JointModelBase<JointModel1> & jmodel1, | ||
| 151 | const pinocchio::JointModelBase<JointModel2> & jmodel2, | ||
| 152 | pinocchio::JointDataBase<typename JointModel1::JointDataDerived> & jdata1, | ||
| 153 | pinocchio::JointDataBase<typename JointModel2::JointDataDerived> & jdata2) | ||
| 154 | { | ||
| 155 | PINOCCHIO_UNUSED_VARIABLE(jdata1); | ||
| 156 | PINOCCHIO_UNUSED_VARIABLE(jdata2); | ||
| 157 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 16 taken 26 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 26 times.
✗ Branch 20 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 26 times.
|
52 | BOOST_CHECK(!jmodel1.shortname().empty()); |
| 158 |
6/12✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 26 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 26 times.
✗ Branch 13 not taken.
✓ Branch 16 taken 26 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 26 times.
✗ Branch 20 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 26 times.
|
52 | BOOST_CHECK(!jmodel2.shortname().empty()); |
| 159 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint1 name: " << jmodel1.shortname() << std::endl; |
| 160 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "joint2 name: " << jmodel2.shortname() << std::endl; |
| 161 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "jdata1 name: " << jdata1.classname() << std::endl; |
| 162 |
2/4✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
|
52 | std::cout << "jdata2 name: " << jdata2.classname() << std::endl; |
| 163 | } | ||
| 164 | }; | ||
| 165 | |||
| 166 | BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) | ||
| 167 | |||
| 168 | template<typename JointModel_> | ||
| 169 | struct init; | ||
| 170 | |||
| 171 | template<typename JointModel_> | ||
| 172 | struct init | ||
| 173 | { | ||
| 174 | 76 | static JointModel_ run(const pinocchio::Model & /* model*/) | |
| 175 | { | ||
| 176 | 76 | JointModel_ jmodel; | |
| 177 | 76 | return jmodel; | |
| 178 | } | ||
| 179 | }; | ||
| 180 | |||
| 181 | template<typename Scalar, int Options> | ||
| 182 | struct init<pinocchio::JointModelRevoluteUnalignedTpl<Scalar, Options>> | ||
| 183 | { | ||
| 184 | typedef pinocchio::JointModelRevoluteUnalignedTpl<Scalar, Options> JointModel; | ||
| 185 | |||
| 186 | 2 | static JointModel run(const pinocchio::Model & /* model*/) | |
| 187 | { | ||
| 188 | typedef typename JointModel::Vector3 Vector3; | ||
| 189 |
2/4✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
2 | JointModel jmodel(Vector3::Random().normalized()); |
| 190 | |||
| 191 | 2 | return jmodel; | |
| 192 | } | ||
| 193 | }; | ||
| 194 | |||
| 195 | template<typename Scalar, int Options> | ||
| 196 | struct init<pinocchio::JointModelRevoluteUnboundedUnalignedTpl<Scalar, Options>> | ||
| 197 | { | ||
| 198 | typedef pinocchio::JointModelRevoluteUnboundedUnalignedTpl<Scalar, Options> JointModel; | ||
| 199 | |||
| 200 | 2 | static JointModel run(const pinocchio::Model & /* model*/) | |
| 201 | { | ||
| 202 | typedef typename JointModel::Vector3 Vector3; | ||
| 203 |
2/4✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
2 | JointModel jmodel(Vector3::Random().normalized()); |
| 204 | |||
| 205 | 2 | return jmodel; | |
| 206 | } | ||
| 207 | }; | ||
| 208 | |||
| 209 | template<typename Scalar, int Options> | ||
| 210 | struct init<pinocchio::JointModelPrismaticUnalignedTpl<Scalar, Options>> | ||
| 211 | { | ||
| 212 | typedef pinocchio::JointModelPrismaticUnalignedTpl<Scalar, Options> JointModel; | ||
| 213 | |||
| 214 | 2 | static JointModel run(const pinocchio::Model & /* model*/) | |
| 215 | { | ||
| 216 | typedef typename JointModel::Vector3 Vector3; | ||
| 217 |
2/4✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
2 | JointModel jmodel(Vector3::Random().normalized()); |
| 218 | |||
| 219 | 2 | return jmodel; | |
| 220 | } | ||
| 221 | }; | ||
| 222 | |||
| 223 | template<typename Scalar, int Options, template<typename, int> class JointCollection> | ||
| 224 | struct init<pinocchio::JointModelTpl<Scalar, Options, JointCollection>> | ||
| 225 | { | ||
| 226 | typedef pinocchio::JointModelTpl<Scalar, Options, JointCollection> JointModel; | ||
| 227 | |||
| 228 | static JointModel run(const pinocchio::Model & /* model*/) | ||
| 229 | { | ||
| 230 | typedef pinocchio::JointModelRevoluteTpl<Scalar, Options, 0> JointModelRX; | ||
| 231 | JointModel jmodel((JointModelRX())); | ||
| 232 | |||
| 233 | return jmodel; | ||
| 234 | } | ||
| 235 | }; | ||
| 236 | |||
| 237 | template<typename Scalar, int Options, template<typename, int> class JointCollection> | ||
| 238 | struct init<pinocchio::JointModelCompositeTpl<Scalar, Options, JointCollection>> | ||
| 239 | { | ||
| 240 | typedef pinocchio::JointModelCompositeTpl<Scalar, Options, JointCollection> JointModel; | ||
| 241 | |||
| 242 | 2 | static JointModel run(const pinocchio::Model & /* model*/) | |
| 243 | { | ||
| 244 | typedef pinocchio::JointModelRevoluteTpl<Scalar, Options, 0> JointModelRX; | ||
| 245 | typedef pinocchio::JointModelRevoluteTpl<Scalar, Options, 1> JointModelRY; | ||
| 246 | typedef pinocchio::JointModelRevoluteTpl<Scalar, Options, 2> JointModelRZ; | ||
| 247 | |||
| 248 |
2/4✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
2 | JointModel jmodel(JointModelRX(), pinocchio::SE3::Random()); |
| 249 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | jmodel.addJoint(JointModelRY(), pinocchio::SE3::Random()); |
| 250 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | jmodel.addJoint(JointModelRZ(), pinocchio::SE3::Random()); |
| 251 | |||
| 252 | 2 | return jmodel; | |
| 253 | } | ||
| 254 | }; | ||
| 255 | |||
| 256 | template<typename JointModel_> | ||
| 257 | struct init<pinocchio::JointModelMimic<JointModel_>> | ||
| 258 | { | ||
| 259 | typedef pinocchio::JointModelMimic<JointModel_> JointModel; | ||
| 260 | |||
| 261 | 12 | static JointModel run(const pinocchio::Model & model) | |
| 262 | { | ||
| 263 |
1/2✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
12 | const pinocchio::JointIndex joint_id = model.getJointId(JointModel_::classname()); |
| 264 | |||
| 265 |
2/4✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
|
12 | JointModel jmodel(boost::get<JointModel_>(model.joints[joint_id]), 1., 0.); |
| 266 | |||
| 267 | 12 | return jmodel; | |
| 268 | } | ||
| 269 | }; | ||
| 270 | |||
| 271 | struct AppendJointToModel | ||
| 272 | { | ||
| 273 | 2 | AppendJointToModel(pinocchio::Model & model) | |
| 274 | 2 | : model(model) | |
| 275 | { | ||
| 276 | 2 | } | |
| 277 | |||
| 278 | template<typename JointModel> | ||
| 279 | 104 | void operator()(const pinocchio::JointModelBase<JointModel> &) const | |
| 280 | { | ||
| 281 |
1/2✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
|
104 | JointModel jmodel = init<JointModel>::run(model); |
| 282 |
4/8✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 52 times.
✗ Branch 12 not taken.
|
104 | model.addJoint(model.joints.size() - 1, jmodel, pinocchio::SE3::Random(), jmodel.classname()); |
| 283 | 104 | } | |
| 284 | |||
| 285 | pinocchio::Model & model; | ||
| 286 | }; | ||
| 287 | |||
| 288 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_run_over_all_joints_unary_visitor) |
| 289 | { | ||
| 290 | using namespace pinocchio; | ||
| 291 | |||
| 292 | typedef JointCollectionDefault::JointModelVariant Variant; | ||
| 293 | |||
| 294 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Model model; |
| 295 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | boost::mpl::for_each<Variant::types>(AppendJointToModel(model)); |
| 296 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Data data(model); |
| 297 | |||
| 298 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
|
54 | for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i) |
| 299 | { | ||
| 300 |
1/2✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
|
52 | SimpleUnaryVisitor1::run( |
| 301 |
1/2✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
|
104 | model.joints[i], data.joints[i], SimpleUnaryVisitor1::ArgsType(model, data, i)); |
| 302 | } | ||
| 303 | |||
| 304 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
|
54 | for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i) |
| 305 | { | ||
| 306 |
2/4✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
|
52 | SimpleUnaryVisitor2::run(model.joints[i], SimpleUnaryVisitor2::ArgsType(model, data, i)); |
| 307 | } | ||
| 308 | |||
| 309 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
|
54 | for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i) |
| 310 | { | ||
| 311 |
1/2✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
|
52 | SimpleUnaryVisitor3::run(model.joints[i]); |
| 312 | } | ||
| 313 | |||
| 314 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
|
54 | for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i) |
| 315 | { | ||
| 316 |
1/2✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
|
52 | SimpleUnaryVisitor4::run(model.joints[i], data.joints[i]); |
| 317 | } | ||
| 318 | 2 | } | |
| 319 | |||
| 320 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_run_over_all_joints_binary_visitor) |
| 321 | { | ||
| 322 | using namespace pinocchio; | ||
| 323 | |||
| 324 | typedef JointCollectionDefault::JointModelVariant Variant; | ||
| 325 | |||
| 326 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Model model; |
| 327 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | boost::mpl::for_each<Variant::types>(AppendJointToModel(model)); |
| 328 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Data data(model); |
| 329 | |||
| 330 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
|
54 | for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i) |
| 331 | { | ||
| 332 |
1/2✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
|
52 | SimpleBinaryVisitor1::run( |
| 333 | 52 | model.joints[i], model.joints[i], data.joints[i], data.joints[i], | |
| 334 |
1/2✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
|
104 | SimpleBinaryVisitor1::ArgsType(model, data, i)); |
| 335 | } | ||
| 336 | |||
| 337 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
|
54 | for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i) |
| 338 | { | ||
| 339 |
1/2✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
|
52 | SimpleBinaryVisitor2::run( |
| 340 |
1/2✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
|
104 | model.joints[i], model.joints[i], SimpleBinaryVisitor2::ArgsType(model, data, i)); |
| 341 | } | ||
| 342 | |||
| 343 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
|
54 | for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i) |
| 344 | { | ||
| 345 |
1/2✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
|
52 | SimpleBinaryVisitor3::run(model.joints[i], model.joints[i]); |
| 346 | } | ||
| 347 | |||
| 348 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
|
54 | for (Model::JointIndex i = 1; i < (Model::JointIndex)model.njoints; ++i) |
| 349 | { | ||
| 350 |
1/2✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
|
52 | SimpleBinaryVisitor4::run(model.joints[i], model.joints[i], data.joints[i], data.joints[i]); |
| 351 | } | ||
| 352 | 2 | } | |
| 353 | |||
| 354 | BOOST_AUTO_TEST_SUITE_END() | ||
| 355 |