Biorbd Release_1.13.0
Loading...
Searching...
No Matches
Segment.h
1#ifndef BIORBD_RIGIDBODY_SEGMENT_H
2#define BIORBD_RIGIDBODY_SEGMENT_H
3
4#include "biorbdConfig.h"
5
6#include <vector>
7
8#include <rbdl/Model.h>
9
10#include <rbdl/Joint.h>
11
12#include "Utils/Node.h"
13#include "Utils/Scalar.h"
14
15namespace BIORBD_NAMESPACE {
16namespace utils {
17class RotoTrans;
18class Range;
20} // namespace utils
21
22namespace rigidbody {
23class Joints;
25
29class BIORBD_API Segment : public utils::Node {
30 public:
34 Segment();
35
56 Segment(
57 rigidbody::Joints &model,
58 const utils::String &name,
59 const utils::String &parentName,
60 const utils::String &seqT,
61 const utils::String &seqR,
62 const std::vector<utils::Range> &QRanges,
63 const std::vector<utils::Range> &QdotRanges,
64 const std::vector<utils::Range> &QddotRanges,
65 const std::vector<utils::Scalar> &jointDamping,
67 const utils::SpatialTransform &cor);
68
88 Segment(
89 rigidbody::Joints &model,
90 const utils::String &name,
91 const utils::String &parentName,
92 const utils::String &seqR,
93 const std::vector<utils::Range> &QRanges,
94 const std::vector<utils::Range> &QdotRanges,
95 const std::vector<utils::Range> &QddotRanges,
96 const std::vector<utils::Scalar> &jointDamping,
98 const utils::SpatialTransform &cor);
99
104 Segment DeepCopy() const;
105
110 void DeepCopy(const Segment &other);
111
115 virtual ~Segment();
116
121 size_t id() const;
122
127 const utils::String &seqT() const;
128
133 const utils::String &seqR() const;
134
141 const std::vector<utils::Range> &QRanges() const;
142
149 void setQRanges(const std::vector<utils::Range> &QRanges);
150
157 const std::vector<utils::Range> &QdotRanges() const;
158
165 void setQdotRanges(const std::vector<utils::Range> &QdotRanges);
166
173 const std::vector<utils::Range> &QddotRanges() const;
174
181 void setQddotRanges(const std::vector<utils::Range> &QddotRanges);
182
186 const std::vector<utils::Scalar> &jointDampings() const;
187
192 void setJointDampings(const std::vector<utils::Scalar> &jointDampings);
193
198 size_t nbDof() const;
199
204 size_t nbDofTrans() const;
205
210 size_t nbDofRot() const;
211
216 size_t nbQ() const;
217
222 size_t nbQdot() const;
223
228 size_t nbQddot() const;
229
236 size_t nbGeneralizedTorque() const;
237
243 size_t getDofIdx(const utils::String &dofName) const;
244
252 const rigidbody::Joints &model) const;
253
263 const rigidbody::Joints &model) const;
264
274 const rigidbody::Joints &model) const;
275
281 const utils::String &nameDof(const size_t i) const;
282
289
298 void setLocalJCS(rigidbody::Joints &model, utils::RotoTrans &rototrans);
299
316 rigidbody::Joints &model,
318
324
330
335 bool isRotationAQuaternion() const;
336
337 protected:
338 std::shared_ptr<int> m_idxInModel;
339
343 void setType();
344
345 std::shared_ptr<utils::SpatialTransform>
347
363 void setDofs(
364 rigidbody::Joints &model,
365 const utils::String &seqT,
366 const utils::String &seqR,
367 const std::vector<utils::Range> &QRanges,
368 const std::vector<utils::Range> &QdotRanges,
369 const std::vector<utils::Range> &QddotRanges,
370 const std::vector<utils::Scalar> &jointDamping);
371
379 template <typename T>
380 bool isVectorHasDofDimension(const std::vector<T> &vec, bool isQLevel) const;
381
387 void setNumberOfDof(size_t nbTrans, size_t nbRot);
388
389 std::shared_ptr<utils::String> m_seqT;
390 std::shared_ptr<utils::String> m_seqR;
391 std::shared_ptr<size_t> m_nbDof;
392 std::shared_ptr<size_t> m_nbQdot;
393 std::shared_ptr<size_t> m_nbQddot;
394 std::shared_ptr<size_t>
397 std::shared_ptr<size_t>
400 std::shared_ptr<size_t>
402 std::shared_ptr<size_t>
404 std::shared_ptr<size_t> m_nbDofQuat;
406
407 std::shared_ptr<std::vector<utils::Range>>
411 std::shared_ptr<std::vector<utils::Range>>
415 std::shared_ptr<std::vector<utils::Range>>
419
420 std::shared_ptr<std::vector<utils::Scalar>>
422
423 std::shared_ptr<bool> m_isQuaternion;
424
432
433 std::shared_ptr<std::vector<RigidBodyDynamics::Joint>>
436 std::shared_ptr<std::vector<size_t>>
438
445 void setSequence(const utils::String &seqT, const utils::String &seqR);
446
453 void fillSequence();
454
462 void str2numSequence(
463 std::vector<size_t> &sequenceInteger,
464 const utils::String &sequenceText);
465
472
473 std::shared_ptr<std::vector<size_t>>
475 std::shared_ptr<std::vector<size_t>>
477 std::shared_ptr<std::vector<utils::String>>
479
484 virtual void setJoints(rigidbody::Joints &model);
485
489 virtual void setJointAxis();
490
491 std::shared_ptr<std::vector<size_t>>
493
501
502 std::shared_ptr<SegmentCharacteristics>
506 std::shared_ptr<std::vector<SegmentCharacteristics>>
510};
511
512} // namespace rigidbody
513} // namespace BIORBD_NAMESPACE
514
515#endif // BIORBD_RIGIDBODY_SEGMENT_H
This is the core of the musculoskeletal model in biorbd.
Definition Joints.h:48
Characteristics of a segment, namely the mass, the center of mass, the inertia, the length and its me...
Description of a segment.
Definition Segment.h:29
std::shared_ptr< std::vector< utils::String > > m_nameDof
To store the DoF names.
Definition Segment.h:478
std::shared_ptr< std::vector< RigidBodyDynamics::Joint > > m_dof
Definition Segment.h:434
bool isRotationAQuaternion() const
Return if the rotation DoF of this segment is a quaternion.
Definition Segment.cpp:188
SegmentCharacteristics & characteristics()
Return the segment characteristics.
Definition Segment.cpp:304
const std::vector< utils::Range > & QRanges() const
Return the ranges for all the dof, translations and rotations respectively.
Definition Segment.cpp:222
utils::RotoTrans localJCS() const
Return the joint coordinate system (JCS) in the parent reference frame.
Definition Segment.cpp:276
std::shared_ptr< bool > m_isQuaternion
If DoF in rotation is a Quaternion.
Definition Segment.h:423
const utils::String & seqT() const
Return the translation sequence in text.
Definition Segment.cpp:218
size_t getDofIdx(const utils::String &dofName) const
Return the index of a specified DoF.
Definition Segment.cpp:547
std::shared_ptr< utils::SpatialTransform > m_cor
Attitude of the segment in parent reference frame.
Definition Segment.h:346
void str2numSequence(std::vector< size_t > &sequenceInteger, const utils::String &sequenceText)
Convert a text sequence to its number counterpart (x = 0, y = 1, z = 2, q = 3).
Definition Segment.cpp:385
std::shared_ptr< utils::String > m_seqT
Translation sequence.
Definition Segment.h:389
std::shared_ptr< std::vector< SegmentCharacteristics > > m_dofCharacteristics
Definition Segment.h:507
Segment DeepCopy() const
Create a deep copy of Segment.
Definition Segment.cpp:142
std::shared_ptr< std::vector< utils::Range > > m_QdotRanges
Definition Segment.h:412
std::shared_ptr< int > m_idxInModel
Index in RBDL model.
Definition Segment.h:338
std::shared_ptr< std::vector< size_t > > m_sequenceTrans
Translation sequence.
Definition Segment.h:474
void determineIfRotIsQuaternion(const utils::String &seqR)
Determines if DoF in rotation is a Quaternion.
Definition Segment.cpp:348
size_t getLastDofIndexInGeneralizedCoordinates(const rigidbody::Joints &model) const
Returns the last index of the segment in the Generalized Coordinates vector.
Definition Segment.cpp:599
void fillSequence()
Fill the transation and rotation sequences.
Definition Segment.cpp:433
virtual void setJointAxis()
Determine the rotation axis in relation to the requested sequence.
Definition Segment.cpp:467
const rigidbody::Segment & findFirstSegmentWithDof(const rigidbody::Joints &model) const
Traverse the model hierarchy until it gets to a segment with a dof. If the current segment has at lea...
Definition Segment.cpp:568
const utils::String & nameDof(const size_t i) const
Return the name of the specified DoF.
Definition Segment.cpp:212
size_t nbGeneralizedTorque() const
Return the number of generalized torque.
Definition Segment.cpp:204
void setDofs(rigidbody::Joints &model, const utils::String &seqT, const utils::String &seqR, const std::vector< utils::Range > &QRanges, const std::vector< utils::Range > &QdotRanges, const std::vector< utils::Range > &QddotRanges, const std::vector< utils::Scalar > &jointDamping)
Set the DoF.
Definition Segment.cpp:313
size_t nbDofTrans() const
Return the number of translation DoF of the segment.
Definition Segment.cpp:206
size_t nbQddot() const
Return the number of generalized accelerations.
Definition Segment.cpp:210
void setDofCharacteristicsOnLastBody()
Set the DoF segment characteristics on the last body.
Definition Segment.cpp:451
std::shared_ptr< size_t > m_nbDofTrueOutside
Definition Segment.h:398
std::shared_ptr< std::vector< utils::Range > > m_QddotRanges
Definition Segment.h:416
const std::vector< utils::Range > & QdotRanges() const
Return the ranges for all the dof velocity, translations and rotations respectively.
Definition Segment.cpp:233
const utils::String & seqR() const
Return the angle sequence in text.
Definition Segment.cpp:220
const std::vector< utils::Scalar > & jointDampings() const
Return the joint damping to apply to the dynamics.
Definition Segment.cpp:257
void setQRanges(const std::vector< utils::Range > &QRanges)
Set the ranges for all the dof, translations and rotations respectively.
Definition Segment.cpp:226
bool isVectorHasDofDimension(const std::vector< T > &vec, bool isQLevel) const
Check if the vector has the same number of elements as the number of DoF.
Definition Segment.cpp:340
std::shared_ptr< std::vector< utils::Range > > m_QRanges
Definition Segment.h:408
size_t nbQ() const
Return the number of generalized coordinates.
Definition Segment.cpp:208
std::shared_ptr< size_t > m_nbQddot
Number of generalized accelerations.
Definition Segment.h:393
size_t getFirstDofIndexInGeneralizedCoordinates(const rigidbody::Joints &model) const
Returns the first index of the segment in the Generalized Coordinates vector.
Definition Segment.cpp:581
size_t nbDofRot() const
Return the number of rotation DoF of the segment.
Definition Segment.cpp:207
void setLocalJCS(rigidbody::Joints &model, utils::RotoTrans &rototrans)
set the joint coordinate system (JCS) in the parent reference frame
Definition Segment.cpp:281
std::shared_ptr< size_t > m_nbDofQuat
Definition Segment.h:404
void setType()
Set the type of the segment.
Definition Segment.cpp:192
void setQddotRanges(const std::vector< utils::Range > &QddotRanges)
Set the ranges for all the dof acceleration, translations and rotations respectively.
Definition Segment.cpp:249
std::shared_ptr< std::vector< utils::Scalar > > m_jointDampings
The joint dampings to apply to the dynamics.
Definition Segment.h:421
virtual void setJoints(rigidbody::Joints &model)
Function that adds the segment to the RBDL body set.
Definition Segment.cpp:499
size_t id() const
Return the Segment index.
Definition Segment.cpp:196
std::shared_ptr< SegmentCharacteristics > m_characteristics
Definition Segment.h:503
const std::vector< utils::Range > & QddotRanges() const
Return the ranges for all the dof acceleration, translations and rotations respectively.
Definition Segment.cpp:245
size_t nbQdot() const
Return the number of generalized velocities.
Definition Segment.cpp:209
std::shared_ptr< std::vector< size_t > > m_sequenceRot
Euler rotation sequence.
Definition Segment.h:476
size_t nbDof() const
Return the number of DoF of the segment.
Definition Segment.cpp:205
void updateCharacteristics(rigidbody::Joints &model, const SegmentCharacteristics &characteristics)
updateCharacteristics Change the inertia characteristics of the segment
Definition Segment.cpp:290
void setNumberOfDof(size_t nbTrans, size_t nbRot)
Set the total number of DoF.
Definition Segment.cpp:403
std::shared_ptr< size_t > m_nbDofTrue
Definition Segment.h:395
void setJointDampings(const std::vector< utils::Scalar > &jointDampings)
Set the joint damping to apply to the dynamics.
Definition Segment.cpp:261
std::shared_ptr< size_t > m_nbDofRot
Number of degrees of freedom in rotation.
Definition Segment.h:403
void setSequence(const utils::String &seqT, const utils::String &seqR)
Set angle and translation sequences, adjust angle sequence and redeclare if is necessary.
Definition Segment.cpp:424
std::shared_ptr< std::vector< size_t > > m_dofPosition
Position in the x, y, and z sequence.
Definition Segment.h:492
std::shared_ptr< size_t > m_nbDofTrans
Number of degrees of freedom in translation.
Definition Segment.h:401
std::shared_ptr< size_t > m_nbQdot
Number of generalized velocities.
Definition Segment.h:392
Segment()
Construct a Segment.
Definition Segment.cpp:20
std::shared_ptr< size_t > m_nbDof
Number of degrees of freedom.
Definition Segment.h:391
std::shared_ptr< std::vector< size_t > > m_idxDof
Index of the parent segment.
Definition Segment.h:437
void setQdotRanges(const std::vector< utils::Range > &QdotRanges)
Set the ranges for all the dof velocity, translations and rotations respectively.
Definition Segment.cpp:237
std::shared_ptr< utils::String > m_seqR
Euler rotation sequence.
Definition Segment.h:390
A node is an abstract element which is assigned to a parent.
Definition Node.h:17
const String & name() const
Return the name of the node.
Definition Node.cpp:43
Homogenous matrix to describe translations and rotations simultaneously.
Definition RotoTrans.h:33
Wrapper of the SpatialTransform (rotation and translation).
Wrapper around the std::string class with augmented functionality.
Definition String.h:18