Robot Dynamics Library
Model.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Jordan Lack <jlack1987@gmail.com>
2 // Copyright (c) 2011-2016 Martin Felis <martin.felis@iwr.uni-heidelberg.de>
3 // RDL - Robot Dynamics Library
4 // Licensed under the zlib license. See LICENSE for more details.
5 
6 #ifndef RDL_MODEL_H
7 #define RDL_MODEL_H
8 
13 #include <assert.h>
14 #include <boost/asio/io_service.hpp>
15 #include <boost/function.hpp>
16 #include <boost/thread/thread.hpp>
17 #include <cstring>
18 #include <iostream>
19 #include <limits>
20 #include <list>
21 #include <map>
22 #include <rclcpp/rclcpp.hpp>
23 #include <type_traits>
24 
25 #include <rdl_dynamics/Body.hpp>
26 #include <rdl_dynamics/Joint.hpp>
34 
35 // std::vectors containing any objects that have Eigen matrices or vectors
36 // as members need to have a special allocater. This can be achieved with
37 // the following macro.
38 
41 namespace RobotDynamics
42 {
111 struct Model
112 {
113  using SharedPtr = std::shared_ptr<Model>;
119  explicit Model(const rclcpp::Node::SharedPtr& n = nullptr, unsigned int* n_threads = nullptr);
120 
122  {
123  work.reset();
124  thread_pool.join_all();
125  }
126 
127  Model(const Model&) = delete;
128  void operator=(const Model&) = delete;
129 
137  void setupRosParameters();
138 
139  // Structural information
140 
143  /* clang-format off */
144 
145  std::vector<ReferenceFramePtr> bodyFrames;
147  // clang for some reason continuously reformats the comment on the above line no matter
148  // how many times you run it.
149  /* clang-format on */
150 
152  std::vector<ReferenceFramePtr> bodyCenteredFrames;
153 
154  std::vector<ReferenceFramePtr> bodyCenterOfBuoyancyFrames;
158  std::vector<ReferenceFramePtr> fixedBodyFrames;
159 
160  std::vector<unsigned int> lambda;
161  std::vector<std::vector<unsigned int>> lambda_chain;
163  std::vector<unsigned int> lambda_q;
166  std::vector<std::vector<unsigned int>> mu;
173  unsigned int dof_count = 0;
174 
182  unsigned int q_size = 0;
183 
191  unsigned int qdot_size = 0;
192 
194  double mass = 0.;
196  double volume = 0.;
197 
199  unsigned int previously_added_body_id = 0;
200 
203  double fluidDensity = 1000.;
207  // State information
214  // Joints
215 
217 
218  std::vector<Joint> mJoints;
219 
223  // Joint state variables
224  std::vector<Math::SpatialTransform> X_J;
225 
226  std::vector<Math::SpatialVector> c_J;
230  std::vector<unsigned int> mJointUpdateOrder;
231 
233  // It is expressed in the coordinate frame of the parent.
234  std::vector<Math::SpatialTransform> X_T;
235 
238  std::vector<unsigned int> mFixedJointCount;
239 
241  // Special variables for joints with 3 degrees of freedom
243 
244  std::vector<Math::Matrix63> multdof3_S;
245  std::vector<Math::Matrix63> multdof3_S_o;
246  std::vector<Math::Matrix63> multdof3_U;
247  std::vector<Math::Matrix3d> multdof3_Dinv;
248  std::vector<Math::Vector3d> multdof3_u;
249  std::vector<unsigned int> multdof3_w_index;
250 
251  std::vector<CustomJoint*> mCustomJoints;
252 
254  // Dynamics variables
255 
257  std::vector<Math::SpatialVector> c;
258 
260  std::vector<Math::SpatialMatrix> IA;
261 
264 
266  std::vector<Math::SpatialVector> U;
267 
270 
273 
277 
281  std::vector<Math::SpatialMatrix> I_add;
282  std::vector<Math::SpatialMatrix> I_H;
283  std::vector<Math::SpatialMatrix> Ic_H;
287  std::vector<Math::Momentum> hc;
288 
300  // Bodies
301 
307  std::vector<Math::SpatialTransform> X_lambda;
308 
310  std::vector<FixedBody> mFixedBodies;
311 
324  unsigned int fixed_body_discriminator = std::numeric_limits<unsigned int>::max() / 2;
325 
333  std::vector<Body> mBodies;
334 
336  std::map<std::string, unsigned int> mBodyNameMap;
337 
339  std::map<std::string, ReferenceFramePtr> referenceFrameMap;
340  unsigned int num_branch_ends = 0;
341 
344 
347 
348  boost::asio::io_service io_service;
349  std::unique_ptr<boost::asio::io_service::work> work;
350  std::vector<boost::thread*> threads;
351  boost::thread_group thread_pool;
352 
353  rclcpp::Node::SharedPtr node;
354  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr callback_handle;
355 
356  rcl_interfaces::msg::SetParametersResult paramCb(const std::vector<rclcpp::Parameter>& parameters);
357 
358  bool setThreadParameters(int policy, struct sched_param param)
359  {
360  if (threads.size() > 0)
361  {
362  for (unsigned int i = 0; i < threads.size(); ++i)
363  {
364  int retcode;
365  if ((retcode = pthread_setschedparam(threads[i]->native_handle(), policy, &param)) != 0)
366  {
367  if (retcode == EPERM)
368  {
369  std::cerr << "Model.setThreadParameters: Failed setting thread parameters. Invalid permissions" << std::endl;
370  }
371  else if (retcode == ESRCH)
372  {
373  std::cerr << "Model.setThreadParameters: Failed setting thread parameters. No thread with the ID could be found" << std::endl;
374  }
375  else if (retcode == EINVAL)
376  {
377  std::cerr << "Model.setThreadParameters: Failed setting thread parameters. policy is not a recognized policy, or param does not make sense for "
378  "the policy."
379  << std::endl;
380  }
381  else
382  {
383  std::cerr << "Model.setThreadParameters: Failed setting thread parameters. pthread_setschedparam returned with unknown error code " << retcode
384  << std::endl;
385  }
386 
387  return false;
388  }
389  }
390  }
391 
392  return true;
393  }
394 
426  unsigned int addBody(const unsigned int parent_id, const Math::SpatialTransform& joint_frame, const Joint& joint, const Body& body, std::string body_name = "");
427 
428  unsigned int addBodySphericalJoint(const unsigned int parent_id, const Math::SpatialTransform& joint_frame, const Joint& joint, const Body& body,
429  std::string body_name = "");
430 
437  unsigned int appendBody(const Math::SpatialTransform& joint_frame, const Joint& joint, const Body& body, std::string body_name = "");
438 
439  unsigned int addBodyCustomJoint(const unsigned int parent_id, const Math::SpatialTransform& joint_frame, CustomJoint* custom_joint, const Body& body,
440  std::string body_name = "");
441 
452  unsigned int GetBodyId(const char* body_name) const
453  {
454  if (mBodyNameMap.count(body_name) == 0)
455  {
456  return std::numeric_limits<unsigned int>::max();
457  }
458 
459  return mBodyNameMap.find(body_name)->second;
460  }
461 
467  ReferenceFramePtr getReferenceFrame(const std::string& frameName) const
468  {
469  ReferenceFramePtr frame;
470  try
471  {
472  frame = referenceFrameMap.at(frameName);
473  }
474  catch (const std::out_of_range& e)
475  {
476  frame = nullptr;
477  }
478 
479  return frame;
480  }
481 
483  std::string GetBodyName(unsigned int body_id) const
484  {
485  std::map<std::string, unsigned int>::const_iterator iter = mBodyNameMap.begin();
486 
487  while (iter != mBodyNameMap.end())
488  {
489  if (iter->second == body_id)
490  {
491  return iter->first;
492  }
493 
494  ++iter;
495  }
496 
497  return "";
498  }
499 
502  bool IsFixedBodyId(unsigned int body_id) const
503  {
504  if ((body_id >= fixed_body_discriminator) && (body_id < std::numeric_limits<unsigned int>::max()) && (body_id - fixed_body_discriminator < mFixedBodies.size()))
505  {
506  return true;
507  }
508  return false;
509  }
510 
511  bool IsBodyId(unsigned int id) const
512  {
513  if ((id > 0) && (id < mBodies.size()))
514  {
515  return true;
516  }
517 
518  if ((id >= fixed_body_discriminator) && (id < std::numeric_limits<unsigned int>::max()))
519  {
520  if (id - fixed_body_discriminator < mFixedBodies.size())
521  {
522  return true;
523  }
524  }
525  return false;
526  }
527 
535  unsigned int GetParentBodyId(unsigned int id)
536  {
537  if (id >= fixed_body_discriminator)
538  {
539  return mFixedBodies[id - fixed_body_discriminator].mMovableParent;
540  }
541 
542  unsigned int parent_id = lambda[id];
543 
544  while (mBodies[parent_id].mIsVirtual)
545  {
546  parent_id = lambda[parent_id];
547  }
548 
549  return parent_id;
550  }
551 
557  {
558  if (id >= fixed_body_discriminator)
559  {
560  return mFixedBodies[id - fixed_body_discriminator].mParentTransform;
561  }
562 
563  unsigned int child_id = id;
564  unsigned int parent_id = lambda[id];
565 
566  if (mBodies[parent_id].mIsVirtual)
567  {
568  while (mBodies[parent_id].mIsVirtual)
569  {
570  child_id = parent_id;
571  parent_id = lambda[child_id];
572  }
573  return X_T[child_id];
574  }
575  else
576  {
577  return X_T[id];
578  }
579  }
580 
584  void SetJointFrame(unsigned int id, const Math::SpatialTransform& transform)
585  {
586  if (id >= fixed_body_discriminator)
587  {
588  throw RdlException("Error: setting of parent transform not supported for fixed bodies!");
589  }
590 
591  unsigned int child_id = id;
592  unsigned int parent_id = lambda[id];
593 
594  if (mBodies[parent_id].mIsVirtual)
595  {
596  while (mBodies[parent_id].mIsVirtual)
597  {
598  child_id = parent_id;
599  parent_id = lambda[child_id];
600  }
601  X_T[child_id] = transform;
602  }
603  else if (id > 0)
604  {
605  X_T[id] = transform;
606  }
607  }
608 
615  Math::Quaternion GetQuaternion(unsigned int i, const Math::VectorNd& Q) const
616  {
617  assert(mJoints[i].mJointType == JointTypeSpherical);
618  unsigned int q_index = mJoints[i].q_index;
619  return Math::Quaternion(Q[q_index], Q[q_index + 1], Q[q_index + 2], Q[multdof3_w_index[i]]);
620  }
621 
628  void SetQuaternion(unsigned int i, const Math::Quaternion& quat, Math::VectorNd& Q) const
629  {
630  assert(mJoints[i].mJointType == JointTypeSpherical);
631  unsigned int q_index = mJoints[i].q_index;
632 
633  Q[q_index] = quat[0];
634  Q[q_index + 1] = quat[1];
635  Q[q_index + 2] = quat[2];
636  Q[multdof3_w_index[i]] = quat[3];
637  }
638 
639  unsigned int getCommonMovableParentId(unsigned int id_1, unsigned int id_2) const
640  {
641  if (IsFixedBodyId(id_1))
642  {
643  id_1 = mFixedBodies[id_1 - fixed_body_discriminator].mMovableParent;
644  }
645 
646  if (IsFixedBodyId(id_2))
647  {
648  id_2 = mFixedBodies[id_2 - fixed_body_discriminator].mMovableParent;
649  }
650 
651  if (id_1 == id_2)
652  {
653  return id_1;
654  }
655 
656  if (id_1 == 0 || id_2 == 0)
657  {
658  return 0;
659  }
660 
661  unsigned int chain_1_size = lambda_chain[id_1].size();
662  unsigned int chain_2_size = lambda_chain[id_2].size();
663 
664  if (chain_1_size <= chain_2_size)
665  {
666  // Can start at 1 bc every list should start with world body id which is zero
667  for (unsigned int i = 1; i < chain_1_size; i++)
668  {
669  if (lambda_chain[id_1][i] != lambda_chain[id_2][i])
670  {
671  return lambda_chain[id_1][i - 1];
672  }
673  }
674 
675  return lambda_chain[id_1][chain_1_size - 1];
676  }
677  else
678  {
679  // Can start at 1 bc every list should start with world body id which is zero
680  for (unsigned int i = 1; i < chain_2_size; i++)
681  {
682  if (lambda_chain[id_1][i] != lambda_chain[id_2][i])
683  {
684  return lambda_chain[id_2][i - 1];
685  }
686  }
687 
688  return lambda_chain[id_2][chain_2_size - 1];
689  }
690  }
691 
692  void crawlChainKinematics(unsigned int b_id, std::atomic<unsigned int>* branch_ends, const Math::VectorNd* Q, const Math::VectorNd* QDot,
693  const Math::VectorNd* QDDot);
694 
695  private:
696  bool validateRigidBodyInertia(const Body& body)
697  {
698  if (body.mIsVirtual)
699  {
700  // don't care about virtual bodies really
701  return true;
702  }
703 
705  if (rbi(0, 0) <= 0 || rbi(1, 1) <= 0 || rbi(2, 2) <= 0)
706  {
707  std::cerr << "\033[1;31m Invalid inertia: Each element of the trace must be > 0 \033[0m" << std::endl;
708  return false;
709  }
710 
711  if (rbi(0, 0) >= (rbi(1, 1) + rbi(2, 2)))
712  {
713  std::cerr << "\033[1;31m Invalid inertia: Triangle inequality not satisfied \033[0m\n" << std::endl;
714  return false;
715  }
716 
717  if (rbi(1, 1) >= (rbi(2, 2) + rbi(0, 0)))
718  {
719  std::cerr << "\033[1;31m Invalid inertia: Triangle inequality not satisfied \033[0m\n" << std::endl;
720  return false;
721  }
722 
723  if (rbi(2, 2) >= (rbi(1, 1) + rbi(0, 0)))
724  {
725  std::cerr << "\033[1;31m Invalid inertia: Triangle inequality not satisfied \033[0m\n" << std::endl;
726  return false;
727  }
728 
729  if (!(rbi - rbi.transpose()).isZero(1.e-8))
730  {
731  std::cerr << "\033[1;31m Invalid inertia: Inertia matrix is not symmetric \033[0m\n" << std::endl;
732  return false;
733  }
734 
735  Eigen::EigenSolver<Eigen::Matrix3d> solver(rbi);
736  Eigen::EigenSolver<Eigen::Matrix3d>::EigenvalueType eivals = solver.eigenvalues();
737 
738  for (unsigned int i = 0; i < eivals.rows(); i++)
739  {
740  if (eivals[i].real() <= 0)
741  {
742  std::cerr << "\033[1;31m Invalid inertia: Inertia matrix is not positive definite \033[0m\n" << std::endl;
743  return false;
744  }
745  }
746 
747  return true;
748  }
749 };
750 typedef std::shared_ptr<Model> ModelPtr;
751 } // namespace RobotDynamics
752 
753 #endif
Definition: rdl_eigenmath.hpp:104
Definition: MotionVector.hpp:21
Quaternion that are used for singularity free joints.
Definition: rdl_eigenmath.hpp:614
A custom exception.
Definition: RdlExceptions.hpp:18
std::shared_ptr< ReferenceFrame > ReferenceFramePtr
Definition: ReferenceFrame.hpp:68
std::vector< SpatialMotion, Eigen::aligned_allocator< SpatialMotion > > SpatialMotionV
Definition: SpatialMotion.hpp:263
std::vector< SpatialForce, Eigen::aligned_allocator< SpatialForce > > SpatialForceV
Definition: SpatialForce.hpp:252
std::vector< MotionVector, Eigen::aligned_allocator< MotionVector > > MotionVectorV
Definition: MotionVector.hpp:347
std::vector< SpatialInertia, Eigen::aligned_allocator< SpatialInertia > > SpatialInertiaV
Definition: SpatialRigidBodyInertia.hpp:144
Eigen::VectorXd VectorNd
Definition: rdl_eigenmath.hpp:20
std::vector< SpatialAcceleration, Eigen::aligned_allocator< SpatialAcceleration > > SpatialAccelerationV
Definition: SpatialAcceleration.hpp:154
std::vector< RigidBodyInertia, Eigen::aligned_allocator< RigidBodyInertia > > RigidBodyInertiaV
Definition: RigidBodyInertia.hpp:285
Eigen::MatrixXd MatrixNd
Definition: rdl_eigenmath.hpp:21
Namespace for all structures of the RobotDynamics library.
Definition: examples.hpp:19
@ JointTypeSpherical
3 DoF joint using Quaternions for joint positional variables and
Definition: Joint.hpp:189
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:750
Describes all properties of a single body.
Definition: Body.hpp:88
Math::Matrix3d mInertia
Inertia matrix at the center of mass.
Definition: Body.hpp:350
bool mIsVirtual
Definition: Body.hpp:356
CustomJoint is a struct used to create a joint with user defined parameters. This is accomplished by ...
Definition: Joint.hpp:657
Describes a joint relative to the predecessor body.
Definition: Joint.hpp:223
Compact representation of spatial transformations.
Definition: rdl_eigenmath.hpp:412
Contains all information about the rigid body model.
Definition: Model.hpp:112
Model(const rclcpp::Node::SharedPtr &n=nullptr, unsigned int *n_threads=nullptr)
Constructor.
Definition: Model.cpp:35
Math::SpatialMotionV v
Definition: Model.hpp:211
std::vector< unsigned int > mJointUpdateOrder
Definition: Model.hpp:230
std::vector< Math::SpatialVector > c
The velocity dependent spatial acceleration.
Definition: Model.hpp:257
std::vector< std::vector< unsigned int > > lambda_chain
Definition: Model.hpp:161
std::vector< Math::Vector3d > multdof3_u
Definition: Model.hpp:248
boost::asio::io_service io_service
Definition: Model.hpp:348
std::vector< CustomJoint * > mCustomJoints
Definition: Model.hpp:251
Math::SpatialTransform GetJointFrame(unsigned int id)
Returns the joint frame transformtion, i.e. the second argument to Model::addBody().
Definition: Model.hpp:556
std::vector< FixedBody > mFixedBodies
All bodies that are attached to a body via a fixed joint.
Definition: Model.hpp:310
~Model()
Definition: Model.hpp:121
unsigned int qdot_size
The size of the.
Definition: Model.hpp:191
boost::thread_group thread_pool
Definition: Model.hpp:351
bool IsBodyId(unsigned int id) const
Definition: Model.hpp:511
unsigned int getCommonMovableParentId(unsigned int id_1, unsigned int id_2) const
Definition: Model.hpp:639
std::vector< Math::SpatialMatrix > I_H
Definition: Model.hpp:282
Math::MotionVector gravity
the cartesian vector of the gravity
Definition: Model.hpp:202
ReferenceFramePtr cobFrame
Definition: Model.hpp:346
Math::MatrixNd ndof0_mat
Definition: Model.hpp:293
std::vector< Math::SpatialTransform > X_J
Definition: Model.hpp:224
std::unique_ptr< boost::asio::io_service::work > work
Definition: Model.hpp:349
rclcpp::Node::SharedPtr node
Definition: Model.hpp:353
Math::SpatialForceV pA
The spatial bias force.
Definition: Model.hpp:263
std::vector< ReferenceFramePtr > bodyFrames
Definition: Model.hpp:145
std::vector< Body > mBodies
All bodies 0 ... N_B, including the base.
Definition: Model.hpp:333
double fluidDensity
Definition: Model.hpp:203
std::vector< Math::SpatialTransform > X_lambda
Transformation from the parent body to the current body.
Definition: Model.hpp:307
rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr callback_handle
Definition: Model.hpp:354
Math::SpatialForceV f
Internal forces on the body (used only InverseDynamics())
Definition: Model.hpp:275
Math::Quaternion GetQuaternion(unsigned int i, const Math::VectorNd &Q) const
Gets the quaternion for body i (only valid if body i is connected by a JointTypeSpherical joint)
Definition: Model.hpp:615
std::vector< unsigned int > mFixedJointCount
The number of fixed joints that have been declared before each joint.
Definition: Model.hpp:238
std::vector< Math::Matrix3d > multdof3_Dinv
Definition: Model.hpp:247
unsigned int GetParentBodyId(unsigned int id)
Determines id the actual parent body.
Definition: Model.hpp:535
bool validateRigidBodyInertia(const Body &body)
Definition: Model.hpp:696
Math::MotionVectorV S_o
Definition: Model.hpp:221
std::vector< Math::SpatialMatrix > I_add
Definition: Model.hpp:281
void setupRosParameters()
Call this after the model is fully populated to declare ros parameters that define the mass parameter...
Definition: Model.cpp:615
Math::VectorNd d
Temporary variable D_i (RBDA p. 130)
Definition: Model.hpp:269
ReferenceFramePtr worldFrame
Definition: Model.hpp:141
unsigned int GetBodyId(const char *body_name) const
Returns the id of a body that was passed to addBody()
Definition: Model.hpp:452
void SetQuaternion(unsigned int i, const Math::Quaternion &quat, Math::VectorNd &Q) const
Sets the quaternion for body i (only valid if body i is connected by a JointTypeSpherical joint)
Definition: Model.hpp:628
Math::MotionVectorV S
Definition: Model.hpp:220
ReferenceFramePtr comFrame
Definition: Model.hpp:343
Math::MotionVector a_f
Definition: Model.hpp:204
std::vector< boost::thread * > threads
Definition: Model.hpp:350
std::vector< unsigned int > lambda
Definition: Model.hpp:160
bool setThreadParameters(int policy, struct sched_param param)
Definition: Model.hpp:358
Math::VectorNd ndof0_vec
Definition: Model.hpp:296
Math::VectorNd nbodies0_vec
Definition: Model.hpp:297
unsigned int addBody(const unsigned int parent_id, const Math::SpatialTransform &joint_frame, const Joint &joint, const Body &body, std::string body_name="")
Connects a given body to the model.
Definition: Model.cpp:328
std::map< std::string, unsigned int > mBodyNameMap
Human readable names for the bodies.
Definition: Model.hpp:336
std::vector< Math::Matrix63 > multdof3_S
Motion subspace for joints with 3 degrees of freedom.
Definition: Model.hpp:244
std::vector< Math::SpatialTransform > X_T
Transformations from the parent body to the frame of the joint.
Definition: Model.hpp:234
std::vector< Math::Matrix63 > multdof3_U
Definition: Model.hpp:246
Math::MotionVector v_f
Definition: Model.hpp:205
std::vector< ReferenceFramePtr > bodyCenterOfBuoyancyFrames
Definition: Model.hpp:154
std::vector< Math::SpatialMatrix > IA
The spatial inertia of the bodies.
Definition: Model.hpp:260
unsigned int num_branch_ends
Definition: Model.hpp:340
ReferenceFramePtr getReferenceFrame(const std::string &frameName) const
Get a fixed or moveable body's reference frame.
Definition: Model.hpp:467
std::shared_ptr< Model > SharedPtr
Definition: Model.hpp:113
unsigned int addBodySphericalJoint(const unsigned int parent_id, const Math::SpatialTransform &joint_frame, const Joint &joint, const Body &body, std::string body_name="")
std::vector< ReferenceFramePtr > fixedBodyFrames
Definition: Model.hpp:158
Math::SpatialForceV f_b
Definition: Model.hpp:276
std::vector< Math::Matrix63 > multdof3_S_o
Definition: Model.hpp:245
Math::SpatialAccelerationV a
The spatial velocity of the bodies.
Definition: Model.hpp:209
unsigned int fixed_body_discriminator
Value that is used to discriminate between fixed and movable bodies.
Definition: Model.hpp:324
Math::RigidBodyInertiaV Ic
Definition: Model.hpp:279
std::vector< ReferenceFramePtr > bodyCenteredFrames
Definition: Model.hpp:152
Math::MatrixNd three_x_qd0
Definition: Model.hpp:294
void operator=(const Model &)=delete
std::vector< Math::SpatialVector > U
Temporary variable U_i (RBDA p. 130)
Definition: Model.hpp:266
bool IsFixedBodyId(unsigned int body_id) const
Checks whether the body is rigidly attached to another body.
Definition: Model.hpp:502
void crawlChainKinematics(unsigned int b_id, std::atomic< unsigned int > *branch_ends, const Math::VectorNd *Q, const Math::VectorNd *QDot, const Math::VectorNd *QDDot)
Definition: Model.cpp:1534
unsigned int dof_count
number of degrees of freedoms of the model
Definition: Model.hpp:173
unsigned int q_size
The size of the -vector. For models without spherical joints the value is the same as Model::dof_coun...
Definition: Model.hpp:182
Model(const Model &)=delete
Math::VectorNd q0_vec
Definition: Model.hpp:295
std::string GetBodyName(unsigned int body_id) const
Returns the name of a body for a given body id.
Definition: Model.hpp:483
std::vector< Joint > mJoints
All joints.
Definition: Model.hpp:218
std::vector< std::vector< unsigned int > > mu
Definition: Model.hpp:166
std::vector< Math::Momentum > hc
Definition: Model.hpp:287
std::vector< unsigned int > lambda_q
Definition: Model.hpp:163
std::vector< Math::SpatialVector > c_J
Definition: Model.hpp:226
unsigned int appendBody(const Math::SpatialTransform &joint_frame, const Joint &joint, const Body &body, std::string body_name="")
Adds a Body to the model such that the previously added Body is the Parent.
Definition: Model.cpp:593
Math::SpatialInertiaV Ib_c
Definition: Model.hpp:285
unsigned int addBodyCustomJoint(const unsigned int parent_id, const Math::SpatialTransform &joint_frame, CustomJoint *custom_joint, const Body &body, std::string body_name="")
Definition: Model.cpp:598
std::map< std::string, ReferenceFramePtr > referenceFrameMap
Definition: Model.hpp:339
rcl_interfaces::msg::SetParametersResult paramCb(const std::vector< rclcpp::Parameter > &parameters)
Definition: Model.cpp:952
void SetJointFrame(unsigned int id, const Math::SpatialTransform &transform)
Sets the joint frame transformtion, i.e. the second argument to Model::addBody().
Definition: Model.hpp:584
Math::VectorNd u
Temporary variable u (RBDA p. 130)
Definition: Model.hpp:272
double mass
Definition: Model.hpp:194
unsigned int previously_added_body_id
Id of the previously added body, required for Model::appendBody()
Definition: Model.hpp:199
Math::SpatialInertiaV I
Definition: Model.hpp:278
std::vector< Math::SpatialMatrix > Ic_H
Definition: Model.hpp:283
std::vector< unsigned int > multdof3_w_index
Definition: Model.hpp:249
Math::SpatialMotionV v_J
Definition: Model.hpp:228
double volume
Definition: Model.hpp:196