|
pinocchio
2.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
|
|
6 #ifndef __pinocchio_multibody_model_hpp__
7 #define __pinocchio_multibody_model_hpp__
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"
15 #include "pinocchio/multibody/fwd.hpp"
16 #include "pinocchio/multibody/frame.hpp"
17 #include "pinocchio/multibody/joint/joint-generic.hpp"
19 #include "pinocchio/container/aligned-vector.hpp"
21 #include "pinocchio/serialization/serializable.hpp"
30 template<
typename _Scalar,
int _Options,
template<
typename,
int>
class JointCollectionTpl>
32 : serialization::Serializable< ModelTpl<_Scalar,_Options,JointCollectionTpl> >
34 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
36 typedef _Scalar Scalar;
37 enum { Options = _Options };
39 typedef JointCollectionTpl<Scalar,Options> JointCollection;
40 typedef DataTpl<Scalar,Options,JointCollectionTpl> Data;
42 typedef SE3Tpl<Scalar,Options> SE3;
43 typedef MotionTpl<Scalar,Options> Motion;
44 typedef ForceTpl<Scalar,Options> Force;
45 typedef InertiaTpl<Scalar,Options> Inertia;
46 typedef FrameTpl<Scalar,Options> Frame;
48 typedef pinocchio::Index Index;
49 typedef pinocchio::JointIndex JointIndex;
50 typedef pinocchio::GeomIndex GeomIndex;
51 typedef pinocchio::FrameIndex FrameIndex;
52 typedef std::vector<Index> IndexVector;
54 typedef JointModelTpl<Scalar,Options,JointCollectionTpl> JointModel;
55 typedef JointDataTpl<Scalar,Options,JointCollectionTpl> JointData;
57 typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointModel) JointModelVector;
58 typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointData) JointDataVector;
60 typedef PINOCCHIO_ALIGNED_STD_VECTOR(Frame) FrameVector;
62 typedef Eigen::Matrix<Scalar,Eigen::Dynamic,1,Options> VectorXs;
63 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
91 PINOCCHIO_ALIGNED_STD_VECTOR(
Inertia) inertias;
94 PINOCCHIO_ALIGNED_STD_VECTOR(
SE3) jointPlacements;
174 , jointPlacements(1,
SE3::Identity())
186 names[0] =
"universe";
195 template<
typename NewScalar>
208 res.gravity =
gravity.template cast<NewScalar>();
217 res.rotorInertia =
rotorInertia.template cast<NewScalar>();
219 res.friction =
friction.template cast<NewScalar>();
220 res.damping =
damping.template cast<NewScalar>();
221 res.effortLimit =
effortLimit.template cast<NewScalar>();
222 res.velocityLimit =
velocityLimit.template cast<NewScalar>();
226 typename ConfigVectorMap::const_iterator it;
230 res.referenceConfigurations.insert(std::make_pair(it->first, it->second.template cast<NewScalar>()));
234 res.inertias.resize(inertias.size());
235 res.jointPlacements.resize(jointPlacements.size());
236 res.joints.resize(
joints.size());
237 res.frames.resize(
frames.size());
240 for(
size_t k = 0; k <
joints.size(); ++k)
242 res.inertias[k] = inertias[k].template cast<NewScalar>();
243 res.jointPlacements[k] = jointPlacements[k].template cast<NewScalar>();
244 res.joints[k] =
joints[k].template cast<NewScalar>();
247 for(
size_t k = 0; k <
frames.size(); ++k)
249 res.frames[k] =
frames[k].template cast<NewScalar>();
269 && other.names ==
names
272 && other.name ==
name;
284 typename ConfigVectorMap::const_iterator it_other = other.referenceConfigurations.begin();
287 std::advance(it,k); std::advance(it_other,k);
289 if(it->second.size() != it_other->second.size())
291 if(it->second != it_other->second)
300 if(other.friction.size() !=
friction.size())
305 if(other.damping.size() !=
damping.size())
307 res &= other.damping ==
damping;
335 for(
size_t k = 1; k < inertias.size(); ++k)
337 res &= other.inertias[k] == inertias[k];
341 for(
size_t k = 1; k < other.jointPlacements.size(); ++k)
343 res &= other.jointPlacements[k] == jointPlacements[k];
349 && other.frames ==
frames;
358 {
return !(*
this == other); }
378 JointIndex
addJoint(
const JointIndex parent,
380 const SE3 & joint_placement,
381 const std::string & joint_name);
391 JointIndex
addJoint(
const JointIndex parent,
393 const SE3 & joint_placement,
394 const std::string & joint_name,
395 const VectorXs & max_effort,
396 const VectorXs & max_velocity,
397 const VectorXs & min_config,
398 const VectorXs & max_config);
406 JointIndex
addJoint(
const JointIndex parent,
408 const SE3 & joint_placement,
409 const std::string & joint_name,
410 const VectorXs & max_effort,
411 const VectorXs & max_velocity,
412 const VectorXs & min_config,
413 const VectorXs & max_config,
427 int previous_frame_index = -1);
439 const SE3 & body_placement = SE3::Identity());
453 const JointIndex & parentJoint,
454 const SE3 & body_placement = SE3::Identity(),
455 int previousFrame = -1);
538 const bool append_inertia =
true);
552 {
return checker.checkModel(*
this); }
569 inline bool check()
const;
578 inline bool check(
const Data & data)
const;
595 #include "pinocchio/multibody/model.hxx"
597 #endif // ifndef __pinocchio_multibody_model_hpp__
std::vector< int > idx_qs
Starting index of the joint i in the configuration space.
TangentVectorType damping
Vector of joint damping parameters.
int nq
Dimension of the configuration vector representation.
ConfigVectorMap referenceConfigurations
Map of reference configurations, indexed by user given names.
@ JOINT
joint frame: attached to the child body of a joint (a.k.a. child frame)
CRTP class describing the API of the checkers.
int nv
Dimension of the velocity vector space.
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.
JointIndex getJointId(const std::string &name) const
Return the index of a joint given by its name.
std::vector< bool > hasConfigurationLimitInTangent()
Check if joints have configuration limits.
ModelTpl()
Default constructor. Builds an empty model with no joints.
JointModelVector joints
Model of joint i, encapsulated in a JointModelAccessor.
int njoints
Number of joints.
FrameIndex getBodyId(const std::string &name) const
Return the index of a body given by its name.
@ FIXED_JOINT
fixed joint frame: joint frame but for a fixed joint
VectorXs ConfigVectorType
Dense vectorized version of a joint configuration vector.
bool check() const
Run check(fusion::list) with DEFAULT_CHECKERS as argument.
@ BODY
body frame: attached to the collision, inertial or visual properties of a link
bool existBodyName(const std::string &name) const
Check if a body given by its name exists.
Motion gravity
Spatial gravity of the model.
bool operator==(const ModelTpl &other) const
Equality comparison operator.
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.
@ SENSOR
sensor frame: defined in a sensor element
int nframes
Number of operational frames.
A Plucker coordinate frame attached to a parent joint inside a kinematic tree.
std::vector< IndexVector > subtrees
Vector of joint subtrees. subtree[j] corresponds to the subtree supported by the joint j....
@ OP_FRAME
operational frame: user-defined frames that are defined at runtime
std::vector< IndexVector > supports
Vector of joint supports. supports[j] corresponds to the collection of all joints located on the path...
std::vector< int > nqs
Dimension of the joint i configuration subspace.
std::vector< bool > hasConfigurationLimit()
Check if joints have configuration limits.
std::vector< std::string > names
Name of joint i
ConfigVectorType upperPositionLimit
Upper joint configuration limit.
FrameVector frames
Vector of operational frames registered on the model.
bool operator!=(const ModelTpl &other) const
TangentVectorType effortLimit
Vector of maximal joint torques.
FrameIndex addBodyFrame(const std::string &body_name, const JointIndex &parentJoint, const SE3 &body_placement=SE3::Identity(), int previousFrame=-1)
Add a body to the frame tree.
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...
TangentVectorType friction
Vector of joint friction parameters.
void addJointIndexToParentSubtrees(const JointIndex joint_id)
Add the joint_id to its parent subtrees.
ModelTpl< NewScalar, Options, JointCollectionTpl > cast() const
FrameIndex addJointFrame(const JointIndex &joint_index, int previous_frame_index=-1)
Add a joint to the frame tree.
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.
ConfigVectorType lowerPositionLimit
Lower joint configuration limit.
std::vector< JointIndex > parents
Joint parent of joint i, denoted li (li==parents[i]).
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.
std::string name
Model name;.
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.
TangentVectorType velocityLimit
Vector of maximal joint velocities.
std::map< std::string, ConfigVectorType > ConfigVectorMap
Map between a string (key) and a configuration vector.
TangentVectorType rotorGearRatio
Vector of rotor gear ratio parameters.
VectorXs TangentVectorType
Dense vectorized version of a joint tangent vector (e.g. velocity, acceleration, etc)....
std::vector< int > idx_vs
Starting index of the joint i in the tangent configuration space.
static const Vector3 gravity981
Default 3D gravity vector (=(0,0,-9.81)).
bool existJointName(const std::string &name) const
Check if a joint given by its name exists.
int nbodies
Number of bodies.
TangentVectorType rotorInertia
Vector of rotor inertia parameters.
std::vector< int > nvs
Dimension of the joint i tangent subspace.
FrameType
Enum on the possible types of frames.
Main pinocchio namespace.