multibody/model.hpp
Go to the documentation of this file.
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 
14 
18 
20 
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>
33  class JointCollectionTpl>
34  struct CastType<NewScalar, ModelTpl<Scalar, Options, JointCollectionTpl>>
35  {
37  };
38 
39  template<typename _Scalar, int _Options, template<typename, int> class JointCollectionTpl>
40  struct traits<ModelTpl<_Scalar, _Options, JointCollectionTpl>>
41  {
42  typedef _Scalar Scalar;
43  };
44 
45  template<typename _Scalar, int _Options, template<typename, int> class JointCollectionTpl>
46  struct ModelTpl
47  : serialization::Serializable<ModelTpl<_Scalar, _Options, JointCollectionTpl>>
48  , NumericalBase<ModelTpl<_Scalar, _Options, JointCollectionTpl>>
49  {
50  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
51 
52  typedef _Scalar Scalar;
53  enum
54  {
55  Options = _Options
56  };
57 
58  typedef JointCollectionTpl<Scalar, Options> JointCollection;
60 
66 
71  typedef std::vector<Index> IndexVector;
72 
75 
76  typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointModel) JointModelVector;
77  typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointData) JointDataVector;
78 
79  typedef PINOCCHIO_ALIGNED_STD_VECTOR(Frame) FrameVector;
80 
81  typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Options> VectorXs;
82  typedef Eigen::Matrix<Scalar, 3, 1, Options> Vector3;
83 
84  typedef PINOCCHIO_ALIGNED_STD_VECTOR(Inertia) InertiaVector;
85  typedef PINOCCHIO_ALIGNED_STD_VECTOR(SE3) SE3Vector;
86 
89 
91  typedef std::map<std::string, ConfigVectorType> ConfigVectorMap;
92 
97 
99  int nq;
100 
102  int nv;
103 
105  int njoints;
106 
108  int nbodies;
109 
111  int nframes;
112 
114  InertiaVector inertias;
115 
117  SE3Vector jointPlacements;
118 
120  JointModelVector joints;
121 
123  std::vector<int> idx_qs;
124 
126  std::vector<int> nqs;
127 
129  std::vector<int> idx_vs;
130 
132  std::vector<int> nvs;
133 
136  std::vector<JointIndex> parents;
137 
140  std::vector<IndexVector> children;
141 
143  std::vector<std::string> names;
144 
147 
151 
154 
157 
160 
163 
166 
169 
172 
175 
177  FrameVector frames;
178 
184  std::vector<IndexVector> supports;
185 
189  std::vector<IndexVector> subtrees;
190 
193 
195  static const Vector3 gravity981;
196 
198  std::string name;
199 
202  : nq(0)
203  , nv(0)
204  , njoints(1)
205  , nbodies(1)
206  , nframes(0)
207  , inertias(1, Inertia::Zero())
208  , jointPlacements(1, SE3::Identity())
209  , joints(1)
210  , idx_qs(1, 0)
211  , nqs(1, 0)
212  , idx_vs(1, 0)
213  , nvs(1, 0)
214  , parents(1, 0)
215  , children(1)
216  , names(1)
217  , supports(1, IndexVector(1, 0))
218  , subtrees(1)
219  , gravity(gravity981, Vector3::Zero())
220  {
221  names[0] = "universe"; // Should be "universe joint (trivial)"
222  // FIXME Should the universe joint be a FIXED_JOINT even if it is
223  // in the list of joints ? See comment in definition of
224  // Model::addJointFrame and Model::addBodyFrame
225  addFrame(Frame("universe", 0, 0, SE3::Identity(), FIXED_JOINT));
226  }
227 
233  template<typename S2, int O2>
234  explicit ModelTpl(const ModelTpl<S2, O2> & other)
235  {
236  *this = other.template cast<Scalar>();
237  }
238 
240  template<typename NewScalar>
241  typename CastType<NewScalar, ModelTpl>::type cast() const;
242 
248  bool operator==(const ModelTpl & other) const;
249 
253  bool operator!=(const ModelTpl & other) const
254  {
255  return !(*this == other);
256  }
257 
278  const JointIndex parent,
279  const JointModel & joint_model,
280  const SE3 & joint_placement,
281  const std::string & joint_name);
282 
293  const JointIndex parent,
294  const JointModel & joint_model,
295  const SE3 & joint_placement,
296  const std::string & joint_name,
297  const VectorXs & max_effort,
298  const VectorXs & max_velocity,
299  const VectorXs & min_config,
300  const VectorXs & max_config);
301 
310  const JointIndex parent,
311  const JointModel & joint_model,
312  const SE3 & joint_placement,
313  const std::string & joint_name,
314  const VectorXs & max_effort,
315  const VectorXs & max_velocity,
316  const VectorXs & min_config,
317  const VectorXs & max_config,
318  const VectorXs & friction,
319  const VectorXs & damping);
320 
330  FrameIndex addJointFrame(const JointIndex & joint_index, int previous_frame_index = -1);
331 
342  void appendBodyToJoint(
343  const JointIndex joint_index,
344  const Inertia & Y,
345  const SE3 & body_placement = SE3::Identity());
346 
360  const std::string & body_name,
361  const JointIndex & parentJoint,
362  const SE3 & body_placement = SE3::Identity(),
363  int parentFrame = -1);
364 
376  FrameIndex getBodyId(const std::string & name) const;
377 
385  bool existBodyName(const std::string & name) const;
386 
397  JointIndex getJointId(const std::string & name) const;
398 
406  bool existJointName(const std::string & name) const;
407 
422  const std::string & name,
423  const FrameType & type = (FrameType)(JOINT | FIXED_JOINT | BODY | OP_FRAME | SENSOR)) const;
424 
433  bool existFrame(
434  const std::string & name,
435  const FrameType & type = (FrameType)(JOINT | FIXED_JOINT | BODY | OP_FRAME | SENSOR)) const;
436 
449  FrameIndex addFrame(const Frame & frame, const bool append_inertia = true);
450 
461  template<typename D>
462  bool check(const AlgorithmCheckerBase<D> & checker = AlgorithmCheckerBase<D>()) const
463  {
464  return checker.checkModel(*this);
465  }
466 
472  std::vector<bool> hasConfigurationLimit();
473 
479  std::vector<bool> hasConfigurationLimitInTangent();
480 
482  bool check() const;
483 
491  bool check(const Data & data) const;
492 
493  protected:
500  };
501 
502 } // namespace pinocchio
503 
504 /* --- Details -------------------------------------------------------------- */
505 /* --- Details -------------------------------------------------------------- */
506 /* --- Details -------------------------------------------------------------- */
507 #include "pinocchio/multibody/model.hxx"
508 
509 #if PINOCCHIO_ENABLE_TEMPLATE_INSTANTIATION
510  #include "pinocchio/multibody/model.txx"
511 #endif // PINOCCHIO_ENABLE_TEMPLATE_INSTANTIATION
512 
513 #endif // ifndef __pinocchio_multibody_model_hpp__
pinocchio::InertiaTpl< Scalar, Options >
pinocchio::FrameIndex
Index FrameIndex
Definition: multibody/fwd.hpp:28
fwd.hpp
pinocchio::ModelTpl::names
std::vector< std::string > names
Name of the joints.
Definition: multibody/model.hpp:143
pinocchio::NumericalBase
Definition: fwd.hpp:89
pinocchio::ModelTpl::frames
FrameVector frames
Vector of operational frames registered on the model.
Definition: multibody/model.hpp:177
pinocchio::DataTpl
Definition: context/generic.hpp:25
pinocchio::AlgorithmCheckerBase
CRTP class describing the API of the checkers.
Definition: algorithm/check.hpp:22
pinocchio::ModelTpl::existJointName
bool existJointName(const std::string &name) const
Check if a joint given by its name exists.
pinocchio::ModelTpl::SE3
SE3Tpl< Scalar, Options > SE3
Definition: multibody/model.hpp:61
pinocchio::ModelTpl::jointPlacements
SE3Vector jointPlacements
Vector of joint placements: placement of a joint i wrt its parent joint frame.
Definition: multibody/model.hpp:117
pinocchio::ModelTpl::GeomIndex
pinocchio::GeomIndex GeomIndex
Definition: multibody/model.hpp:69
lambdas.parent
parent
Definition: lambdas.py:20
pinocchio::ModelTpl::lowerPositionLimit
ConfigVectorType lowerPositionLimit
Lower joint configuration limit.
Definition: multibody/model.hpp:171
pinocchio::ModelTpl::existBodyName
bool existBodyName(const std::string &name) const
Check if a body given by its name exists.
pinocchio::ModelTpl::ModelTpl
ModelTpl()
Default constructor. Builds an empty model with no joints.
Definition: multibody/model.hpp:201
aligned-vector.hpp
pinocchio::Options
Options
Definition: joint-configuration.hpp:1116
pinocchio::ModelTpl::cast
CastType< NewScalar, ModelTpl >::type cast() const
pinocchio::ModelTpl::Motion
MotionTpl< Scalar, Options > Motion
Definition: multibody/model.hpp:62
pinocchio::ModelTpl::operator==
bool operator==(const ModelTpl &other) const
Equality comparison operator.
pinocchio::ModelTpl::operator!=
bool operator!=(const ModelTpl &other) const
Definition: multibody/model.hpp:253
pinocchio::FrameType
FrameType
Enum on the possible types of frames.
Definition: multibody/frame.hpp:31
pinocchio::SE3Tpl< Scalar, Options >
pinocchio::SENSOR
@ SENSOR
sensor frame: defined in a sensor element
Definition: multibody/frame.hpp:38
serializable.hpp
setup.data
data
Definition: cmake/cython/setup.in.py:48
inertia.hpp
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
pinocchio::ModelTpl::joints
JointModelVector joints
Vector of joint models.
Definition: multibody/model.hpp:120
pinocchio::JointDataTpl
Definition: multibody/joint/fwd.hpp:162
pinocchio::ModelTpl::existFrame
bool existFrame(const std::string &name, const FrameType &type=(FrameType)(JOINT|FIXED_JOINT|BODY|OP_FRAME|SENSOR)) const
Checks if a frame given by its name exists.
pinocchio::ModelTpl::Data
DataTpl< Scalar, Options, JointCollectionTpl > Data
Definition: multibody/model.hpp:59
motion.hpp
pinocchio::ModelTpl::name
std::string name
Model name.
Definition: multibody/model.hpp:198
pinocchio::ModelTpl::addJoint
JointIndex addJoint(const JointIndex parent, const JointModel &joint_model, const SE3 &joint_placement, const std::string &joint_name)
Add a joint to the kinematic tree with infinite bounds.
pinocchio::ModelTpl::hasConfigurationLimit
std::vector< bool > hasConfigurationLimit()
Check if joints have configuration limits.
pinocchio::ModelTpl::rotorInertia
TangentVectorType rotorInertia
Vector of rotor inertia parameters.
Definition: multibody/model.hpp:153
pinocchio::ModelTpl::check
bool check(const AlgorithmCheckerBase< D > &checker=AlgorithmCheckerBase< D >()) const
Check the validity of the attributes of Model with respect to the specification of some algorithms.
Definition: multibody/model.hpp:462
simulation-pendulum.type
type
Definition: simulation-pendulum.py:18
pinocchio::FrameTpl
A Plucker coordinate frame attached to a parent joint inside a kinematic tree.
Definition: multibody/frame.hpp:55
pinocchio::Index
PINOCCHIO_COMPILER_DIAGNOSTIC_POP typedef std::size_t Index
Definition: multibody/fwd.hpp:22
pinocchio::ModelTpl::inertias
InertiaVector inertias
Vector of spatial inertias supported by each joint.
Definition: multibody/model.hpp:114
pinocchio::ModelTpl::JointIndex
pinocchio::JointIndex JointIndex
Definition: multibody/model.hpp:68
pinocchio::ModelTpl::Force
ForceTpl< Scalar, Options > Force
Definition: multibody/model.hpp:63
pinocchio::ModelTpl::referenceConfigurations
ConfigVectorMap referenceConfigurations
Map of reference configurations, indexed by user given names.
Definition: multibody/model.hpp:146
pinocchio::ModelTpl::Inertia
InertiaTpl< Scalar, Options > Inertia
Definition: multibody/model.hpp:64
pinocchio::ModelTpl::subtrees
std::vector< IndexVector > subtrees
Vector of joint subtrees. subtree[j] corresponds to the subtree supported by the joint j....
Definition: multibody/model.hpp:189
pinocchio::ModelTpl::nqs
std::vector< int > nqs
Vector of dimension of the joint configuration subspace.
Definition: multibody/model.hpp:126
pinocchio::ModelTpl::PINOCCHIO_ALIGNED_STD_VECTOR
typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointModel) JointModelVector
pinocchio::ModelTpl::addBodyFrame
FrameIndex addBodyFrame(const std::string &body_name, const JointIndex &parentJoint, const SE3 &body_placement=SE3::Identity(), int parentFrame=-1)
Add a body to the frame tree.
pinocchio::ModelTpl::nvs
std::vector< int > nvs
Dimension of the *i*th joint tangent subspace.
Definition: multibody/model.hpp:132
pinocchio::ModelTpl::appendBodyToJoint
void appendBodyToJoint(const JointIndex joint_index, const Inertia &Y, const SE3 &body_placement=SE3::Identity())
Append a body to a given joint of the kinematic tree.
pinocchio::ModelTpl::children
std::vector< IndexVector > children
Vector of children index. Chidren of the i*th joint, denoted *mu(i) corresponds to the set (i==parent...
Definition: multibody/model.hpp:140
reachable-workspace-with-collisions.parentJoint
parentJoint
Definition: reachable-workspace-with-collisions.py:48
pinocchio::ModelTpl::idx_qs
std::vector< int > idx_qs
Vector of starting index of the *i*th joint in the configuration space.
Definition: multibody/model.hpp:123
pinocchio::ModelTpl::TangentVectorType
VectorXs TangentVectorType
Dense vectorized version of a joint tangent vector (e.g. velocity, acceleration, etc)....
Definition: multibody/model.hpp:96
pinocchio::ModelTpl::IndexVector
std::vector< Index > IndexVector
Definition: multibody/model.hpp:71
pinocchio::ModelTpl::JointData
JointDataTpl< Scalar, Options, JointCollectionTpl > JointData
Definition: multibody/model.hpp:74
joint-generic.hpp
pinocchio::ModelTpl::getFrameId
FrameIndex getFrameId(const std::string &name, const FrameType &type=(FrameType)(JOINT|FIXED_JOINT|BODY|OP_FRAME|SENSOR)) const
Returns the index of a frame given by its name.
se3.hpp
pinocchio::ModelTpl::hasConfigurationLimitInTangent
std::vector< bool > hasConfigurationLimitInTangent()
Check if joints have configuration limits.
pinocchio::CastType< NewScalar, ModelTpl< Scalar, Options, JointCollectionTpl > >::type
ModelTpl< NewScalar, Options, JointCollectionTpl > type
Definition: multibody/model.hpp:36
pinocchio::JointModelTpl
Definition: multibody/joint/fwd.hpp:155
pinocchio::ForceTpl< Scalar, Options >
pinocchio::ModelTpl::FrameIndex
pinocchio::FrameIndex FrameIndex
Definition: multibody/model.hpp:70
pinocchio::ModelTpl::rotorGearRatio
TangentVectorType rotorGearRatio
Vector of rotor gear ratio parameters.
Definition: multibody/model.hpp:156
pinocchio::ModelTpl::armature
VectorXs armature
Vector of armature values expressed at the joint level This vector may contain the contribution of ro...
Definition: multibody/model.hpp:150
pinocchio::ModelTpl::VectorXs
Eigen::Matrix< Scalar, Eigen::Dynamic, 1, Options > VectorXs
Definition: multibody/model.hpp:81
pinocchio::ModelTpl::Scalar
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
Definition: multibody/model.hpp:52
pinocchio::ModelTpl::addJointIndexToParentSubtrees
void addJointIndexToParentSubtrees(const JointIndex joint_id)
Add the joint_id to its parent subtrees.
pinocchio::ModelTpl::nframes
int nframes
Number of operational frames.
Definition: multibody/model.hpp:111
pinocchio::ModelTpl::velocityLimit
TangentVectorType velocityLimit
Vector of maximal joint velocities.
Definition: multibody/model.hpp:168
pinocchio::ModelTpl::nbodies
int nbodies
Number of bodies.
Definition: multibody/model.hpp:108
pinocchio::ModelTpl::friction
TangentVectorType friction
Vector of joint friction parameters.
Definition: multibody/model.hpp:159
pinocchio::ModelTpl::addJointFrame
FrameIndex addJointFrame(const JointIndex &joint_index, int previous_frame_index=-1)
Add a joint to the frame tree.
contact-cholesky.frame
frame
Definition: contact-cholesky.py:27
pinocchio::ModelTpl::gravity
Motion gravity
Spatial gravity of the model.
Definition: multibody/model.hpp:192
pinocchio::JOINT
@ JOINT
joint frame: attached to the child body of a joint (a.k.a. child frame)
Definition: multibody/frame.hpp:34
pinocchio::ModelTpl::gravity981
static const Vector3 gravity981
Default 3D gravity vector (=(0,0,-9.81)).
Definition: multibody/model.hpp:195
pinocchio::ModelTpl::getJointId
JointIndex getJointId(const std::string &name) const
Return the index of a joint given by its name.
pinocchio::ModelTpl::Vector3
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
Definition: multibody/model.hpp:82
pinocchio::ModelTpl::Index
pinocchio::Index Index
Definition: multibody/model.hpp:67
pinocchio::OP_FRAME
@ OP_FRAME
operational frame: user-defined frames that are defined at runtime
Definition: multibody/frame.hpp:33
append-urdf-model-with-another-model.joint_name
string joint_name
Definition: append-urdf-model-with-another-model.py:33
append-urdf-model-with-another-model.joint_placement
joint_placement
Definition: append-urdf-model-with-another-model.py:29
pinocchio::ModelTpl::damping
TangentVectorType damping
Vector of joint damping parameters.
Definition: multibody/model.hpp:162
pinocchio::ModelTpl::nv
int nv
Dimension of the velocity vector space.
Definition: multibody/model.hpp:102
pinocchio::ModelTpl::getBodyId
FrameIndex getBodyId(const std::string &name) const
Return the index of a body given by its name.
pinocchio::ModelTpl::ConfigVectorMap
std::map< std::string, ConfigVectorType > ConfigVectorMap
Map between a string (key) and a configuration vector.
Definition: multibody/model.hpp:91
pinocchio::SE3Tpl< Scalar, Options >::Identity
static SE3Tpl Identity()
Definition: spatial/se3-tpl.hpp:136
pinocchio::FIXED_JOINT
@ FIXED_JOINT
fixed joint frame: joint frame but for a fixed joint
Definition: multibody/frame.hpp:35
frame.hpp
pinocchio::ModelTpl::supports
std::vector< IndexVector > supports
Vector of joint supports. supports[j] corresponds to the vector of indices of the joints located on t...
Definition: multibody/model.hpp:184
pinocchio::ModelTpl::check
bool check() const
Run check(fusion::list) with DEFAULT_CHECKERS as argument.
Definition: default-check.hpp:23
pinocchio::ModelTpl::addFrame
FrameIndex addFrame(const Frame &frame, const bool append_inertia=true)
Adds a frame to the kinematic tree. The inertia stored within the frame will be happened to the inert...
pinocchio::JointIndex
Index JointIndex
Definition: multibody/fwd.hpp:26
pinocchio::ModelTpl::effortLimit
TangentVectorType effortLimit
Vector of maximal joint torques.
Definition: multibody/model.hpp:165
pinocchio::ModelTpl::parents
std::vector< JointIndex > parents
Vector of parent joint indexes. The parent of joint i, denoted li, corresponds to li==parents[i].
Definition: multibody/model.hpp:136
pinocchio::traits
Common traits structure to fully define base classes for CRTP.
Definition: fwd.hpp:71
pinocchio::ModelTpl::Options
@ Options
Definition: multibody/model.hpp:55
pinocchio::ModelTpl::Frame
FrameTpl< Scalar, Options > Frame
Definition: multibody/model.hpp:65
append-urdf-model-with-another-model.body_placement
body_placement
Definition: append-urdf-model-with-another-model.py:39
pinocchio::traits< ModelTpl< _Scalar, _Options, JointCollectionTpl > >::Scalar
_Scalar Scalar
Definition: multibody/model.hpp:42
pinocchio::ModelTpl::ConfigVectorType
VectorXs ConfigVectorType
Dense vectorized version of a joint configuration vector.
Definition: multibody/model.hpp:88
pinocchio::ModelTpl::idx_vs
std::vector< int > idx_vs
Starting index of the *i*th joint in the tangent configuration space.
Definition: multibody/model.hpp:129
pinocchio::MotionTpl< Scalar, Options >
append-urdf-model-with-another-model.joint_id
joint_id
Definition: append-urdf-model-with-another-model.py:34
pinocchio::CastType
Type of the cast of a class C templated by Scalar and Options, to a new NewScalar type....
Definition: fwd.hpp:99
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio::ModelTpl::ModelTpl
ModelTpl(const ModelTpl< S2, O2 > &other)
Copy constructor by casting.
Definition: multibody/model.hpp:234
pinocchio::ModelTpl::upperPositionLimit
ConfigVectorType upperPositionLimit
Upper joint configuration limit.
Definition: multibody/model.hpp:174
force.hpp
pinocchio::BODY
@ BODY
body frame: attached to the collision, inertial or visual properties of a link
Definition: multibody/frame.hpp:36
pinocchio::GeomIndex
Index GeomIndex
Definition: multibody/fwd.hpp:27
fwd.hpp
pinocchio::ModelTpl::nq
int nq
Dimension of the configuration vector representation.
Definition: multibody/model.hpp:99
pinocchio::serialization::Serializable
Definition: serialization/serializable.hpp:16
pinocchio::ModelTpl::JointCollection
JointCollectionTpl< Scalar, Options > JointCollection
Definition: multibody/model.hpp:58
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
pinocchio::ModelTpl::njoints
int njoints
Number of joints.
Definition: multibody/model.hpp:105
pinocchio::ModelTpl::JointModel
JointModelTpl< Scalar, Options, JointCollectionTpl > JointModel
Definition: multibody/model.hpp:73


pinocchio
Author(s):
autogenerated on Sun Jun 16 2024 02:43:12