Biorbd
Geometry.cpp
1 #define BIORBD_API_EXPORTS
2 #include "Muscles/Geometry.h"
3 
4 #include <rbdl/Model.h>
5 #include <rbdl/Kinematics.h>
6 #include "Utils/Error.h"
7 #include "Utils/Matrix.h"
8 #include "Utils/RotoTrans.h"
9 #include "RigidBody/Joints.h"
10 #include "RigidBody/GeneralizedCoordinates.h"
11 #include "RigidBody/GeneralizedVelocity.h"
12 #include "Muscles/WrappingObject.h"
13 #include "Muscles/PathModifiers.h"
14 #include "Muscles/Characteristics.h"
15 #include "Muscles/ViaPoint.h"
16 #include "Muscles/PathModifiers.h"
17 
19  m_origin(std::make_shared<biorbd::utils::Vector3d>()),
20  m_insertion(std::make_shared<biorbd::utils::Vector3d>()),
21  m_originInGlobal(std::make_shared<biorbd::utils::Vector3d>(biorbd::utils::Vector3d::Zero())),
22  m_insertionInGlobal(std::make_shared<biorbd::utils::Vector3d>(biorbd::utils::Vector3d::Zero())),
23  m_pointsInGlobal(std::make_shared<std::vector<biorbd::utils::Vector3d>>()),
24  m_pointsInLocal(std::make_shared<std::vector<biorbd::utils::Vector3d>>()),
25  m_jacobian(std::make_shared<biorbd::utils::Matrix>()),
26  m_G(std::make_shared<biorbd::utils::Matrix>()),
27  m_jacobianLength(std::make_shared<biorbd::utils::Matrix>()),
28  m_length(std::make_shared<biorbd::utils::Scalar>(0)),
29  m_muscleTendonLength(std::make_shared<biorbd::utils::Scalar>(0)),
30  m_velocity(std::make_shared<biorbd::utils::Scalar>(0)),
31  m_isGeometryComputed(std::make_shared<bool>(false)),
32  m_isVelocityComputed(std::make_shared<bool>(false)),
33  m_posAndJacoWereForced(std::make_shared<bool>(false))
34 {
35 
36 }
37 
39  const biorbd::utils::Vector3d &origin,
40  const biorbd::utils::Vector3d &insertion) :
41  m_origin(std::make_shared<biorbd::utils::Vector3d>(origin)),
42  m_insertion(std::make_shared<biorbd::utils::Vector3d>(insertion)),
43  m_originInGlobal(std::make_shared<biorbd::utils::Vector3d>(biorbd::utils::Vector3d::Zero())),
44  m_insertionInGlobal(std::make_shared<biorbd::utils::Vector3d>(biorbd::utils::Vector3d::Zero())),
45  m_pointsInGlobal(std::make_shared<std::vector<biorbd::utils::Vector3d>>()),
46  m_pointsInLocal(std::make_shared<std::vector<biorbd::utils::Vector3d>>()),
47  m_jacobian(std::make_shared<biorbd::utils::Matrix>()),
48  m_G(std::make_shared<biorbd::utils::Matrix>()),
49  m_jacobianLength(std::make_shared<biorbd::utils::Matrix>()),
50  m_length(std::make_shared<biorbd::utils::Scalar>(0)),
51  m_muscleTendonLength(std::make_shared<biorbd::utils::Scalar>(0)),
52  m_velocity(std::make_shared<biorbd::utils::Scalar>(0)),
53  m_isGeometryComputed(std::make_shared<bool>(false)),
54  m_isVelocityComputed(std::make_shared<bool>(false)),
55  m_posAndJacoWereForced(std::make_shared<bool>(false))
56 {
57 
58 }
59 
61 {
63  copy.DeepCopy(*this);
64  return copy;
65 }
66 
68 {
69  *m_origin = other.m_origin->DeepCopy();
70  *m_insertion = other.m_insertion->DeepCopy();
71  *m_originInGlobal = other.m_originInGlobal->DeepCopy();
72  *m_insertionInGlobal = other.m_insertionInGlobal->DeepCopy();
73  m_pointsInGlobal->resize(other.m_pointsInGlobal->size());
74  for (unsigned int i=0; i<other.m_pointsInGlobal->size(); ++i)
75  (*m_pointsInGlobal)[i] = (*other.m_pointsInGlobal)[i].DeepCopy();
76  m_pointsInLocal->resize(other.m_pointsInLocal->size());
77  for (unsigned int i=0; i<other.m_pointsInLocal->size(); ++i)
78  (*m_pointsInLocal)[i] = (*other.m_pointsInLocal)[i].DeepCopy();
79  *m_jacobian = *other.m_jacobian;
80  *m_G = *other.m_G;
81  *m_jacobianLength = *other.m_jacobianLength;
82  *m_length = *other.m_length;
83  *m_muscleTendonLength = *other.m_muscleTendonLength;
84  *m_velocity = *other.m_velocity;
85  *m_isGeometryComputed = *other.m_isGeometryComputed;
86  *m_isVelocityComputed = *other.m_isVelocityComputed;
87  *m_posAndJacoWereForced = *other.m_posAndJacoWereForced;
88 }
89 
90 
91 // ------ PUBLIC FUNCTIONS ------ //
96  int updateKin)
97 {
98  if (*m_posAndJacoWereForced){
100  false,
101  "Warning, using updateKinematics overrides the"
102  " previously sent position and jacobian");
103  *m_posAndJacoWereForced = false;
104  }
105 
106  // Make sure the model is in the right configuration
107  if (updateKin > 1)
108  model.UpdateKinematicsCustom(Q, Qdot, nullptr);
109 
110  // Position of the points in space
111  setMusclesPointsInGlobal(model, *Q);
112 
113  // Compute the Jacobian of the muscle points
114  jacobian(model, *Q);
115 
116  // Complete the update
117  _updateKinematics(Qdot);
118 }
119 
121  const biorbd::muscles::Characteristics& characteristics,
122  biorbd::muscles::PathModifiers &pathModifiers,
125  int updateKin)
126 {
127  if (*m_posAndJacoWereForced){
129  false, "Warning, using updateKinematics overrides the"
130  " previously sent position and jacobian");
131  *m_posAndJacoWereForced = false;
132  }
133 
134  // Ensure the model is in the right configuration
135  if (updateKin > 1) {
136  model.UpdateKinematicsCustom(Q, Qdot);
137  }
138 
139  // Position of the points in space
140  setMusclesPointsInGlobal(model, *Q, &pathModifiers);
141 
142  // Compute the Jacobian of the muscle points
143  jacobian(model, *Q);
144 
145  // Complete the update
146  _updateKinematics(Qdot, &characteristics, &pathModifiers);
147 }
148 
150  std::vector<biorbd::utils::Vector3d>& musclePointsInGlobal,
151  biorbd::utils::Matrix& jacoPointsInGlobal,
153 {
154  *m_posAndJacoWereForced = true;
155 
156  // Position of the points in space
157  setMusclesPointsInGlobal(musclePointsInGlobal);
158 
159  // Compute the Jacobian of the muscle points
160  jacobian(jacoPointsInGlobal);
161 
162  // Complete the update
163  _updateKinematics(Qdot);
164 }
165 
167  std::vector<biorbd::utils::Vector3d>& musclePointsInGlobal,
168  biorbd::utils::Matrix& jacoPointsInGlobal,
171 {
172  *m_posAndJacoWereForced = true;
173 
174  // Position of the points in space
175  setMusclesPointsInGlobal(musclePointsInGlobal);
176 
177  // Compute the Jacobian of the muscle points
178  jacobian(jacoPointsInGlobal);
179 
180  // Complete the update
181  _updateKinematics(Qdot, &c);
182 }
183 
184 // Get and set the positions of the origins and insertions
186  const utils::Vector3d &position)
187 {
188  *m_origin = position;
189 }
191 {
192  return *m_origin;
193 }
194 
196  const utils::Vector3d &position)
197 {
198  *m_insertion = position;
199 }
201 {
202  return *m_insertion;
203 }
204 
205 // Position of the muscles in space
207 {
208  biorbd::utils::Error::check(*m_isGeometryComputed, "Geometry must be computed at least once before calling originInLocal()");
209  return *m_originInGlobal;
210 }
212 {
213  biorbd::utils::Error::check(*m_isGeometryComputed, "Geometry must be computed at least once before calling insertionInGlobal()");
214  return *m_insertionInGlobal;
215 }
216 const std::vector<biorbd::utils::Vector3d> &biorbd::muscles::Geometry::musclesPointsInGlobal() const
217 {
218  biorbd::utils::Error::check(*m_isGeometryComputed, "Geometry must be computed at least once before calling musclesPointsInGlobal()");
219  return *m_pointsInGlobal;
220 }
221 
222 // Return the length and muscular velocity
223 const biorbd::utils::Scalar& biorbd::muscles::Geometry::length() const
224 {
225  biorbd::utils::Error::check(*m_isGeometryComputed, "Geometry must be computed at least before calling length()");
226  return *m_length;
227 }
228 const biorbd::utils::Scalar& biorbd::muscles::Geometry::musculoTendonLength() const
229 {
230  biorbd::utils::Error::check(*m_isGeometryComputed, "Geometry must be computed at least before calling length()");
231  return *m_muscleTendonLength;
232 }
233 const biorbd::utils::Scalar& biorbd::muscles::Geometry::velocity() const
234 {
235  biorbd::utils::Error::check(*m_isVelocityComputed, "Geometry must be computed before calling velocity()");
236  return *m_velocity;
237 }
238 
239 // Return the Jacobian
241 {
242  biorbd::utils::Error::check(*m_isGeometryComputed, "Geometry must be computed before calling jacobian()");
243  return *m_jacobian;
244 } // Return the last Jacobian
246 {
247  biorbd::utils::Error::check(*m_isGeometryComputed, "Geometry must be computed before calling jacobianOrigin()");
248  return m_jacobian->block(0,0,3,m_jacobian->cols());
249 }
251 {
252  biorbd::utils::Error::check(*m_isGeometryComputed, "Geometry must be computed before calling jacobianInsertion()");
253  return m_jacobian->block(m_jacobian->rows()-3,0,3,m_jacobian->cols());
254 }
256 {
257  biorbd::utils::Error::check(*m_isGeometryComputed, "Geometry must be computed before calling jacobian(i)");
258  return m_jacobian->block(3*idxViaPoint,0,3,m_jacobian->cols());
259 }
260 
262 {
263  biorbd::utils::Error::check(*m_isGeometryComputed, "Geometry must be computed before calling jacobianLength()");
264  return *m_jacobianLength;
265 }
266 
267 // --------------------------------------- //
268 
271  const biorbd::muscles::Characteristics* characteristics,
272  biorbd::muscles::PathModifiers *pathModifiers)
273 {
274  // Compute the length and velocities
275  length(characteristics, pathModifiers);
276  *m_isGeometryComputed = true;
277 
278  // Compute the jacobian of the lengths
279  computeJacobianLength();
280  if (Qdot != nullptr){
281  velocity(*Qdot);
282  *m_isVelocityComputed = true;
283  }
284  else
285  *m_isVelocityComputed = false;
286 }
287 
291 {
292  // Return the position of the marker in function of the given position
293  m_originInGlobal->block(0,0,3,1) = RigidBodyDynamics::CalcBodyToBaseCoordinates(model, Q, model.GetBodyId(m_origin->parent().c_str()), *m_origin,false);
294  return *m_originInGlobal;
295 }
296 
300 {
301  // Return the position of the marker in function of the given position
302  m_insertionInGlobal->block(0,0,3,1) = RigidBodyDynamics::CalcBodyToBaseCoordinates(model, Q, model.GetBodyId(m_insertion->parent().c_str()), *m_insertion,false);
303  return *m_insertionInGlobal;
304 }
305 
307  std::vector<biorbd::utils::Vector3d> &ptsInGlobal)
308 {
309  biorbd::utils::Error::check(ptsInGlobal.size() >= 2, "ptsInGlobal must at least have an origin and an insertion");
310  m_pointsInLocal->clear(); // In this mode, we don't need the local, because the Jacobian of the points has to be given as well
311  *m_pointsInGlobal = ptsInGlobal;
312 }
313 
317  biorbd::muscles::PathModifiers *pathModifiers)
318 {
319  // Output varible (reset to zero)
320  m_pointsInLocal->clear();
321  m_pointsInGlobal->clear();
322 
323  // Do not apply on wrapping objects
324  if (pathModifiers->nbWraps()!=0){
325  // CHECK TO MODIFY BEFOR GOING FORWARD WITH PROJECTS
326  biorbd::utils::Error::check(pathModifiers->nbVia() == 0, "Cannot mix wrapping and via points yet") ;
327  biorbd::utils::Error::check(pathModifiers->nbWraps() < 2, "Cannot compute more than one wrapping yet");
328 
329  // Get the matrix of Rt of the wrap
330  biorbd::muscles::WrappingObject& w = static_cast<biorbd::muscles::WrappingObject&>(pathModifiers->object(0));
331  const biorbd::utils::RotoTrans& RT = w.RT(model,Q);
332 
333  // Alias
334  const biorbd::utils::Vector3d& po_mus = originInGlobal(model, Q); // Origin on bone
335  const biorbd::utils::Vector3d& pi_mus = insertionInGlobal(model,Q); // Insertion on bone
336 
337  biorbd::utils::Vector3d pi_wrap(0, 0, 0); // point on the wrapping related to insertion
338  biorbd::utils::Vector3d po_wrap(0, 0, 0); // point on the wrapping related to origin
339 
340  w.wrapPoints(RT,po_mus,pi_mus,po_wrap, pi_wrap);
341 
342  // Store the points in local
343  biorbd::utils::Error::check(0, "That part of the function is not validated, "
344  "please contact pariterre@hotmail.com");
345  m_pointsInLocal->push_back(originInLocal());
346  m_pointsInLocal->push_back(
347  biorbd::utils::Vector3d(RigidBodyDynamics::CalcBodyToBaseCoordinates(
348  model, Q, model.GetBodyId(w.parent().c_str()),po_wrap, false),
349  "wrap_o", w.parent()));
350  m_pointsInLocal->push_back(
351  biorbd::utils::Vector3d(RigidBodyDynamics::CalcBodyToBaseCoordinates(
352  model, Q, model.GetBodyId(w.parent().c_str()),pi_wrap, false),
353  "wrap_i", w.parent()));
354  m_pointsInLocal->push_back(insertionInLocal());
355 
356  // Store the points in global
357  m_pointsInGlobal->push_back(originInGlobal());
358  m_pointsInGlobal->push_back(po_wrap);
359  m_pointsInGlobal->push_back(pi_wrap);
360  m_pointsInGlobal->push_back(insertionInGlobal());
361 
362  }
363 
364  else if (pathModifiers->nbObjects()!=0 && pathModifiers->object(0).typeOfNode() == biorbd::utils::NODE_TYPE::VIA_POINT){
365  m_pointsInLocal->push_back(originInLocal());
366  m_pointsInGlobal->push_back(originInGlobal(model, Q));
367  for (unsigned int i=0; i<pathModifiers->nbObjects(); ++i){
368  const biorbd::muscles::ViaPoint& node(static_cast<biorbd::muscles::ViaPoint&>(pathModifiers->object(i)));
369  m_pointsInLocal->push_back(node);
370  m_pointsInGlobal->push_back(RigidBodyDynamics::CalcBodyToBaseCoordinates(model, Q, model.GetBodyId(node.parent().c_str()), node, false));
371  }
372  m_pointsInLocal->push_back(insertionInLocal());
373  m_pointsInGlobal->push_back(insertionInGlobal(model,Q));
374 
375  }
376  else if (pathModifiers->nbObjects()==0){
377  m_pointsInLocal->push_back(originInLocal());
378  m_pointsInLocal->push_back(insertionInLocal());
379  m_pointsInGlobal->push_back(originInGlobal(model, Q));
380  m_pointsInGlobal->push_back(insertionInGlobal(model,Q));
381  }
382  else
383  biorbd::utils::Error::raise("Length for this type of object was not implemented");
384 
385  // Set the dimension of jacobian
386  setJacobianDimension(model);
387 }
388 
389 const biorbd::utils::Scalar& biorbd::muscles::Geometry::length(
390  const biorbd::muscles::Characteristics *characteristics,
391  biorbd::muscles::PathModifiers *pathModifiers)
392 {
393  *m_muscleTendonLength = 0;
394 
395  // because we can't combine, test the first (0) will let us know all the types if more than one
396  if (pathModifiers != nullptr && pathModifiers->nbWraps()!=0){
397  // CHECK TO MODIFY BEFORE GOING FORWARD WITH PROJECTS
398  biorbd::utils::Error::check(pathModifiers->nbVia() == 0, "Cannot mix wrapping and via points yet" ) ;
399  biorbd::utils::Error::check(pathModifiers->nbWraps() < 2, "Cannot compute more than one wrapping yet");
400 
401  biorbd::utils::Vector3d pi_wrap(0, 0, 0); // point on the wrapping related to insertion
402  biorbd::utils::Vector3d po_wrap(0, 0, 0); // point on the wrapping related to origin
403  biorbd::utils::Scalar lengthWrap(0);
404  static_cast<biorbd::muscles::WrappingObject&>(pathModifiers->object(0)).wrapPoints(
405  po_wrap,
406  pi_wrap,
407  &lengthWrap);
408  *m_muscleTendonLength = ((*m_pointsInGlobal)[0] - pi_wrap).norm() + // length before the wrap
409  lengthWrap + // length on the wrap
410  (*m_pointsInGlobal->end() - po_wrap).norm(); // length after the wrap
411 
412  }
413  else{
414  for (unsigned int i=0; i<m_pointsInGlobal->size()-1; ++i)
415  *m_muscleTendonLength += ((*m_pointsInGlobal)[i+1] - (*m_pointsInGlobal)[i]).norm();
416  }
417 
418  *m_length = (*m_muscleTendonLength - characteristics->tendonSlackLength())
419  /
420  std::cos(characteristics->pennationAngle());
421 
422  return *m_length;
423 }
424 
425 const biorbd::utils::Scalar& biorbd::muscles::Geometry::velocity(
427 {
428  // Compute the velocity of the muscular elongation
429  *m_velocity = (jacobianLength()*Qdot)[0];
430  return *m_velocity;
431 }
432 
434 {
435  *m_jacobian = biorbd::utils::Matrix::Zero(static_cast<unsigned int>(m_pointsInLocal->size()*3), model.dof_count);
436  *m_G = biorbd::utils::Matrix::Zero(3, model.dof_count);
437 }
438 
440 {
441  biorbd::utils::Error::check(jaco.rows()/3 == static_cast<int>(m_pointsInGlobal->size()), "Jacobian is the wrong size");
442  *m_jacobian = jaco;
443 }
444 
448 {
449  for (unsigned int i=0; i<m_pointsInLocal->size(); ++i){
450  m_G->setZero();
451  RigidBodyDynamics::CalcPointJacobian(model, Q, model.GetBodyId((*m_pointsInLocal)[i].parent().c_str()), (*m_pointsInLocal)[i], *m_G, false); // False for speed
452  m_jacobian->block(3*i,0,3,model.dof_count) = *m_G;
453  }
454 }
455 
457 {
458  *m_jacobianLength = biorbd::utils::Matrix::Zero(1, m_jacobian->cols());
459  const std::vector<biorbd::utils::Vector3d>& p = *m_pointsInGlobal;
460  for (unsigned int i=0; i<p.size()-1 ; ++i){
461  *m_jacobianLength += (( p[i+1] - p[i] ).transpose() * (jacobian(i+1) - jacobian(i)))
462  /
463  ( p[i+1] - p[i] ).norm();
464  }
465 }
biorbd::muscles::Geometry::insertionInLocal
const biorbd::utils::Vector3d & insertionInLocal() const
Return the insertion position.
Definition: Geometry.cpp:200
biorbd::muscles::Geometry::m_originInGlobal
std::shared_ptr< biorbd::utils::Vector3d > m_originInGlobal
Position of the origin in the global reference.
Definition: Geometry.h:323
biorbd::muscles::Characteristics::pennationAngle
const biorbd::utils::Scalar & pennationAngle() const
Return the angle of pennation.
Definition: Characteristics.cpp:126
biorbd::muscles::PathModifiers::nbWraps
unsigned int nbWraps() const
Return the total number of wrapping objects in the set.
Definition: PathModifiers.cpp:61
biorbd::muscles::Geometry::computeJacobianLength
void computeJacobianLength()
Compute the muscle length jacobian.
Definition: Geometry.cpp:456
biorbd::utils::Vector3d
Wrapper around Eigen Vector3d and attach it to a parent.
Definition: Vector3d.h:24
biorbd::muscles::PathModifiers::nbObjects
unsigned int nbObjects() const
Return the total number of path modifier objects in the set.
Definition: PathModifiers.cpp:70
biorbd::muscles::Geometry::m_velocity
std::shared_ptr< biorbd::utils::Scalar > m_velocity
Velocity of the muscular elongation.
Definition: Geometry.h:333
biorbd::rigidbody::GeneralizedCoordinates
Class GeneralizedCoordinates.
Definition: GeneralizedCoordinates.h:15
biorbd::muscles::Geometry::m_pointsInGlobal
std::shared_ptr< std::vector< biorbd::utils::Vector3d > > m_pointsInGlobal
Position of all the points in the global reference.
Definition: Geometry.h:325
biorbd::muscles::ViaPoint
Via point of a muscle.
Definition: ViaPoint.h:16
biorbd::muscles::Geometry::m_origin
std::shared_ptr< biorbd::utils::Vector3d > m_origin
Origin node.
Definition: Geometry.h:320
biorbd::muscles::Geometry
Class Geometry of the muscle.
Definition: Geometry.h:30
biorbd::muscles::Geometry::jacobianOrigin
biorbd::utils::Matrix jacobianOrigin() const
Return the gradient of the jacobian for the origin node.
Definition: Geometry.cpp:245
biorbd::utils::Node::typeOfNode
biorbd::utils::NODE_TYPE typeOfNode() const
Return the type of node.
Definition: Node.cpp:75
biorbd::muscles::Geometry::DeepCopy
biorbd::muscles::Geometry DeepCopy() const
Deep copy of a geometry.
Definition: Geometry.cpp:60
biorbd::muscles::Geometry::jacobianLength
const biorbd::utils::Matrix & jacobianLength() const
Return the jacobian length of the muscle.
Definition: Geometry.cpp:261
biorbd::muscles::Geometry::jacobianInsertion
biorbd::utils::Matrix jacobianInsertion() const
Return the gradient of the jacobian for the insertion node.
Definition: Geometry.cpp:250
biorbd::utils::Error::raise
static void raise(const biorbd::utils::String &message)
Throw an error message.
Definition: Error.cpp:4
biorbd::muscles::Geometry::m_posAndJacoWereForced
std::shared_ptr< bool > m_posAndJacoWereForced
To know if the override was used on the muscle position and the Jacobian.
Definition: Geometry.h:337
biorbd::muscles::Geometry::m_G
std::shared_ptr< biorbd::utils::Matrix > m_G
Internal matrix of the jacobian dimension to speed up calculation.
Definition: Geometry.h:328
biorbd::utils::Error::warning
static void warning(bool cond, const biorbd::utils::String &message)
Non-blocking assert that displays the error message if false.
Definition: Error.cpp:19
biorbd::muscles::Geometry::m_jacobianLength
std::shared_ptr< biorbd::utils::Matrix > m_jacobianLength
The muscle length jacobian.
Definition: Geometry.h:329
biorbd::muscles::Geometry::updateKinematics
void updateKinematics(biorbd::rigidbody::Joints &model, const biorbd::rigidbody::GeneralizedCoordinates *Q=nullptr, const biorbd::rigidbody::GeneralizedVelocity *Qdot=nullptr, int updateKin=2)
Updates the position and dynamic elements of the muscles.
Definition: Geometry.cpp:92
biorbd::muscles::PathModifiers::nbVia
unsigned int nbVia() const
Return the total number of via points in the set.
Definition: PathModifiers.cpp:65
biorbd::muscles::Geometry::setOrigin
void setOrigin(const biorbd::utils::Vector3d &position)
Set the origin position in the local reference frame of the muscle.
Definition: Geometry.cpp:185
biorbd::muscles::Geometry::setMusclesPointsInGlobal
void setMusclesPointsInGlobal(std::vector< biorbd::utils::Vector3d > &ptsInGlobal)
Set the muscle points in global.
Definition: Geometry.cpp:306
biorbd::muscles::Geometry::m_isVelocityComputed
std::shared_ptr< bool > m_isVelocityComputed
To know if the velocity was computed in the last update.
Definition: Geometry.h:336
biorbd::muscles::Geometry::musculoTendonLength
const biorbd::utils::Scalar & musculoTendonLength() const
Return the previously computed muscle-tendon length.
Definition: Geometry.cpp:228
biorbd::rigidbody::Joints
This is the core of the musculoskeletal model in biorbd.
Definition: Joints.h:40
biorbd::utils::RotoTrans
Homogenous matrix to describe translations and rotations simultaneously.
Definition: RotoTrans.h:34
biorbd::muscles::Geometry::m_jacobian
std::shared_ptr< biorbd::utils::Matrix > m_jacobian
The jacobian matrix.
Definition: Geometry.h:327
biorbd::muscles::Geometry::insertionInGlobal
const biorbd::utils::Vector3d & insertionInGlobal() const
Return the insertion position in the global reference.
Definition: Geometry.cpp:211
biorbd::muscles::Geometry::Geometry
Geometry()
Construct geometry.
Definition: Geometry.cpp:18
biorbd::muscles::Geometry::musclesPointsInGlobal
const std::vector< biorbd::utils::Vector3d > & musclesPointsInGlobal() const
Return the muscles points in the global reference.
Definition: Geometry.cpp:216
biorbd::muscles::PathModifiers
Holder of all the path modifiers of a muscle.
Definition: PathModifiers.h:18
biorbd::utils::Matrix
A wrapper for the Eigen::MatrixXd.
Definition: Matrix.h:21
biorbd::muscles::Characteristics::tendonSlackLength
const biorbd::utils::Scalar & tendonSlackLength() const
Return the tendon slack length.
Definition: Characteristics.cpp:116
biorbd::muscles::Geometry::m_insertion
std::shared_ptr< biorbd::utils::Vector3d > m_insertion
Insertion node.
Definition: Geometry.h:321
biorbd::muscles::Geometry::setInsertionInLocal
void setInsertionInLocal(const biorbd::utils::Vector3d &position)
Set the insertion position.
Definition: Geometry.cpp:195
biorbd::muscles::WrappingObject::RT
virtual const biorbd::utils::RotoTrans & RT(biorbd::rigidbody::Joints &model, const biorbd::rigidbody::GeneralizedCoordinates &Q, bool updateKin=true)=0
Return the RotoTrans matrix of the wrapping object.
biorbd::muscles::Geometry::m_length
std::shared_ptr< biorbd::utils::Scalar > m_length
Muscle length.
Definition: Geometry.h:331
biorbd::muscles::WrappingObject
Base class for the wrapping objects.
Definition: WrappingObject.h:23
biorbd::muscles::Geometry::velocity
const biorbd::utils::Scalar & velocity() const
Return the previously computed velocity.
Definition: Geometry.cpp:233
biorbd::muscles::Geometry::m_pointsInLocal
std::shared_ptr< std::vector< biorbd::utils::Vector3d > > m_pointsInLocal
Position of all the points in local.
Definition: Geometry.h:326
biorbd::muscles::Geometry::m_insertionInGlobal
std::shared_ptr< biorbd::utils::Vector3d > m_insertionInGlobal
Position of the insertion node in the global reference.
Definition: Geometry.h:324
biorbd::muscles::Geometry::m_muscleTendonLength
std::shared_ptr< biorbd::utils::Scalar > m_muscleTendonLength
Muscle tendon length.
Definition: Geometry.h:332
biorbd::muscles::Geometry::length
const biorbd::utils::Scalar & length() const
Return the previously computed muscle length.
Definition: Geometry.cpp:223
biorbd::muscles::PathModifiers::object
biorbd::utils::Vector3d & object(unsigned int idx)
Return the object at a specific index in the set.
Definition: PathModifiers.cpp:75
biorbd::muscles::Geometry::_updateKinematics
void _updateKinematics(const biorbd::rigidbody::GeneralizedVelocity *Qdot, const biorbd::muscles::Characteristics *characteristics=nullptr, biorbd::muscles::PathModifiers *pathModifiers=nullptr)
Actual function that implements the update of the kinematics.
Definition: Geometry.cpp:269
biorbd::muscles::WrappingObject::wrapPoints
virtual void wrapPoints(const biorbd::utils::RotoTrans &rt, const biorbd::utils::Vector3d &p1_bone, const biorbd::utils::Vector3d &p2_bone, biorbd::utils::Vector3d &p1, biorbd::utils::Vector3d &p2, biorbd::utils::Scalar *muscleLength=nullptr)=0
From the position of the wrapping object, return the 2 locations where the muscle leaves the wrapping...
biorbd::muscles::Geometry::originInGlobal
const biorbd::utils::Vector3d & originInGlobal() const
Return the origin position in the global reference.
Definition: Geometry.cpp:206
biorbd::muscles::Characteristics
Class Holds that muscle characteristics.
Definition: Characteristics.h:17
biorbd::muscles::Geometry::jacobian
const biorbd::utils::Matrix & jacobian() const
Return the previously computed muscle jacobian.
Definition: Geometry.cpp:240
biorbd::rigidbody::Joints::UpdateKinematicsCustom
void UpdateKinematicsCustom(const biorbd::rigidbody::GeneralizedCoordinates *Q=nullptr, const biorbd::rigidbody::GeneralizedVelocity *Qdot=nullptr, const biorbd::rigidbody::GeneralizedAcceleration *Qddot=nullptr)
Update the kinematic variables such as body velocities and accelerations in the model to reflect the ...
Definition: Joints.cpp:1063
biorbd::utils::Node::parent
const biorbd::utils::String & parent() const
Return the parent name of the node.
Definition: Node.cpp:64
biorbd::rigidbody::GeneralizedVelocity
Class GeneralizedVelocity.
Definition: GeneralizedVelocity.h:15
biorbd::muscles::Geometry::originInLocal
const biorbd::utils::Vector3d & originInLocal() const
Return the origin position.
Definition: Geometry.cpp:190
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::muscles::Geometry::setJacobianDimension
void setJacobianDimension(biorbd::rigidbody::Joints &model)
Set the jacobian dimensions.
Definition: Geometry.cpp:433
biorbd::muscles::Geometry::m_isGeometryComputed
std::shared_ptr< bool > m_isGeometryComputed
To know if the geometry was computed at least once.
Definition: Geometry.h:335