| Directory: | ./ |
|---|---|
| File: | include/pinocchio/multibody/model.hpp |
| Date: | 2025-04-30 16:14:33 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 36 | 36 | 100.0% |
| Branches: | 82 | 155 | 52.9% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2015-2020 CNRS INRIA | ||
| 3 | // Copyright (c) 2015 Wandercraft, 86 rue de Paris 91400 Orsay, France. | ||
| 4 | // | ||
| 5 | |||
| 6 | #ifndef __pinocchio_multibody_model_hpp__ | ||
| 7 | #define __pinocchio_multibody_model_hpp__ | ||
| 8 | |||
| 9 | #include "pinocchio/spatial/fwd.hpp" | ||
| 10 | #include "pinocchio/spatial/se3.hpp" | ||
| 11 | #include "pinocchio/spatial/force.hpp" | ||
| 12 | #include "pinocchio/spatial/motion.hpp" | ||
| 13 | #include "pinocchio/spatial/inertia.hpp" | ||
| 14 | |||
| 15 | #include "pinocchio/multibody/fwd.hpp" | ||
| 16 | #include "pinocchio/multibody/frame.hpp" | ||
| 17 | #include "pinocchio/multibody/joint/joint-generic.hpp" | ||
| 18 | |||
| 19 | #include "pinocchio/container/aligned-vector.hpp" | ||
| 20 | |||
| 21 | #include "pinocchio/serialization/serializable.hpp" | ||
| 22 | |||
| 23 | #include <map> | ||
| 24 | #include <iterator> | ||
| 25 | |||
| 26 | namespace pinocchio | ||
| 27 | { | ||
| 28 | template< | ||
| 29 | typename NewScalar, | ||
| 30 | typename Scalar, | ||
| 31 | int Options, | ||
| 32 | template<typename, int> class JointCollectionTpl> | ||
| 33 | struct CastType<NewScalar, ModelTpl<Scalar, Options, JointCollectionTpl>> | ||
| 34 | { | ||
| 35 | typedef ModelTpl<NewScalar, Options, JointCollectionTpl> type; | ||
| 36 | }; | ||
| 37 | |||
| 38 | template<typename _Scalar, int _Options, template<typename, int> class JointCollectionTpl> | ||
| 39 | struct traits<ModelTpl<_Scalar, _Options, JointCollectionTpl>> | ||
| 40 | { | ||
| 41 | typedef _Scalar Scalar; | ||
| 42 | }; | ||
| 43 | |||
| 44 | template<typename _Scalar, int _Options, template<typename, int> class JointCollectionTpl> | ||
| 45 | struct ModelTpl | ||
| 46 | : serialization::Serializable<ModelTpl<_Scalar, _Options, JointCollectionTpl>> | ||
| 47 | , NumericalBase<ModelTpl<_Scalar, _Options, JointCollectionTpl>> | ||
| 48 | { | ||
| 49 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
| 50 | |||
| 51 | typedef _Scalar Scalar; | ||
| 52 | enum | ||
| 53 | { | ||
| 54 | Options = _Options | ||
| 55 | }; | ||
| 56 | |||
| 57 | typedef JointCollectionTpl<Scalar, Options> JointCollection; | ||
| 58 | typedef DataTpl<Scalar, Options, JointCollectionTpl> Data; | ||
| 59 | |||
| 60 | typedef SE3Tpl<Scalar, Options> SE3; | ||
| 61 | typedef MotionTpl<Scalar, Options> Motion; | ||
| 62 | typedef ForceTpl<Scalar, Options> Force; | ||
| 63 | typedef InertiaTpl<Scalar, Options> Inertia; | ||
| 64 | typedef FrameTpl<Scalar, Options> Frame; | ||
| 65 | |||
| 66 | typedef pinocchio::Index Index; | ||
| 67 | typedef pinocchio::JointIndex JointIndex; | ||
| 68 | typedef pinocchio::GeomIndex GeomIndex; | ||
| 69 | typedef pinocchio::FrameIndex FrameIndex; | ||
| 70 | typedef std::vector<Index> IndexVector; | ||
| 71 | |||
| 72 | typedef JointModelTpl<Scalar, Options, JointCollectionTpl> JointModel; | ||
| 73 | typedef JointDataTpl<Scalar, Options, JointCollectionTpl> JointData; | ||
| 74 | |||
| 75 | typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointModel) JointModelVector; | ||
| 76 | typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointData) JointDataVector; | ||
| 77 | |||
| 78 | typedef PINOCCHIO_ALIGNED_STD_VECTOR(Frame) FrameVector; | ||
| 79 | |||
| 80 | typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Options> VectorXs; | ||
| 81 | typedef Eigen::Matrix<Scalar, 3, 1, Options> Vector3; | ||
| 82 | |||
| 83 | typedef PINOCCHIO_ALIGNED_STD_VECTOR(Inertia) InertiaVector; | ||
| 84 | typedef PINOCCHIO_ALIGNED_STD_VECTOR(SE3) SE3Vector; | ||
| 85 | |||
| 86 | /// \brief Dense vectorized version of a joint configuration vector. | ||
| 87 | typedef VectorXs ConfigVectorType; | ||
| 88 | |||
| 89 | /// \brief Map between a string (key) and a configuration vector | ||
| 90 | typedef std::map<std::string, ConfigVectorType> ConfigVectorMap; | ||
| 91 | |||
| 92 | /// \brief Dense vectorized version of a joint tangent vector (e.g. velocity, acceleration, | ||
| 93 | /// etc). | ||
| 94 | /// It also handles the notion of co-tangent vector (e.g. torque, etc). | ||
| 95 | typedef VectorXs TangentVectorType; | ||
| 96 | |||
| 97 | /// \brief Dimension of the configuration vector representation. | ||
| 98 | int nq; | ||
| 99 | |||
| 100 | /// \brief Dimension of the velocity vector space. | ||
| 101 | int nv; | ||
| 102 | |||
| 103 | /// \brief Dimension of the jacobian space. | ||
| 104 | int nvExtended; | ||
| 105 | |||
| 106 | /// \brief Number of joints. | ||
| 107 | int njoints; | ||
| 108 | |||
| 109 | /// \brief Number of bodies. | ||
| 110 | int nbodies; | ||
| 111 | |||
| 112 | /// \brief Number of operational frames. | ||
| 113 | int nframes; | ||
| 114 | |||
| 115 | /// \brief Vector of spatial inertias supported by each joint. | ||
| 116 | InertiaVector inertias; | ||
| 117 | |||
| 118 | /// \brief Vector of joint placements: placement of a joint *i* wrt its parent joint frame. | ||
| 119 | SE3Vector jointPlacements; | ||
| 120 | |||
| 121 | /// \brief Vector of joint models. | ||
| 122 | JointModelVector joints; | ||
| 123 | |||
| 124 | /// \brief Vector of starting index of the *i*th joint in the configuration space. | ||
| 125 | std::vector<int> idx_qs; | ||
| 126 | |||
| 127 | /// \brief Vector of dimension of the joint configuration subspace. | ||
| 128 | std::vector<int> nqs; | ||
| 129 | |||
| 130 | /// \brief Starting index of the *i*th joint in the tangent configuration space. | ||
| 131 | std::vector<int> idx_vs; | ||
| 132 | |||
| 133 | /// \brief Dimension of the *i*th joint tangent subspace. | ||
| 134 | std::vector<int> nvs; | ||
| 135 | |||
| 136 | /// \brief Starting index of the *i*th joint in the jacobian space. | ||
| 137 | std::vector<int> idx_vExtendeds; | ||
| 138 | |||
| 139 | /// \brief Dimension of the *i*th joint jacobian subspace. | ||
| 140 | std::vector<int> nvExtendeds; | ||
| 141 | |||
| 142 | /// \brief Vector of parent joint indexes. The parent of joint *i*, denoted *li*, corresponds to | ||
| 143 | /// li==parents[i]. | ||
| 144 | std::vector<JointIndex> parents; | ||
| 145 | |||
| 146 | /// \brief Vector of children index. Chidren of the *i*th joint, denoted *mu(i)* corresponds to | ||
| 147 | /// the set (i==parents[k] for k in mu(i)). | ||
| 148 | std::vector<IndexVector> children; | ||
| 149 | |||
| 150 | /// \brief Vector of mimicking joints in the tree (with type MimicTpl) | ||
| 151 | std::vector<JointIndex> mimicking_joints; | ||
| 152 | |||
| 153 | /// \brief Vector of mimicked joints in the tree (can be any joint type) | ||
| 154 | /// The i-th element of this vector correspond to the mimicked joint of the i-th mimicking | ||
| 155 | /// vector in mimicking_joints | ||
| 156 | std::vector<JointIndex> mimicked_joints; | ||
| 157 | |||
| 158 | /// \brief Name of the joints. | ||
| 159 | std::vector<std::string> names; | ||
| 160 | |||
| 161 | /// \brief Map of reference configurations, indexed by user given names. | ||
| 162 | ConfigVectorMap referenceConfigurations; | ||
| 163 | |||
| 164 | /// \brief Vector of armature values expressed at the joint level | ||
| 165 | /// This vector may contain the contribution of rotor inertia effects for instance. | ||
| 166 | VectorXs armature; | ||
| 167 | |||
| 168 | /// \brief Vector of rotor inertia parameters | ||
| 169 | TangentVectorType rotorInertia; | ||
| 170 | |||
| 171 | /// \brief Vector of rotor gear ratio parameters | ||
| 172 | TangentVectorType rotorGearRatio; | ||
| 173 | |||
| 174 | /// \brief Vector of joint friction parameters | ||
| 175 | TangentVectorType friction; | ||
| 176 | |||
| 177 | /// \brief Vector of joint damping parameters | ||
| 178 | TangentVectorType damping; | ||
| 179 | |||
| 180 | /// \brief Vector of maximal joint torques | ||
| 181 | TangentVectorType effortLimit; | ||
| 182 | |||
| 183 | /// \brief Vector of maximal joint velocities | ||
| 184 | TangentVectorType velocityLimit; | ||
| 185 | |||
| 186 | /// \brief Lower joint configuration limit | ||
| 187 | ConfigVectorType lowerPositionLimit; | ||
| 188 | |||
| 189 | /// \brief Upper joint configuration limit | ||
| 190 | ConfigVectorType upperPositionLimit; | ||
| 191 | |||
| 192 | /// \brief Vector of operational frames registered on the model. | ||
| 193 | FrameVector frames; | ||
| 194 | |||
| 195 | /// \brief Vector of joint supports. | ||
| 196 | /// supports[j] corresponds to the vector of indices of the joints located on the path between | ||
| 197 | /// joint *j* and "universe". | ||
| 198 | /// The first element of supports[j] is "universe", the last one is the index of joint *j* | ||
| 199 | /// itself. | ||
| 200 | std::vector<IndexVector> supports; | ||
| 201 | |||
| 202 | /// \brief Vector of mimic supports joints. | ||
| 203 | /// mimic_joint_supports[j] corresponds to the vector of mimic joints indices located on the | ||
| 204 | /// path between joint *j* and "universe". The first element of mimic_joint_supports[j] is | ||
| 205 | /// "universe". If *j* is a mimic, the last element is the index of joint *j* itself. | ||
| 206 | std::vector<IndexVector> mimic_joint_supports; | ||
| 207 | |||
| 208 | /// \brief Vector of joint subtrees. | ||
| 209 | /// subtree[j] corresponds to the subtree supported by the joint *j*. | ||
| 210 | /// The first element of subtree[j] is the index of the joint *j* itself. | ||
| 211 | std::vector<IndexVector> subtrees; | ||
| 212 | |||
| 213 | /// \brief Spatial gravity of the model. | ||
| 214 | Motion gravity; | ||
| 215 | |||
| 216 | /// \brief Default 3D gravity vector (=(0,0,-9.81)). | ||
| 217 | static const Vector3 gravity981; | ||
| 218 | |||
| 219 | /// \brief Model name. | ||
| 220 | std::string name; | ||
| 221 | |||
| 222 | /// \brief Default constructor. Builds an empty model with no joints. | ||
| 223 | 1016 | ModelTpl() | |
| 224 | 1016 | : nq(0) | |
| 225 | 1016 | , nv(0) | |
| 226 | 1016 | , nvExtended(0) | |
| 227 | 1016 | , njoints(1) | |
| 228 | 1016 | , nbodies(1) | |
| 229 | 1016 | , nframes(0) | |
| 230 |
2/4✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1011 times.
✗ Branch 6 not taken.
|
1016 | , inertias(1, Inertia::Zero()) |
| 231 |
2/4✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1011 times.
✗ Branch 6 not taken.
|
1016 | , jointPlacements(1, SE3::Identity()) |
| 232 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , joints(1) |
| 233 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , idx_qs(1, 0) |
| 234 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , nqs(1, 0) |
| 235 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , idx_vs(1, 0) |
| 236 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , nvs(1, 0) |
| 237 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , idx_vExtendeds(1, 0) |
| 238 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , nvExtendeds(1, 0) |
| 239 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , parents(1, 0) |
| 240 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , children(1) |
| 241 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , names(1) |
| 242 |
2/4✓ Branch 3 taken 1011 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1011 times.
✗ Branch 7 not taken.
|
1016 | , supports(1, IndexVector(1, 0)) |
| 243 |
2/4✓ Branch 3 taken 1011 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1011 times.
✗ Branch 7 not taken.
|
1016 | , mimic_joint_supports(1, IndexVector(1, 0)) |
| 244 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | , subtrees(1) |
| 245 |
12/24✓ Branch 4 taken 1011 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1011 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1011 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1011 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1011 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1011 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1011 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1011 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1011 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1011 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1011 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1011 times.
✗ Branch 38 not taken.
|
3048 | , gravity(gravity981, Vector3::Zero()) |
| 246 | { | ||
| 247 |
1/2✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
|
1016 | names[0] = "universe"; // Should be "universe joint (trivial)" |
| 248 | // FIXME Should the universe joint be a FIXED_JOINT even if it is | ||
| 249 | // in the list of joints ? See comment in definition of | ||
| 250 | // Model::addJointFrame and Model::addBodyFrame | ||
| 251 |
5/10✓ Branch 1 taken 1011 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1011 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1011 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1011 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1011 times.
✗ Branch 15 not taken.
|
1016 | addFrame(Frame("universe", 0, 0, SE3::Identity(), FIXED_JOINT)); |
| 252 | 1016 | } | |
| 253 | |||
| 254 | /// | ||
| 255 | /// \brief Copy constructor by casting | ||
| 256 | /// | ||
| 257 | /// \param[in] other model to copy to *this | ||
| 258 | /// | ||
| 259 | template<typename S2, int O2> | ||
| 260 | 1 | explicit ModelTpl(const ModelTpl<S2, O2> & other) | |
| 261 |
13/26✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 1 times.
✗ Branch 27 not taken.
✓ Branch 29 taken 1 times.
✗ Branch 30 not taken.
✓ Branch 32 taken 1 times.
✗ Branch 33 not taken.
✓ Branch 35 taken 1 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 1 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 1 times.
✗ Branch 45 not taken.
✓ Branch 47 taken 1 times.
✗ Branch 48 not taken.
✓ Branch 53 taken 1 times.
✗ Branch 54 not taken.
|
1 | { |
| 262 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | *this = other.template cast<Scalar>(); |
| 263 | 1 | } | |
| 264 | |||
| 265 | /// \returns A new copy of *this with the Scalar type casted to NewScalar. | ||
| 266 | template<typename NewScalar> | ||
| 267 | typename CastType<NewScalar, ModelTpl>::type cast() const; | ||
| 268 | |||
| 269 | /// | ||
| 270 | /// \brief Equality comparison operator. | ||
| 271 | /// | ||
| 272 | /// \returns true if *this is equal to other. | ||
| 273 | /// | ||
| 274 | bool operator==(const ModelTpl & other) const; | ||
| 275 | |||
| 276 | /// | ||
| 277 | /// \returns true if *this is NOT equal to other. | ||
| 278 | /// | ||
| 279 | 4 | bool operator!=(const ModelTpl & other) const | |
| 280 | { | ||
| 281 | 4 | return !(*this == other); | |
| 282 | } | ||
| 283 | |||
| 284 | /// | ||
| 285 | /// \brief Add a joint to the kinematic tree with infinite bounds. | ||
| 286 | /// | ||
| 287 | /// \remarks This method does not add a Frame of same name to the vector of frames. | ||
| 288 | /// Use Model::addJointFrame. | ||
| 289 | /// \remarks The inertia supported by the joint is set to Zero. | ||
| 290 | /// \remark Joints need to be added to the tree in a depth-first order. | ||
| 291 | /// | ||
| 292 | /// \tparam JointModelDerived The type of the joint model. | ||
| 293 | /// | ||
| 294 | /// \param[in] parent Index of the parent joint. | ||
| 295 | /// \param[in] joint_model The joint model. | ||
| 296 | /// \param[in] joint_placement Placement of the joint inside its parent joint. | ||
| 297 | /// \param[in] joint_name Name of the joint. If empty, the name is random. | ||
| 298 | /// | ||
| 299 | /// \return The index of the new joint. | ||
| 300 | /// | ||
| 301 | /// \sa Model::appendBodyToJoint | ||
| 302 | /// | ||
| 303 | JointIndex addJoint( | ||
| 304 | const JointIndex parent, | ||
| 305 | const JointModel & joint_model, | ||
| 306 | const SE3 & joint_placement, | ||
| 307 | const std::string & joint_name); | ||
| 308 | |||
| 309 | /// | ||
| 310 | /// \copydoc ModelTpl::addJoint(const JointIndex,const JointModel &,const SE3 &,const | ||
| 311 | /// std::string &) | ||
| 312 | /// | ||
| 313 | /// \param[in] max_effort Maximal joint torque. | ||
| 314 | /// \param[in] max_velocity Maximal joint velocity. | ||
| 315 | /// \param[in] min_config Lower joint configuration. | ||
| 316 | /// \param[in] max_config Upper joint configuration. | ||
| 317 | /// | ||
| 318 | JointIndex addJoint( | ||
| 319 | const JointIndex parent, | ||
| 320 | const JointModel & joint_model, | ||
| 321 | const SE3 & joint_placement, | ||
| 322 | const std::string & joint_name, | ||
| 323 | const VectorXs & max_effort, | ||
| 324 | const VectorXs & max_velocity, | ||
| 325 | const VectorXs & min_config, | ||
| 326 | const VectorXs & max_config); | ||
| 327 | |||
| 328 | /// | ||
| 329 | /// \copydoc ModelTpl::addJoint(const JointIndex,const JointModel &,const SE3 &,const | ||
| 330 | /// std::string &,const VectorXs &,const VectorXs &,const VectorXs &,const VectorXs &) | ||
| 331 | /// | ||
| 332 | /// \param[in] friction Joint friction parameters. | ||
| 333 | /// \param[in] damping Joint damping parameters. | ||
| 334 | /// | ||
| 335 | JointIndex addJoint( | ||
| 336 | const JointIndex parent, | ||
| 337 | const JointModel & joint_model, | ||
| 338 | const SE3 & joint_placement, | ||
| 339 | const std::string & joint_name, | ||
| 340 | const VectorXs & max_effort, | ||
| 341 | const VectorXs & max_velocity, | ||
| 342 | const VectorXs & min_config, | ||
| 343 | const VectorXs & max_config, | ||
| 344 | const VectorXs & friction, | ||
| 345 | const VectorXs & damping); | ||
| 346 | |||
| 347 | /// | ||
| 348 | /// \brief Add a joint to the frame tree. | ||
| 349 | /// | ||
| 350 | /// \param[in] jointIndex Index of the joint. | ||
| 351 | /// \param[in] frameIndex Index of the parent frame. If negative, | ||
| 352 | /// the parent frame is the frame of the parent joint. | ||
| 353 | /// | ||
| 354 | /// \return The index of the new frame | ||
| 355 | /// | ||
| 356 | FrameIndex addJointFrame(const JointIndex & joint_index, int previous_frame_index = -1); | ||
| 357 | |||
| 358 | /// | ||
| 359 | /// \brief Append a body to a given joint of the kinematic tree. | ||
| 360 | /// | ||
| 361 | /// \param[in] joint_index Index of the supporting joint. | ||
| 362 | /// \param[in] Y Spatial inertia of the body. | ||
| 363 | /// \param[in] body_placement The relative placement of the body regarding to the parent joint. | ||
| 364 | /// Set default to the Identity placement. | ||
| 365 | /// | ||
| 366 | /// \sa Model::addJoint | ||
| 367 | /// | ||
| 368 | void appendBodyToJoint( | ||
| 369 | const JointIndex joint_index, | ||
| 370 | const Inertia & Y, | ||
| 371 | const SE3 & body_placement = SE3::Identity()); | ||
| 372 | |||
| 373 | /// | ||
| 374 | /// \brief Add a body to the frame tree. | ||
| 375 | /// | ||
| 376 | /// \param[in] body_name Name of the body. | ||
| 377 | /// \param[in] parentJoint Index of the parent joint. | ||
| 378 | /// \param[in] body_placement The relative placement of the body regarding to the parent joint. | ||
| 379 | /// Set default to the Identity placement. \param[in] parentFrame Index of the parent frame. If | ||
| 380 | /// negative, | ||
| 381 | /// the parent frame is the frame of the parent joint. | ||
| 382 | /// | ||
| 383 | /// \return The index of the new frame | ||
| 384 | /// | ||
| 385 | FrameIndex addBodyFrame( | ||
| 386 | const std::string & body_name, | ||
| 387 | const JointIndex & parentJoint, | ||
| 388 | const SE3 & body_placement = SE3::Identity(), | ||
| 389 | int parentFrame = -1); | ||
| 390 | |||
| 391 | /// | ||
| 392 | /// \brief Return the index of a body given by its name. | ||
| 393 | /// | ||
| 394 | /// \warning If no body is found, return the number of elements at time T. | ||
| 395 | /// This can lead to errors if the model is expanded after this method is called | ||
| 396 | /// (for example to get the id of a parent body) | ||
| 397 | /// | ||
| 398 | /// \param[in] name Name of the body. | ||
| 399 | /// | ||
| 400 | /// \return Index of the body. | ||
| 401 | /// | ||
| 402 | FrameIndex getBodyId(const std::string & name) const; | ||
| 403 | |||
| 404 | /// | ||
| 405 | /// \brief Check if a body given by its name exists. | ||
| 406 | /// | ||
| 407 | /// \param[in] name Name of the body. | ||
| 408 | /// | ||
| 409 | /// \return True if the body exists in the kinematic tree. | ||
| 410 | /// | ||
| 411 | bool existBodyName(const std::string & name) const; | ||
| 412 | |||
| 413 | /// | ||
| 414 | /// \brief Return the index of a joint given by its name. | ||
| 415 | /// | ||
| 416 | /// \warning If no joint is found, return the number of elements at time T. | ||
| 417 | /// This can lead to errors if the model is expanded after this method is called | ||
| 418 | /// (for example to get the id of a parent joint) | ||
| 419 | /// \param[in] name Name of the joint. | ||
| 420 | /// | ||
| 421 | /// \return Index of the joint. | ||
| 422 | /// | ||
| 423 | JointIndex getJointId(const std::string & name) const; | ||
| 424 | |||
| 425 | /// | ||
| 426 | /// \brief Check if a joint given by its name exists. | ||
| 427 | /// | ||
| 428 | /// \param[in] name Name of the joint. | ||
| 429 | /// | ||
| 430 | /// \return True if the joint exists in the kinematic tree. | ||
| 431 | /// | ||
| 432 | bool existJointName(const std::string & name) const; | ||
| 433 | |||
| 434 | /// | ||
| 435 | /// \brief Returns the index of a frame given by its name. | ||
| 436 | /// \sa Model::existFrame to check if the frame exists or not. | ||
| 437 | /// | ||
| 438 | /// \warning If no frame is found, returns the size of the vector of Model::frames. | ||
| 439 | /// This can lead to errors if the model is expanded after this method is called | ||
| 440 | /// (for example to get the id of a parent frame). | ||
| 441 | /// | ||
| 442 | /// \param[in] name Name of the frame. | ||
| 443 | /// \param[in] type Type of the frame. | ||
| 444 | /// | ||
| 445 | /// \return Index of the frame. | ||
| 446 | /// | ||
| 447 | FrameIndex getFrameId( | ||
| 448 | const std::string & name, | ||
| 449 |
25/37✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 749 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 40 times.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 25 times.
✓ Branch 14 taken 40 times.
✓ Branch 15 taken 278 times.
✓ Branch 16 taken 25 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 25 times.
✓ Branch 19 taken 1 times.
✓ Branch 20 taken 278 times.
✓ Branch 21 taken 24 times.
✓ Branch 22 taken 2 times.
✓ Branch 23 taken 24 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 29 times.
✓ Branch 26 taken 274 times.
✓ Branch 28 taken 16 times.
✗ Branch 29 not taken.
✓ Branch 33 taken 16 times.
✗ Branch 34 not taken.
✓ Branch 37 taken 317 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 35 times.
✗ Branch 41 not taken.
✓ Branch 45 taken 35 times.
✗ Branch 46 not taken.
✓ Branch 49 taken 360 times.
✗ Branch 50 not taken.
|
3433 | const FrameType & type = (FrameType)(JOINT | FIXED_JOINT | BODY | OP_FRAME | SENSOR)) const; |
| 450 | |||
| 451 | /// | ||
| 452 | /// \brief Checks if a frame given by its name exists. | ||
| 453 | /// | ||
| 454 | /// \param[in] name Name of the frame. | ||
| 455 | /// \param[in] type Type of the frame. | ||
| 456 | /// | ||
| 457 | /// \return Returns true if the frame exists. | ||
| 458 | /// | ||
| 459 | bool existFrame( | ||
| 460 | const std::string & name, | ||
| 461 |
5/14✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 6 taken 52 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 35 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
|
235 | const FrameType & type = (FrameType)(JOINT | FIXED_JOINT | BODY | OP_FRAME | SENSOR)) const; |
| 462 | |||
| 463 | /// | ||
| 464 | /// \brief Adds a frame to the kinematic tree. | ||
| 465 | /// The inertia stored within the frame will be happened to the inertia supported by the | ||
| 466 | /// joint (frame.parentJoint). | ||
| 467 | /// | ||
| 468 | /// \param[in] frame The frame to add to the kinematic tree. | ||
| 469 | /// \param[in] append_inertia Append the inertia contained in the Frame to the inertia supported | ||
| 470 | /// by the joint. | ||
| 471 | /// | ||
| 472 | /// \return Returns the index of the frame if it has been successfully added or if it already | ||
| 473 | /// exists in the kinematic tree. | ||
| 474 | /// | ||
| 475 | FrameIndex addFrame(const Frame & frame, const bool append_inertia = true); | ||
| 476 | |||
| 477 | /// | ||
| 478 | /// \brief Check the validity of the attributes of Model with respect to the specification of | ||
| 479 | /// some algorithms. | ||
| 480 | /// | ||
| 481 | /// The method is a template so that the checkers can be defined in each algorithms. | ||
| 482 | /// \param[in] checker a class, typically defined in the algorithm module, that | ||
| 483 | /// validates the attributes of model. | ||
| 484 | /// | ||
| 485 | /// \return true if the Model is valid, false otherwise. | ||
| 486 | /// | ||
| 487 | template<typename D> | ||
| 488 | 10998 | bool check(const AlgorithmCheckerBase<D> & checker = AlgorithmCheckerBase<D>()) const | |
| 489 | { | ||
| 490 | 10998 | return checker.checkModel(*this); | |
| 491 | } | ||
| 492 | |||
| 493 | /// | ||
| 494 | /// \brief Check if joints have configuration limits | ||
| 495 | /// | ||
| 496 | /// \return Returns list of boolean of size model.nq. | ||
| 497 | /// | ||
| 498 | std::vector<bool> hasConfigurationLimit(); | ||
| 499 | |||
| 500 | /// | ||
| 501 | /// \brief Check if joints have configuration limits | ||
| 502 | /// | ||
| 503 | /// \return Returns list of boolean of size model.nq. | ||
| 504 | /// | ||
| 505 | std::vector<bool> hasConfigurationLimitInTangent(); | ||
| 506 | |||
| 507 | /// Run check(fusion::list) with DEFAULT_CHECKERS as argument. | ||
| 508 | bool check() const; | ||
| 509 | |||
| 510 | /// | ||
| 511 | /// \brief Run checkData on data and current model. | ||
| 512 | /// | ||
| 513 | /// \param[in] data to be checked wrt *this. | ||
| 514 | /// | ||
| 515 | /// \return true if the data is valid, false otherwise. | ||
| 516 | /// | ||
| 517 | bool check(const Data & data) const; | ||
| 518 | |||
| 519 | protected: | ||
| 520 | /// | ||
| 521 | /// \brief Add the joint_id to its parent subtrees. | ||
| 522 | /// | ||
| 523 | /// \param[in] joint_id The id of the joint to add to the subtrees | ||
| 524 | /// | ||
| 525 | void addJointIndexToParentSubtrees(const JointIndex joint_id); | ||
| 526 | }; | ||
| 527 | |||
| 528 | } // namespace pinocchio | ||
| 529 | |||
| 530 | /* --- Details -------------------------------------------------------------- */ | ||
| 531 | /* --- Details -------------------------------------------------------------- */ | ||
| 532 | /* --- Details -------------------------------------------------------------- */ | ||
| 533 | #include "pinocchio/multibody/model.hxx" | ||
| 534 | |||
| 535 | #if PINOCCHIO_ENABLE_TEMPLATE_INSTANTIATION | ||
| 536 | #include "pinocchio/multibody/model.txx" | ||
| 537 | #endif // PINOCCHIO_ENABLE_TEMPLATE_INSTANTIATION | ||
| 538 | |||
| 539 | #endif // ifndef __pinocchio_multibody_model_hpp__ | ||
| 540 |