Biorbd
Segment.cpp
1 #define BIORBD_API_EXPORTS
2 #include "RigidBody/Segment.h"
3 
4 #include <limits.h>
5 #include "Utils/String.h"
6 #include "Utils/Error.h"
7 #include "Utils/Vector3d.h"
8 #include "Utils/RotoTrans.h"
9 #include "RigidBody/Joints.h"
10 #include "RigidBody/Mesh.h"
11 #include "RigidBody/SegmentCharacteristics.h"
12 #include "Utils/Range.h"
13 
15  biorbd::utils::Node(),
16  m_idxPF (std::make_shared<int>(-1)),
17  m_cor(std::make_shared<RigidBodyDynamics::Math::SpatialTransform>()),
18  m_seqT(std::make_shared<biorbd::utils::String>()),
19  m_seqR(std::make_shared<biorbd::utils::String>()),
20  m_QRanges(std::make_shared<std::vector<biorbd::utils::Range>>()),
21  m_QDotRanges(std::make_shared<std::vector<biorbd::utils::Range>>()),
22  m_QDDotRanges(std::make_shared<std::vector<biorbd::utils::Range>>()),
23  m_nbDof(std::make_shared<unsigned int>(0)),
24  m_nbQdot(std::make_shared<unsigned int>(0)),
25  m_nbQddot(std::make_shared<unsigned int>(0)),
26  m_nbDofTrue(std::make_shared<unsigned int>(0)),
27  m_nbDofTrueOutside(std::make_shared<unsigned int>(0)),
28  m_nbDofTrans(std::make_shared<unsigned int>(0)),
29  m_nbDofRot(std::make_shared<unsigned int>(0)),
30  m_nbDofQuat(std::make_shared<unsigned int>(0)),
31  m_isQuaternion(std::make_shared<bool>(false)),
32  m_dof(std::make_shared<std::vector<RigidBodyDynamics::Joint>>()),
33  m_idxDof(std::make_shared<std::vector<unsigned int>>()),
34  m_sequenceTrans(std::make_shared<std::vector<unsigned int>>()),
35  m_sequenceRot(std::make_shared<std::vector<unsigned int>>()),
36  m_nameDof(std::make_shared<std::vector<biorbd::utils::String>>()),
37  m_dofPosition(std::make_shared<std::vector<unsigned int>>()),
38  m_characteristics(std::make_shared<biorbd::rigidbody::SegmentCharacteristics>()),
39  m_dofCharacteristics(std::make_shared<std::vector<biorbd::rigidbody::SegmentCharacteristics>>())
40 {
41  setType();
42 }
43 
46  const biorbd::utils::String &name,
47  const biorbd::utils::String &parentName,
48  const biorbd::utils::String &seqT,
49  const biorbd::utils::String &seqR,
50  const std::vector<biorbd::utils::Range>& QRanges,
51  const std::vector<biorbd::utils::Range>& QDotRanges,
52  const std::vector<biorbd::utils::Range>& QDDotRanges,
53  const biorbd::rigidbody::SegmentCharacteristics& characteristics,
54  const RigidBodyDynamics::Math::SpatialTransform& cor,
55  int PF) :
56 
57  biorbd::utils::Node(name, parentName),
58  m_idxPF (std::make_shared<int>(PF)),
59  m_cor(std::make_shared<RigidBodyDynamics::Math::SpatialTransform>(cor)),
60  m_seqT(std::make_shared<biorbd::utils::String>(seqT)),
61  m_seqR(std::make_shared<biorbd::utils::String>(seqR)),
62  m_QRanges(std::make_shared<std::vector<biorbd::utils::Range>>()),
63  m_QDotRanges(std::make_shared<std::vector<biorbd::utils::Range>>()),
64  m_QDDotRanges(std::make_shared<std::vector<biorbd::utils::Range>>()),
65  m_nbDof(std::make_shared<unsigned int>(0)),
66  m_nbQdot(std::make_shared<unsigned int>(0)),
67  m_nbQddot(std::make_shared<unsigned int>(0)),
68  m_nbDofTrue(std::make_shared<unsigned int>(0)),
69  m_nbDofTrueOutside(std::make_shared<unsigned int>(0)),
70  m_nbDofTrans(std::make_shared<unsigned int>(0)),
71  m_nbDofRot(std::make_shared<unsigned int>(0)),
72  m_nbDofQuat(std::make_shared<unsigned int>(0)),
73  m_isQuaternion(std::make_shared<bool>(false)),
74  m_dof(std::make_shared<std::vector<RigidBodyDynamics::Joint>>()),
75  m_idxDof(std::make_shared<std::vector<unsigned int>>()),
76  m_sequenceTrans(std::make_shared<std::vector<unsigned int>>()),
77  m_sequenceRot(std::make_shared<std::vector<unsigned int>>()),
78  m_nameDof(std::make_shared<std::vector<biorbd::utils::String>>()),
79  m_dofPosition(std::make_shared<std::vector<unsigned int>>()),
80  m_characteristics(std::make_shared<biorbd::rigidbody::SegmentCharacteristics>(characteristics)),
81  m_dofCharacteristics(std::make_shared<std::vector<biorbd::rigidbody::SegmentCharacteristics>>())
82 {
83  setType();
84  // Call proper functions
86  // Add platform
87  setPF(PF);
88 }
91  const biorbd::utils::String &name, // Name of segment
92  const biorbd::utils::String &parentName, // Name of segment
93  const biorbd::utils::String &seqR, // Cardan sequence to classify the rotation DoF
94  const std::vector<biorbd::utils::Range>& QRanges,
95  const std::vector<biorbd::utils::Range>& QDotRanges,
96  const std::vector<biorbd::utils::Range>& QDDotRanges,
97  const biorbd::rigidbody::SegmentCharacteristics& characteristics, // Mass, Center of mass of segment, Inertia of segment, etc.
98  const RigidBodyDynamics::Math::SpatialTransform& cor, // Transformation from parent to child
99  int PF): // Force platform number
100 
101 
102  biorbd::utils::Node(name, parentName),
103  m_idxPF (std::make_shared<int>(PF)),
104  m_cor(std::make_shared<RigidBodyDynamics::Math::SpatialTransform>(cor)),
105  m_seqT(std::make_shared<biorbd::utils::String>()),
106  m_seqR(std::make_shared<biorbd::utils::String>(seqR)),
107  m_QRanges(std::make_shared<std::vector<biorbd::utils::Range>>()),
108  m_QDotRanges(std::make_shared<std::vector<biorbd::utils::Range>>()),
109  m_QDDotRanges(std::make_shared<std::vector<biorbd::utils::Range>>()),
110  m_nbDof(std::make_shared<unsigned int>(0)),
111  m_nbQdot(std::make_shared<unsigned int>(0)),
112  m_nbQddot(std::make_shared<unsigned int>(0)),
113  m_nbDofTrue(std::make_shared<unsigned int>(0)),
114  m_nbDofTrueOutside(std::make_shared<unsigned int>(0)),
115  m_nbDofTrans(std::make_shared<unsigned int>(0)),
116  m_nbDofRot(std::make_shared<unsigned int>(0)),
117  m_nbDofQuat(std::make_shared<unsigned int>(0)),
118  m_isQuaternion(std::make_shared<bool>(false)),
119  m_dof(std::make_shared<std::vector<RigidBodyDynamics::Joint>>()),
120  m_idxDof(std::make_shared<std::vector<unsigned int>>()),
121  m_sequenceTrans(std::make_shared<std::vector<unsigned int>>()),
122  m_sequenceRot(std::make_shared<std::vector<unsigned int>>()),
123  m_nameDof(std::make_shared<std::vector<biorbd::utils::String>>()),
124  m_dofPosition(std::make_shared<std::vector<unsigned int>>()),
125  m_characteristics(std::make_shared<biorbd::rigidbody::SegmentCharacteristics>(characteristics)),
126  m_dofCharacteristics(std::make_shared<std::vector<biorbd::rigidbody::SegmentCharacteristics>>())
127 {
128  setType();
129  // Call proper functions
130  setDofs(model, "", seqR, QRanges, QDotRanges, QDDotRanges);
131  // Add platform
132  setPF(PF);
133 }
134 
136 {
138  copy.DeepCopy(*this);
139  return copy;
140 }
141 
143 {
145  *m_idxPF = *other.m_idxPF;
146  *m_cor = *other.m_cor;
147  *m_seqT = *other.m_seqT;
148  *m_seqR = *other.m_seqR;
149  *m_QRanges = *other.m_QRanges;
150  *m_QDotRanges = *other.m_QDotRanges;
151  *m_QDDotRanges = *other.m_QDDotRanges;
152  *m_nbDof = *other.m_nbDof;
153  *m_nbQdot = *other.m_nbQdot;
154  *m_nbQddot = *other.m_nbQddot;
155  *m_nbDofTrue = *other.m_nbDofTrue;
156  *m_nbDofTrueOutside = *other.m_nbDofTrueOutside;
157  *m_nbDofTrans = *other.m_nbDofTrans;
158  *m_nbDofRot = *other.m_nbDofRot;
159  *m_nbDofQuat = *other.m_nbDofQuat;
160  *m_isQuaternion = *other.m_isQuaternion;
161  m_dof->resize(other.m_dof->size());
162  for (unsigned int i=0; i<other.m_dof->size(); ++i)
163  (*m_dof)[i] = (*other.m_dof)[i];
164  *m_idxDof = *other.m_idxDof;
165  *m_sequenceTrans = *other.m_sequenceTrans;
166  *m_sequenceRot = *other.m_sequenceRot;
167  m_nameDof->resize(other.m_nameDof->size());
168  for (unsigned int i=0; i<other.m_nameDof->size(); ++i)
169  (*m_nameDof)[i] = (*other.m_nameDof)[i];
170  *m_dofPosition = *other.m_dofPosition;
171  *m_characteristics = other.m_characteristics->DeepCopy();
172  m_dofCharacteristics->resize(other.m_dofCharacteristics->size());
173  for (unsigned int i=0; i<other.m_dofCharacteristics->size(); ++i)
174  (*m_dofCharacteristics)[i] = (*other.m_dofCharacteristics)[i].DeepCopy();
175 }
176 
178 
179 }
180 
182  return *m_isQuaternion;
183 }
184 
186 {
187  *m_typeOfNode = biorbd::utils::NODE_TYPE::SEGMENT;
188 }
189 
190 unsigned int biorbd::rigidbody::Segment::id() const{
191  if (*m_nbDof!=0)
192  return (*m_idxDof)[*m_nbDof-1];
193  else
194  return (*m_idxDof)[*m_nbDof];
195 }
196 
198  return *m_idxPF;
199 }
201  return nbQddot();
202 }
204  return *m_nbDofTrueOutside;
205 }
207  return *m_nbDofTrans;
208 }
210  return *m_nbDofRot;
211 }
212 unsigned int biorbd::rigidbody::Segment::nbQ() const{
213  return *m_nbDofTrue;
214 }
216  return *m_nbQdot;
217 }
219  return *m_nbQddot;
220 }
221 
222 // Add platform
224  *m_idxPF = idx;
225 }
226 
227 const biorbd::utils::String &biorbd::rigidbody::Segment::nameDof(const unsigned int i) const {
228  // Return the number of DoF of the segment
229  biorbd::utils::Error::check(i<*m_nbDofTrue, "Dof ouside N dof for this segment");
230  return (*m_nameDof)[i];
231 }
232 
234 {
235  return *m_seqT;
236 }
237 
239 {
240  return *m_seqR;
241 }
242 
243 const std::vector<biorbd::utils::Range>&
245 {
246  return *m_QRanges;
247 }
248 
249 const std::vector<biorbd::utils::Range>&
251 {
252  return *m_QDotRanges;
253 }
254 
255 const std::vector<biorbd::utils::Range>&
257 {
258  return *m_QDDotRanges;
259 }
260 
262  return *m_cor;
263 }
265  return *m_characteristics;
266 }
267 
270  const biorbd::utils::String &seqT,
271  const biorbd::utils::String &seqR,
272  const std::vector<biorbd::utils::Range>& QRanges,
273  const std::vector<biorbd::utils::Range>& QDotRanges,
274  const std::vector<biorbd::utils::Range>& QDDotRanges)
275 {
276  determineIfRotIsQuaternion(seqR);
277  setSequence(seqT, seqR);
278 
279  // Control for the size of dofRange then copy it
280  size_t nRot(seqR.length());
281  if (*m_isQuaternion){
282  nRot = 0;
283  }
285  QRanges.size() == 0 ||
286  QRanges.size() == seqT.length() + nRot,
287  "QRanges and number of dof must be equal");
288  *m_QRanges = QRanges;
289 
291  QDotRanges.size() == 0 ||
292  QDotRanges.size() == seqT.length() + nRot,
293  "QDotRanges and number of dof must be equal");
294  *m_QDotRanges = QDotRanges;
295 
297  QDDotRanges.size() == 0 ||
298  QDDotRanges.size() == seqT.length() + nRot,
299  "QDDotRanges and number of dof must be equal");
300  *m_QDDotRanges = QDDotRanges;
301  setJoints(model);
302 }
303 
305  if (!seqR.tolower().compare("q"))
306  *m_isQuaternion = true;
307 }
308 
309 
310 // Member functions
312  const biorbd::utils::String &seqT,
313  const biorbd::utils::String &seqR){
314  m_sequenceTrans->clear();
315  m_sequenceTrans->resize(*m_nbDofTrans);
316  m_sequenceRot->clear();
317  if (*m_isQuaternion)
318  m_sequenceRot->resize(1);
319  else
320  m_sequenceRot->resize(*m_nbDofRot);
321 
322  str2numSequence(*m_sequenceTrans, seqT);
323  str2numSequence(*m_sequenceRot, seqR);
324 
325  // Store the names of the DoFs
326  m_nameDof->clear();
327  m_nameDof->resize(*m_nbDofTrue);
328  for (unsigned int i=0; i<*m_nbDofTrans; ++i)
329  (*m_nameDof)[i] = "Trans" + seqT(i).toupper();
330  for (unsigned int i=0; i<*m_nbDofRot; ++i)
331  (*m_nameDof)[*m_nbDofTrans+i] = "Rot" + seqR(i).toupper();
332  biorbd::utils::String xyz("XYZW");
333  for (unsigned int i=0; i<*m_nbDofQuat; ++i)
334  (*m_nameDof)[*m_nbDofTrans + *m_nbDofRot + i] = biorbd::utils::String("Quat") + xyz.substr(i, 1);
335 
336 }
338  std::vector<unsigned int>& sequenceInteger,
339  const biorbd::utils::String &sequenceText){
340  for (unsigned int i=0; i<sequenceText.length(); i++){
341  char tp = sequenceText.tolower()[i];
342  if (tp == 'x')
343  sequenceInteger[i] = 0;
344  else if (tp == 'y')
345  sequenceInteger[i] = 1;
346  else if (tp == 'z')
347  sequenceInteger[i] = 2;
348  else if (tp == 'q'){
349  sequenceInteger[i] = 3;
350  }
351  else
352  biorbd::utils::Error::raise("Wrong sequence!");
353  }
354 }
355 void biorbd::rigidbody::Segment::setNumberOfDof(unsigned int nTrans, unsigned int nRot){
356  *m_nbDofTrans = nTrans;
357  if (*m_isQuaternion){
358  *m_nbDofRot = 0;
359  *m_nbDofQuat = 4;
360  *m_nbDof = nTrans + 1;
361  *m_nbQdot = nTrans + 3;
362  *m_nbQddot = nTrans + 3;
363  *m_nbDofTrue = nTrans + *m_nbDofQuat;
364  *m_nbDofTrueOutside = nTrans + 3;
365  }
366  else{
367  *m_nbDofRot = nRot;
368  *m_nbDofQuat = 0;
369  *m_nbDof = nTrans + *m_nbDofRot;
370  *m_nbQdot = *m_nbDof;
371  *m_nbQddot = *m_nbDof;
372  *m_nbDofTrue = *m_nbDof;
373  *m_nbDofTrueOutside = *m_nbDof;
374  }
375 }
376 
377 void biorbd::rigidbody::Segment::setSequence(const biorbd::utils::String &seqT, const biorbd::utils::String &seqR) { // Find the x, y, and z positions in this sequence
378  setNumberOfDof(static_cast<unsigned int>(seqT.length()), static_cast<unsigned int>(seqR.length()));
379  str2numSequence(seqT, seqR);
380  fillSequence();
381 }
383  m_dofPosition->clear();
384  m_dofPosition->resize(*m_nbDof);
385 
386  for (unsigned int i=0; i<*m_nbDofTrans; i++)
387  (*m_dofPosition)[i] = (*m_sequenceTrans)[i]; // Place the translation first in the requested order
388  if (*m_isQuaternion)
389  (*m_dofPosition)[*m_nbDofTrans] = (*m_sequenceRot)[0];
390  else
391  for (unsigned int i=0; i<*m_nbDofRot; i++)
392  (*m_dofPosition)[i+*m_nbDofTrans] = (*m_sequenceRot)[i]; // Place the rotation following the translations in the requested order
393 }
394 
396  m_dofCharacteristics->clear();
397 
398  if (*m_nbDof!=0){
399  m_dofCharacteristics->resize(*m_nbDof);
400  for (unsigned int i=0; i<*m_nbDof-1; i++)
401  (*m_dofCharacteristics)[i] = biorbd::rigidbody::SegmentCharacteristics();
402 
403  (*m_dofCharacteristics)[*m_nbDof-1] = *m_characteristics;
404  }
405  else{
406  m_dofCharacteristics->resize(1);
407  (*m_dofCharacteristics)[0] = *m_characteristics;
408  }
409 }
410 
412  // Definition of the rotation axis
413  biorbd::utils::Vector3d axis[3];
414  axis[0] = biorbd::utils::Vector3d(1,0,0); // axe x
415  axis[1] = biorbd::utils::Vector3d(0,1,0); // axe y
416  axis[2] = biorbd::utils::Vector3d(0,0,1); // axe z
417 
418  // Declaration of DoFs in translation
419  m_dof->clear();
420  if (*m_nbDof != 0){
421  m_dof->resize(*m_nbDof);
422  for (unsigned int i=0; i<*m_nbDofTrans; i++)
423  (*m_dof)[i] = RigidBodyDynamics::Joint(
424  RigidBodyDynamics::JointTypePrismatic,
425  axis[(*m_dofPosition)[i]]);
426 
427  // Declaration of the DoFs in rotation
428  if (*m_isQuaternion)
429  (*m_dof)[*m_nbDofTrans] = RigidBodyDynamics::Joint(
430  RigidBodyDynamics::JointTypeSpherical);
431  else
432  for (unsigned int i=*m_nbDofTrans; i<*m_nbDofRot+*m_nbDofTrans; i++)
433  (*m_dof)[i] = RigidBodyDynamics::Joint(
434  RigidBodyDynamics::JointTypeRevolute,
435  axis[(*m_dofPosition)[i]]);
436  }
437  else{
438  m_dof->resize(1);
439  (*m_dof)[0] = RigidBodyDynamics::Joint
440  (RigidBodyDynamics::JointTypeFixed);
441  }
442 }
443 
445  biorbd::rigidbody::Joints& model) {
446  setDofCharacteristicsOnLastBody(); // Apply the segment caracteristics only to the last segment
447  setJointAxis(); // Choose the axis order in relation to the selected sequence
448 
449 
450  RigidBodyDynamics::Math::SpatialTransform zero (
451  RigidBodyDynamics::Math::Matrix3dIdentity,
452  RigidBodyDynamics::Math::Vector3d(0,0,0));
453  // Create the articulations (intra segment)
454  m_idxDof->clear();
455 
456  if (*m_nbDof==0)
457  m_idxDof->resize(1);
458  else
459  m_idxDof->resize(*m_nbDof);
460 
461  unsigned int parent_id(model.GetBodyId(parent().c_str()));
462  if (parent_id == std::numeric_limits<unsigned int>::max())
463  parent_id = 0;
464  if (*m_nbDof==0)
465  (*m_idxDof)[0] = model.AddBody(
466  parent_id, *m_cor, (*m_dof)[0],
467  (*m_dofCharacteristics)[0], name());
468  else if (*m_nbDof == 1)
469  (*m_idxDof)[0] = model.AddBody(
470  parent_id, *m_cor, (*m_dof)[0],
471  (*m_dofCharacteristics)[0], name());
472  else{
473  (*m_idxDof)[0] = model.AddBody(
474  parent_id, *m_cor, (*m_dof)[0],
475  (*m_dofCharacteristics)[0]);
476  for (unsigned int i=1; i<*m_nbDof; i++)
477  if (i!=*m_nbDof-1)
478  (*m_idxDof)[i] = model.AddBody(
479  (*m_idxDof)[i-1], zero,
480  (*m_dof)[i], (*m_dofCharacteristics)[i]);
481  else
482  (*m_idxDof)[i] = model.AddBody(
483  (*m_idxDof)[i-1], zero, (*m_dof)[i],
484  (*m_dofCharacteristics)[i], name());
485  }
486 
487 }
488 
490  const biorbd::utils::String &dofName) const{
491 
492  unsigned int idx(INT_MAX);
493  bool found = false;
494  for (unsigned int i=0; i<nbDof(); ++i){
495  if (!dofName.tolower().compare((*m_nameDof)[i].tolower())){
496  idx = i;
497  found = true;
498  break;
499  }
500  }
501 
502 
504  "Type should be \"Rot\" or \"Trans\" and axis "
505  "should be \"X\", \"Y\" or \"Z\", e.g. "
506  "\"RotY\" for Rotation around y or \"TransX\" "
507  "for Translation on x");
508 
509  return idx;
510 
511 }
512 
513 
514 
biorbd::rigidbody::Segment::localJCS
biorbd::utils::RotoTrans localJCS() const
Return the joint coordinate system (JCS) in the parent reference frame.
Definition: Segment.cpp:261
biorbd::rigidbody::Segment::determineIfRotIsQuaternion
void determineIfRotIsQuaternion(const biorbd::utils::String &seqR)
Determines if DoF in rotation is a Quaternion.
Definition: Segment.cpp:304
biorbd::rigidbody::Segment::id
unsigned int id() const
Return the Segment index.
Definition: Segment.cpp:190
biorbd::rigidbody::Segment::m_idxPF
std::shared_ptr< int > m_idxPF
Platform index which acts on the segment.
Definition: Segment.h:228
biorbd::rigidbody::Segment::m_QDDotRanges
std::shared_ptr< std::vector< biorbd::utils::Range > > m_QDDotRanges
Minimum and maximum acceleration values that each dof should hold. This is only prescriptive and can ...
Definition: Segment.h:268
biorbd::rigidbody::Segment::m_sequenceRot
std::shared_ptr< std::vector< unsigned int > > m_sequenceRot
Euler rotation sequence.
Definition: Segment.h:326
biorbd::rigidbody::Segment::setJoints
virtual void setJoints(biorbd::rigidbody::Joints &model)
Function that adds the segment to the RBDL body set.
Definition: Segment.cpp:444
biorbd::rigidbody::Segment::m_seqT
std::shared_ptr< biorbd::utils::String > m_seqT
Translation sequence.
Definition: Segment.h:264
biorbd::rigidbody::Segment::isRotationAQuaternion
bool isRotationAQuaternion() const
Return if the rotation DoF of this segment is a quaternion.
Definition: Segment.cpp:181
biorbd::utils::Vector3d
Wrapper around Eigen Vector3d and attach it to a parent.
Definition: Vector3d.h:24
biorbd::rigidbody::Segment::m_dof
std::shared_ptr< std::vector< RigidBodyDynamics::Joint > > m_dof
Actual DoF: t1, t2, t3, r1, r2, r3; where the order depends on seqT and seqR.
Definition: Segment.h:288
biorbd::rigidbody::Segment::nbQdot
unsigned int nbQdot() const
Return the number of generalized velocities.
Definition: Segment.cpp:215
biorbd::utils::Node::DeepCopy
void DeepCopy(const biorbd::utils::Node &other)
Deep copy of the node in another node.
Definition: Node.cpp:46
biorbd::rigidbody::SegmentCharacteristics
Characteristics of a segment, namely the mass, the center of mass, the inertia, the length and its me...
Definition: SegmentCharacteristics.h:27
biorbd::rigidbody::Segment::Segment
Segment()
Construct a Segment.
Definition: Segment.cpp:14
biorbd::rigidbody::Segment::nbDofRot
unsigned int nbDofRot() const
Return the number of rotation DoF of the segment.
Definition: Segment.cpp:209
biorbd::rigidbody::Segment::m_nbDofTrue
std::shared_ptr< unsigned int > m_nbDofTrue
Number of degrees of freedom including the extra DoF when there is a quaternion.
Definition: Segment.h:272
biorbd::rigidbody::Segment::nbDofTrans
unsigned int nbDofTrans() const
Return the number of translation DoF of the segment.
Definition: Segment.cpp:206
biorbd::rigidbody::Segment::m_idxDof
std::shared_ptr< std::vector< unsigned int > > m_idxDof
Index of the parent segment.
Definition: Segment.h:289
biorbd::rigidbody::Segment::getDofIdx
unsigned int getDofIdx(const biorbd::utils::String &dofName) const
Return the index of a specified DoF.
Definition: Segment.cpp:489
biorbd::rigidbody::Segment::fillSequence
void fillSequence()
Fill the transation and rotation sequences.
Definition: Segment.cpp:382
biorbd::rigidbody::Segment::QDDotRanges
const std::vector< biorbd::utils::Range > & QDDotRanges() const
Return the ranges for all the dof acceleration, translations and rotations respectively.
Definition: Segment.cpp:256
biorbd::rigidbody::Segment::nbDof
unsigned int nbDof() const
Return the number of DoF of the segment.
Definition: Segment.cpp:203
biorbd::rigidbody::Segment::m_nbQdot
std::shared_ptr< unsigned int > m_nbQdot
Number of generalized velocities.
Definition: Segment.h:270
biorbd::rigidbody::Segment::m_nbDofTrans
std::shared_ptr< unsigned int > m_nbDofTrans
Number of degrees of freedom in translation.
Definition: Segment.h:274
biorbd::rigidbody::Segment::setSequence
void setSequence(const biorbd::utils::String &seqT, const biorbd::utils::String &seqR)
Set angle and translation sequences, adjust angle sequence and redeclare if is necessary.
Definition: Segment.cpp:377
biorbd::rigidbody::Segment::DeepCopy
biorbd::rigidbody::Segment DeepCopy() const
Create a deep copy of Segment.
Definition: Segment.cpp:135
biorbd::rigidbody::Segment::m_nbDof
std::shared_ptr< unsigned int > m_nbDof
Number of degrees of freedom.
Definition: Segment.h:269
biorbd::utils::Error::raise
static void raise(const biorbd::utils::String &message)
Throw an error message.
Definition: Error.cpp:4
biorbd::rigidbody::Segment::nbQ
unsigned int nbQ() const
Return the number of generalized coordinates.
Definition: Segment.cpp:212
biorbd::rigidbody::Segment::m_QDotRanges
std::shared_ptr< std::vector< biorbd::utils::Range > > m_QDotRanges
Minimum and maximum velocity values that each dof should hold. This is only prescriptive and can be i...
Definition: Segment.h:267
biorbd::rigidbody::Segment::m_sequenceTrans
std::shared_ptr< std::vector< unsigned int > > m_sequenceTrans
Translation sequence.
Definition: Segment.h:325
biorbd::rigidbody::Joints
This is the core of the musculoskeletal model in biorbd.
Definition: Joints.h:40
biorbd::rigidbody::Segment::~Segment
virtual ~Segment()
Destroy the class properly.
Definition: Segment.cpp:177
biorbd::rigidbody::Segment::setType
void setType()
Set the type of the segment.
Definition: Segment.cpp:185
biorbd::utils::RotoTrans
Homogenous matrix to describe translations and rotations simultaneously.
Definition: RotoTrans.h:34
biorbd::rigidbody::Segment::QRanges
const std::vector< biorbd::utils::Range > & QRanges() const
Return the ranges for all the dof, translations and rotations respectively.
Definition: Segment.cpp:244
biorbd::utils::String::tolower
static biorbd::utils::String tolower(const biorbd::utils::String &str)
Convert a string to a lower case string.
Definition: String.cpp:97
biorbd::rigidbody::Segment::setNumberOfDof
void setNumberOfDof(unsigned int nbTrans, unsigned int nbRot)
Set the total number of DoF.
Definition: Segment.cpp:355
biorbd::rigidbody::Segment::m_seqR
std::shared_ptr< biorbd::utils::String > m_seqR
Euler rotation sequence.
Definition: Segment.h:265
biorbd::rigidbody::Segment::nameDof
const biorbd::utils::String & nameDof(const unsigned int i) const
Return the name of the specified DoF.
Definition: Segment.cpp:227
biorbd::rigidbody::Segment::m_isQuaternion
std::shared_ptr< bool > m_isQuaternion
If DoF in rotation is a Quaternion.
Definition: Segment.h:278
biorbd::rigidbody::Segment::seqT
const biorbd::utils::String & seqT() const
Return the translation sequence in text.
Definition: Segment.cpp:233
biorbd::rigidbody::Segment::platformIdx
int platformIdx() const
Return the platform index.
Definition: Segment.cpp:197
biorbd::rigidbody::Segment
Description of a segment.
Definition: Segment.h:24
biorbd::rigidbody::Segment::m_nbDofQuat
std::shared_ptr< unsigned int > m_nbDofQuat
Number of degrees of freedom in rotation if expressed in quaternion.
Definition: Segment.h:276
biorbd::rigidbody::Segment::m_dofCharacteristics
std::shared_ptr< std::vector< biorbd::rigidbody::SegmentCharacteristics > > m_dofCharacteristics
Variable containing the inertial data and other from each segment (on a 6DoF segment,...
Definition: Segment.h:351
biorbd::rigidbody::Segment::str2numSequence
void str2numSequence(std::vector< unsigned int > &sequenceInteger, const biorbd::utils::String &sequenceText)
Convert a text sequence to its number counterpart (x = 0, y = 1, z = 2, q = 3)
Definition: Segment.cpp:337
biorbd::rigidbody::Segment::setDofCharacteristicsOnLastBody
void setDofCharacteristicsOnLastBody()
Set the DoF segment characteristics on the last body.
Definition: Segment.cpp:395
biorbd::rigidbody::Segment::m_QRanges
std::shared_ptr< std::vector< biorbd::utils::Range > > m_QRanges
Minimum and maximum coordinate values that each dof should hold. This is only prescriptive and can be...
Definition: Segment.h:266
biorbd::rigidbody::Segment::m_characteristics
std::shared_ptr< biorbd::rigidbody::SegmentCharacteristics > m_characteristics
Non-used virtual segment; it allows to "save" the data and to avoid the use of multiple intermediate ...
Definition: Segment.h:350
biorbd::utils::String
Wrapper around the std::string class with augmented functionality.
Definition: String.h:17
biorbd::rigidbody::Segment::setDofs
void setDofs(biorbd::rigidbody::Joints &model, const biorbd::utils::String &seqT, const biorbd::utils::String &seqR, const std::vector< biorbd::utils::Range > &QRanges, const std::vector< biorbd::utils::Range > &QDotRanges, const std::vector< biorbd::utils::Range > &QDDotRanges)
Set the DoF.
Definition: Segment.cpp:268
biorbd::rigidbody::Segment::nbGeneralizedTorque
unsigned int nbGeneralizedTorque() const
Return the number of generalized torque.
Definition: Segment.cpp:200
biorbd::rigidbody::Segment::setJointAxis
virtual void setJointAxis()
Determine the rotation axis in relation to the requested sequence.
Definition: Segment.cpp:411
biorbd::rigidbody::Segment::m_nameDof
std::shared_ptr< std::vector< biorbd::utils::String > > m_nameDof
To store the DoF names.
Definition: Segment.h:327
biorbd::rigidbody::Segment::nbQddot
unsigned int nbQddot() const
Return the number of generalized accelerations.
Definition: Segment.cpp:218
biorbd::rigidbody::Segment::m_nbDofTrueOutside
std::shared_ptr< unsigned int > m_nbDofTrueOutside
Number of degree of freedom read from the outside (Same as nDof except if Quaternion)
Definition: Segment.h:273
biorbd::rigidbody::Segment::characteristics
const biorbd::rigidbody::SegmentCharacteristics & characteristics() const
Return the segment characteristics.
Definition: Segment.cpp:264
biorbd::utils::String::toupper
static biorbd::utils::String toupper(const biorbd::utils::String &str)
Convert a string to a upper case string.
Definition: String.cpp:107
biorbd::rigidbody::Segment::m_nbQddot
std::shared_ptr< unsigned int > m_nbQddot
Number of generalized accelerations.
Definition: Segment.h:271
biorbd::rigidbody::Segment::m_cor
std::shared_ptr< RigidBodyDynamics::Math::SpatialTransform > m_cor
Attitude of the segment in parent reference frame.
Definition: Segment.h:236
biorbd::rigidbody::Segment::m_nbDofRot
std::shared_ptr< unsigned int > m_nbDofRot
Number of degrees of freedom in rotation.
Definition: Segment.h:275
biorbd::utils::Error::check
static void check(bool cond, const biorbd::utils::String &message)
Assert that raises the error message if false.
Definition: Error.cpp:10
biorbd::rigidbody::Segment::setPF
void setPF(int idx)
Set the platform index.
Definition: Segment.cpp:223
biorbd::rigidbody::Segment::seqR
const biorbd::utils::String & seqR() const
Return the angle sequence in text.
Definition: Segment.cpp:238
biorbd::rigidbody::Segment::QDotRanges
const std::vector< biorbd::utils::Range > & QDotRanges() const
Return the ranges for all the dof velocity, translations and rotations respectively.
Definition: Segment.cpp:250
biorbd::rigidbody::Segment::m_dofPosition
std::shared_ptr< std::vector< unsigned int > > m_dofPosition
Position in the x, y, and z sequence.
Definition: Segment.h:340