humoto
model.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4  @copyright 2014-2017 INRIA. Licensed under the Apache License, Version 2.0.
5  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
6 
7  @brief
8 */
9 
10 #pragma once
11 
12 namespace humoto
13 {
14  namespace rbdl
15  {
16  /**
17  * @brief Parameters of the model.
18  */
20  {
21  public:
22  // RBDL parameter
24 
25  public:
27  {
28  floating_base_ = true;
29  }
30  };
31 
32 
33 
34  /**
35  * @brief Wraps RBDL model and provides additional functionality.
36  */
38  {
39  public:
41  RigidBodyDynamics::Model rbdl_model_;
42  double total_mass_;
43 
44 
45  public:
46  /**
47  * @brief Default constructor. It is necesary to load() model
48  * before using.
49  */
51  {
52  setDefaults();
53  }
54 
55 
56  /**
57  * @brief Construct using URDF model
58  *
59  * @param[in] urdf_filename
60  */
61  explicit Model(const std::string & urdf_filename)
62  {
63  load(urdf_filename);
64  }
65 
66 
67  /**
68  * @brief Construct using URDF model
69  *
70  * @param[in] model_parameters
71  * @param[in] urdf_filename
72  */
73  Model( const ModelParameters & model_parameters,
74  const std::string & urdf_filename)
75  {
76  load(model_parameters, urdf_filename);
77  }
78 
79 
80  /**
81  * @brief Load URDF model.
82  *
83  * @param[in] model_parameters
84  * @param[in] urdf_filename
85  */
86  void load( const ModelParameters & model_parameters,
87  const std::string & urdf_filename)
88  {
89  model_parameters_ = model_parameters;
90  load(urdf_filename);
91  }
92 
93 
94  /**
95  * @brief Load URDF model.
96  *
97  * @param[in] urdf_filename
98  */
99  void load(const std::string & urdf_filename)
100  {
101  setDefaults();
102 
103  bool rbdl_status = RigidBodyDynamics::Addons::URDFReadFromFile(
104  urdf_filename.c_str(),
105  &rbdl_model_,
106  model_parameters_.floating_base_,
107  false);
108  if (false == rbdl_status)
109  {
110  HUMOTO_THROW_MSG(std::string("Failed to load URDF model: ") + urdf_filename);
111  }
112 
113  total_mass_ = 0.0;
114  for (std::size_t i = 1; i < rbdl_model_.mBodies.size(); ++i)
115  {
116  total_mass_ += rbdl_model_.mBodies[i].mMass;
117  }
118 
119  joint_data_.resize(rbdl_model_.mJoints.size());
120  }
121 
122 
123  /**
124  * @brief Update model
125  *
126  * @param[in] joint_angles new joint angles
127  */
128  void update(const Eigen::VectorXd & joint_angles)
129  {
130  RigidBodyDynamics::UpdateKinematicsCustom(rbdl_model_, &joint_angles, NULL, NULL);
131  for (std::size_t i = 0; i < joint_data_.size(); ++i)
132  {
133  joint_data_[i].compute(rbdl_model_, i);
134  }
135  }
136 
137 
138  /**
139  * @brief Return number of DoF
140  *
141  * @return number of DoF
142  */
143  std::size_t getDOFNumber() const
144  {
145  return(rbdl_model_.q_size);
146  }
147 
148 
149 
150  // get*Tag
151  /**
152  * @brief Tag for a link
153  *
154  * @param[in] link_string_id
155  *
156  * @return tag
157  */
158  TagLinkPtr getLinkTag(const std::string &link_string_id) const
159  {
160  boost::shared_ptr<TagLink> ptr(new TagLink(getLinkId(link_string_id)));
161  return(ptr);
162  }
163 
164 
165  /**
166  * @brief Tag for a point on a link
167  *
168  * @param[in] link_string_id
169  * @param[in] position_local position of the point in the local frame
170  *
171  * @return tag
172  */
173  TagPointPtr getPointTag(const std::string &link_string_id,
174  const etools::Vector3 &position_local) const
175  {
176  boost::shared_ptr<TagPoint> ptr(new TagPoint( getLinkId(link_string_id),
177  position_local));
178  return(ptr);
179  }
180 
181 
182  /**
183  * @brief Tag for the CoM of a link
184  *
185  * @param[in] link_string_id
186  *
187  * @return tag
188  */
189  TagPointPtr getLinkCoMTag(const std::string &link_string_id) const
190  {
191  LinkId id = getLinkId(link_string_id);
192  boost::shared_ptr<TagPoint> ptr(new TagPoint( id,
193  rbdl_model_.mBodies[id].mCenterOfMass));
194  return(ptr);
195  }
196 
197 
198  /**
199  * @brief CoM Tag for several bodies
200  *
201  * @param[in] link_string_ids
202  *
203  * @return tag
204  */
205  TagPartialCoMPtr getCoMTag(const std::vector<std::string> &link_string_ids) const
206  {
207  std::vector<LinkId> link_ids;
208  double total_mass = 0.0;
209 
210  link_ids.resize(link_string_ids.size());
211 
212  for (std::size_t i = 0; i < link_ids.size(); ++i)
213  {
214  link_ids[i] = getLinkId(link_string_ids[i]);
215 
216  total_mass += rbdl_model_.mBodies[link_ids[i]].mMass;
217  }
218 
219  boost::shared_ptr<TagPartialCoM> ptr(new TagPartialCoM(link_ids, total_mass));
220  return(ptr);
221  }
222 
223 
224  /**
225  * @brief CoM tag
226  *
227  * @return tag
228  */
230  {
231  boost::shared_ptr<TagCoM> ptr(new TagCoM());
232  return(ptr);
233  }
234 
235 
236  // getTagPosition
237  /**
238  * @brief Get CoM of several bodies
239  *
240  * @param[in] tag CoM tag
241  *
242  * @return CoM position
243  */
244  etools::Vector3 getTagPosition(const TagPartialCoMPtr tag) const
245  {
246  etools::Vector3 com_position;
247 
248  com_position.setZero(3);
249 
250  for (std::size_t i = 0; i < tag->link_ids_.size(); ++i)
251  {
252  LinkId id = tag->link_ids_[i];
253 
254  com_position.noalias() +=
255  rbdl_model_.mBodies[id].mMass
256  * getPointTagPosition(id, rbdl_model_.mBodies[id].mCenterOfMass);
257 
258  /*
259  com_position.noalias() +=
260  rbdl_model_.X_base[id].applyTranspose(rbdl_model_.I[id]).h;
261  */
262  }
263 
264  com_position /= tag->mass_;
265  return (com_position);
266  }
267 
268 
269  /**
270  * @brief Get position of a tag
271  *
272  * @param[in] tag
273  *
274  * @return 3d position vector
275  */
276  etools::Vector3 getTagPosition(const TagLinkPtr tag) const
277  {
278  return(getLinkTransform(tag->link_id_).r);
279  }
280 
281 
282  /**
283  * @brief Get position of a tag
284  *
285  * @param[in] tag
286  *
287  * @return 3d position vector
288  */
289  etools::Vector3 getTagPosition( const TagPointPtr tag) const
290  {
291  return(getPointTagPosition(tag->link_id_, tag->local_position_));
292  }
293 
294 
295 
296  /**
297  * @brief Get CoM of the robot
298  *
299  * @param[in] tag
300  *
301  * @return total mass
302  */
303  etools::Vector3 getTagPosition(const TagCoMPtr tag) const
304  {
305  etools::Vector3 com_position;
306 
307  com_position.setZero(3);
308 
309  for (std::size_t i = 1; i < rbdl_model_.mBodies.size(); ++i)
310  {
311  com_position.noalias() +=
312  rbdl_model_.mBodies[i].mMass
313  * getPointTagPosition(i, rbdl_model_.mBodies[i].mCenterOfMass);
314  }
315 
316  com_position /= total_mass_;
317 
318  return (com_position);
319  }
320 
321 
322  // getTagOrientation
323 
324  /**
325  * @brief Get orientation of a tag
326  *
327  * @param[in] tag
328  *
329  * @return 3x3 matrix
330  */
332  {
333  return(getLinkTransform(tag->link_id_).E.transpose());
334  }
335 
336 
337  /**
338  * @brief Get orientation of a tag
339  *
340  * @param[in] tag
341  *
342  * @return 3x3 matrix
343  */
345  {
346  return ( getTagOrientation(TagLinkPtr (new TagLink(tag->link_id_))) );
347  }
348 
349 
350  // getTagPose
351  /**
352  * @brief Get tag pose
353  *
354  * @param[in] tag
355  *
356  * @return 3x3 matrix
357  */
359  {
361 
362  RigidBodyDynamics::Math::SpatialTransform mBaseTransform = getLinkTransform(tag->link_id_);
363 
364  pose.position_ = mBaseTransform.r;
365  pose.rpy_ = rigidbody::convertMatrixToEulerAngles(mBaseTransform.E.transpose(),
367 
368  return (pose);
369  }
370 
371 
372  /**
373  * @brief Get tag pose
374  *
375  * @param[in] tag
376  *
377  * @return 3x3 matrix
378  */
380  {
382 
383  RigidBodyDynamics::Math::SpatialTransform mBaseTransform = getLinkTransform(tag->link_id_);
384 
385  pose.position_ = mBaseTransform.E.transpose() * tag->local_position_ + mBaseTransform.r;
386  pose.rpy_ = rigidbody::convertMatrixToEulerAngles(mBaseTransform.E.transpose(),
388 
389  return (pose);
390  }
391 
392 
393  // getTagMass
394  /**
395  * @brief Get mass
396  *
397  * @param[in] tag
398  *
399  * @return mass
400  */
401  double getTagMass(const TagCoMPtr tag) const
402  {
403  return (total_mass_);
404  }
405 
406 
407  /**
408  * @brief Get mass
409  *
410  * @param[in] tag CoM tag
411  *
412  * @return total mass of the bodies
413  */
414  double getTagMass(const TagPartialCoMPtr tag) const
415  {
416  return (tag->mass_);
417  }
418 
419 
420  /**
421  * @brief Get mass
422  *
423  * @param[in] tag CoM tag
424  *
425  * @return total mass of the bodies
426  */
427  double getTagMass(const TagLinkPtr tag) const
428  {
429  return (rbdl_model_.mBodies[tag->link_id_].mMass);
430  }
431 
432 
433  // getTagJacobian
434  /**
435  * @brief Get CoM jacbian for a set of bodies
436  *
437  * @param[out] jacobian
438  * @param[in] tag
439  */
440  void getTagJacobian(Eigen::MatrixXd &jacobian,
441  const TagPartialCoMPtr tag) const
442  {
443  Eigen::VectorXd q;
444  Eigen::MatrixXd jacobian_i;
445 
446 
447  for (std::size_t i = 0; i < tag->link_ids_.size(); ++i)
448  {
449  LinkId id = tag->link_ids_[i];
450 
451  getTagJacobian<SpatialType::TRANSLATION>(jacobian_i, id, rbdl_model_.mBodies[id].mCenterOfMass);
452 
453  if (i == 0)
454  {
455  jacobian.noalias() = jacobian_i * rbdl_model_.mBodies[id].mMass;
456  }
457  else
458  {
459  jacobian.noalias() += jacobian_i * rbdl_model_.mBodies[id].mMass;
460  }
461  }
462 
463  jacobian /= tag->mass_;
464  }
465 
466 
467  /**
468  * @brief Get Jacobian for a specific tag.
469  *
470  * @param[out] jacobian
471  * @param[in] tag
472  *
473  * @attention Based on CalcPointJacobian() function from RBDL.
474  */
475  template<SpatialType::Type t_jacobian_type>
476  void getTagJacobian( Eigen::MatrixXd &jacobian,
477  const TagLinkPtr tag) const
478  {
479  getTagJacobian<t_jacobian_type>(jacobian, tag->link_id_, etools::Vector3::Zero());
480  }
481 
482 
483  /**
484  * @brief Get Jacobian for a specific tag.
485  *
486  * @param[out] jacobian
487  * @param[in] tag
488  *
489  * @attention Based on CalcPointJacobian() function from RBDL.
490  */
491  template<SpatialType::Type t_jacobian_type>
492  void getTagJacobian( Eigen::MatrixXd &jacobian,
493  const TagPointPtr tag) const
494  {
495  getTagJacobian<t_jacobian_type>(jacobian, tag->link_id_, tag->local_position_);
496  }
497 
498 
499 
500  /**
501  * @brief Compute CoM Jacobian of the robot
502  *
503  * @param[out] jacobian
504  * @param[in] tag
505  */
506  void getTagJacobian(Eigen::MatrixXd &jacobian,
507  const TagCoMPtr tag) const
508  {
509  Eigen::MatrixXd jacobian_i;
510 
511 
512  for (std::size_t i = 1; i < rbdl_model_.mBodies.size(); ++i)
513  {
514  getTagJacobian<SpatialType::TRANSLATION>(jacobian_i, i, rbdl_model_.mBodies[i].mCenterOfMass);
515 
516  if (i == 1)
517  {
518  jacobian.noalias() = jacobian_i*rbdl_model_.mBodies[i].mMass;
519  }
520  else
521  {
522  jacobian.noalias() += jacobian_i*rbdl_model_.mBodies[i].mMass;
523  }
524  }
525 
526  jacobian /= total_mass_;
527  }
528 
529 
530 
531 #if defined(HUMOTO_BUILD_TESTS) || defined(HUMOTO_BUILD_REGRESSION_TESTS)
532  /**
533  * @brief Compute CoM position using RBDL functions
534  *
535  * @param[out] com_position
536  *
537  * @return total mass
538  *
539  * @attention This method should be used in tests only.
540  */
541  double getCoMRBDL(etools::Vector3 &com_position)
542  {
543  double mass;
544  RigidBodyDynamics::Math::Vector3d com;
545  Eigen::VectorXd q, dq;
546 
547  RigidBodyDynamics::Utils::CalcCenterOfMass(
548  rbdl_model_,
549  q,
550  dq,
551  mass,
552  com,
553  NULL,
554  NULL,
555  false);
556  com_position = com;
557 
558  return (mass);
559  }
560 
561 
562  /**
563  * @brief Compute CoM Jacobian using RBDL functions
564  *
565  * @param[out] jacobian
566  *
567  * @attention This method should be used in tests only.
568  */
569  void getCoMJacobianRBDL(Eigen::MatrixXd &jacobian)
570  {
571  Eigen::VectorXd q;
572  Eigen::MatrixXd jacobian_i;
573 
574 
575  for (std::size_t i = 1; i < rbdl_model_.mBodies.size(); ++i)
576  {
577  jacobian_i.setZero(3, getDOFNumber());
578  RigidBodyDynamics::CalcPointJacobian (
579  rbdl_model_,
580  q,
581  i,
582  rbdl_model_.mBodies[i].mCenterOfMass,
583  jacobian_i,
584  false);
585 
586  if (i == 1)
587  {
588  jacobian.noalias() = jacobian_i*rbdl_model_.mBodies[i].mMass;
589  }
590  else
591  {
592  jacobian.noalias() += jacobian_i*rbdl_model_.mBodies[i].mMass;
593  }
594  }
595 
596  jacobian /= total_mass_;
597  }
598 
599 
600  /**
601  * @brief Compute CoM Jacobian for a set of bodies using RBDL
602  * functions
603  *
604  * @param[out] jacobian
605  * @param[in] ids
606  *
607  * @attention This method should be used in tests only.
608  */
609  void getCoMJacobianRBDL(Eigen::MatrixXd &jacobian,
610  const IndexVector &ids)
611  {
612  double total_mass = 0;
613  Eigen::VectorXd q;
614  Eigen::MatrixXd jacobian_i;
615 
616 
617  for (EigenIndex i = 0; i < ids.size(); ++i)
618  {
619  std::size_t id = ids(i);
620  double mass = rbdl_model_.mBodies[id].mMass;
621  total_mass += mass;
622 
623  jacobian_i.setZero(3, getDOFNumber());
624  RigidBodyDynamics::CalcPointJacobian (
625  rbdl_model_,
626  q,
627  id,
628  rbdl_model_.mBodies[id].mCenterOfMass,
629  jacobian_i,
630  false);
631 
632  if (i == 0)
633  {
634  jacobian.noalias() = jacobian_i*mass;
635  }
636  else
637  {
638  jacobian.noalias() += jacobian_i*mass;
639  }
640  }
641 
642  jacobian /= total_mass;
643  }
644 #endif
645 
646  private:
647  /**
648  * @brief Stores precomputed data for each joint.
649  */
651  {
652  public:
653  Eigen::MatrixXd transformed_joint_axis_;
655 
656 
657  public:
658  /**
659  * @brief Computes data for a given joint
660  *
661  * @param[in] rbdl_model
662  * @param[in] joint_id
663  */
664  void compute( const RigidBodyDynamics::Model & rbdl_model,
665  const unsigned int joint_id)
666  {
667  if(rbdl_model.mJoints[joint_id].mJointType != RigidBodyDynamics::JointTypeCustom)
668  {
669  dof_number_ = rbdl_model.mJoints[joint_id].mDoFCount;
670 
671  switch(dof_number_)
672  {
673  case 1:
674  transformed_joint_axis_ = rbdl_model.X_base[joint_id].inverse().apply(rbdl_model.S[joint_id]);
675  break;
676  case 3:
677  transformed_joint_axis_ = rbdl_model.X_base[joint_id].inverse().toMatrix()
678  * rbdl_model.multdof3_S[joint_id];
679  break;
680  default:
681  // Skip this : why?
682  break;
683  }
684  }
685  else
686  {
687  unsigned int k = rbdl_model.mJoints[joint_id].custom_joint_index;
688 
689  dof_number_ = rbdl_model.mCustomJoints[k]->mDoFCount;
690  transformed_joint_axis_ = rbdl_model.X_base[joint_id].inverse().toMatrix()
691  * rbdl_model.mCustomJoints[k]->S;
692  }
693  }
694  };
695 
696  private:
697  std::vector<JointData> joint_data_;
698 
699 
700  private:
701  /**
702  * @brief Initialization
703  */
704  void setDefaults()
705  {
706  total_mass_ = 0.0;
707  }
708 
709 
710  /**
711  * @brief True if a body is fixed to its parent
712  *
713  * @param[in] link_id
714  *
715  * @return true/false
716  *
717  * @attention Based on IsFixedLinkId() function from RBDL.
718  */
719  bool isLinkFixed (const std::size_t link_id) const
720  {
721  if ( ( link_id >= rbdl_model_.fixed_body_discriminator )
722  && ( link_id < std::numeric_limits<unsigned int>::max() )
723  && ( link_id - rbdl_model_.fixed_body_discriminator < rbdl_model_.mFixedBodies.size() ) )
724  {
725  return (true);
726  }
727  else
728  {
729  return (false);
730  }
731  }
732 
733 
734 
735  /**
736  * @brief Determines id of a body based on its string id.
737  *
738  * @param[in] string_id
739  *
740  * @return id
741  */
742  std::size_t getLinkId(const std::string &string_id) const
743  {
744  return (rbdl_model_.GetBodyId(string_id.c_str()));
745  }
746 
747 
748 
749  /**
750  * @brief Express local position in root frame
751  *
752  * @param[in] link_id
753  * @param[in] point_body_coordinates
754  *
755  * @return 3d vector
756  *
757  * @attention Based on CalcBodyToBaseCoordinates() function from RBDL.
758  */
759  etools::Vector3 expressInRootFrame(
760  const std::size_t link_id,
761  const etools::Vector3 &point_body_coordinates) const
762  {
763  if (isLinkFixed(link_id))
764  {
765  unsigned int flink_id = link_id - rbdl_model_.fixed_body_discriminator;
766  unsigned int parent_id = rbdl_model_.mFixedBodies[flink_id].mMovableParent;
767 
768  etools::Matrix3 fixed_rotation = rbdl_model_.mFixedBodies[flink_id].mParentTransform.E.transpose();
769  etools::Vector3 fixed_position = rbdl_model_.mFixedBodies[flink_id].mParentTransform.r;
770 
771  etools::Matrix3 parent_body_rotation = rbdl_model_.X_base[parent_id].E.transpose();
772  etools::Vector3 parent_body_position = rbdl_model_.X_base[parent_id].r;
773 
774  return (parent_body_position
775  +
776  parent_body_rotation * (fixed_position + fixed_rotation * (point_body_coordinates)) );
777  }
778  else
779  {
780  etools::Matrix3 body_rotation = rbdl_model_.X_base[link_id].E.transpose();
781  etools::Vector3 body_position = rbdl_model_.X_base[link_id].r;
782 
783  return (body_position + body_rotation * point_body_coordinates);
784  }
785  }
786 
787 
788  /**
789  * @brief Get position of a tag
790  *
791  * @param[in] id parent link id
792  * @param[in] position_local position in the link frame
793  *
794  * @return 3d position vector
795  */
796  etools::Vector3 getPointTagPosition(const std::size_t id,
797  const etools::Vector3 &position_local) const
798  {
799  RigidBodyDynamics::Math::SpatialTransform mBaseTransform = getLinkTransform(id);
800 
801  return (mBaseTransform.E.transpose() * position_local + mBaseTransform.r);
802  }
803 
804 
805 
806  /**
807  * @brief Get Jacobian for a specific tag.
808  *
809  * @param[out] jacobian
810  * @param[in] link_id
811  * @param[in] tag_position (local)
812  *
813  * @attention Based on CalcPointJacobian() function from RBDL.
814  */
815  template<SpatialType::Type t_jacobian_type>
816  void getTagJacobian( Eigen::MatrixXd &jacobian,
817  const LinkId link_id,
818  const etools::Vector3 tag_position) const
819  {
820  unsigned int joint_id = link_id;
821 
822  if (isLinkFixed(link_id))
823  {
824  unsigned int flink_id = link_id - rbdl_model_.fixed_body_discriminator;
825  joint_id = rbdl_model_.mFixedBodies[flink_id].mMovableParent;
826  }
827 
828  jacobian.setZero(SpatialType::getNumberOfElements(t_jacobian_type), getDOFNumber());
829 
830 
831  SpatialTransformWithoutRotation trans(expressInRootFrame(link_id, tag_position));
832  while (joint_id != 0)
833  {
834  trans.applySelective<t_jacobian_type>(
835  jacobian.middleCols(rbdl_model_.mJoints[joint_id].q_index,
836  joint_data_[joint_id].dof_number_),
837  joint_data_[joint_id].transformed_joint_axis_);
838 
839  joint_id = rbdl_model_.lambda[joint_id];
840  }
841  }
842 
843 
844  /**
845  * @brief Returns spatial transform for a link
846  *
847  * @param[in] id
848  *
849  * @return spatial transform
850  */
851  RigidBodyDynamics::Math::SpatialTransform getLinkTransform(const LinkId id) const
852  {
853  if (isLinkFixed(id))
854  {
855  unsigned int flink_id = id - rbdl_model_.fixed_body_discriminator;
856 
857  return(rbdl_model_.mFixedBodies[flink_id].mParentTransform
858  * rbdl_model_.X_base[rbdl_model_.mFixedBodies[flink_id].mMovableParent]);
859  }
860  else
861  {
862  return (rbdl_model_.X_base[id]);
863  }
864  }
865  };
866  }
867 }
boost::shared_ptr< const TagLink > TagLinkPtr
Definition: tag.h:44
void compute(const RigidBodyDynamics::Model &rbdl_model, const unsigned int joint_id)
Computes data for a given joint.
Definition: model.h:664
boost::shared_ptr< const TagPartialCoM > TagPartialCoMPtr
Definition: tag.h:99
TagPointPtr getLinkCoMTag(const std::string &link_string_id) const
Tag for the CoM of a link.
Definition: model.h:189
static std::size_t getNumberOfElements(const Type &spatial_type)
Returns number of elements (dimensionality) for given spatial data type.
std::vector< JointData > joint_data_
Definition: model.h:697
void getTagJacobian(Eigen::MatrixXd &jacobian, const TagPointPtr tag) const
Get Jacobian for a specific tag.
Definition: model.h:492
void applySelective(Eigen::MatrixBase< t_Derived > const &result_block, const Eigen::MatrixXd &matrix) const
RigidBodyDynamics::Math::SpatialTransform getLinkTransform(const LinkId id) const
Returns spatial transform for a link.
Definition: model.h:851
#define HUMOTO_LOCAL
Definition: export_import.h:26
TagPointPtr getPointTag(const std::string &link_string_id, const etools::Vector3 &position_local) const
Tag for a point on a link.
Definition: model.h:173
rigidbody::RigidBodyPose getTagPose(const TagLinkPtr tag) const
Get tag pose.
Definition: model.h:358
etools::Vector3 getTagPosition(const TagCoMPtr tag) const
Get CoM of the robot.
Definition: model.h:303
void setDefaults()
Initialization.
Definition: model.h:704
std::size_t LinkId
Definition: tag.h:16
Eigen::MatrixXd transformed_joint_axis_
Definition: model.h:653
void update(const Eigen::VectorXd &joint_angles)
Update model.
Definition: model.h:128
TagLinkPtr getLinkTag(const std::string &link_string_id) const
Tag for a link.
Definition: model.h:158
TagCoMPtr getCoMTag() const
CoM tag.
Definition: model.h:229
#define HUMOTO_THROW_MSG(s)
HUMOTO_THROW_MSG throws an error message concatenated with the name of the function (if supported)...
etools::Vector3 getTagPosition(const TagPointPtr tag) const
Get position of a tag.
Definition: model.h:289
double getTagMass(const TagPartialCoMPtr tag) const
Get mass.
Definition: model.h:414
EIGEN_DEFAULT_DENSE_INDEX_TYPE EigenIndex
Definition: utility.h:26
etools::Vector3 getTagPosition(const TagLinkPtr tag) const
Get position of a tag.
Definition: model.h:276
void load(const std::string &urdf_filename)
Load URDF model.
Definition: model.h:99
void getTagJacobian(Eigen::MatrixXd &jacobian, const LinkId link_id, const etools::Vector3 tag_position) const
Get Jacobian for a specific tag.
Definition: model.h:816
Eigen::Matrix< unsigned int, Eigen::Dynamic, 1 > IndexVector
Definition: utility.h:19
TagPartialCoMPtr getCoMTag(const std::vector< std::string > &link_string_ids) const
CoM Tag for several bodies.
Definition: model.h:205
Model(const ModelParameters &model_parameters, const std::string &urdf_filename)
Construct using URDF model.
Definition: model.h:73
etools::Vector3 getTagPosition(const TagPartialCoMPtr tag) const
Get CoM of several bodies.
Definition: model.h:244
boost::shared_ptr< const TagCoM > TagCoMPtr
Definition: tag.h:79
etools::Vector3 convertMatrixToEulerAngles(const etools::Matrix3 &rotation_matrix, const EulerAngles::Type euler_angles_type)
Convert rotation matrix to Euler angles.
Definition: rotary_state.h:41
etools::Vector3 getPointTagPosition(const std::size_t id, const etools::Vector3 &position_local) const
Get position of a tag.
Definition: model.h:796
RigidBodyDynamics::Model rbdl_model_
Definition: model.h:41
double total_mass_
Definition: model.h:42
Stores precomputed data for each joint.
Definition: model.h:650
void getTagJacobian(Eigen::MatrixXd &jacobian, const TagCoMPtr tag) const
Compute CoM Jacobian of the robot.
Definition: model.h:506
void getTagJacobian(Eigen::MatrixXd &jacobian, const TagLinkPtr tag) const
Get Jacobian for a specific tag.
Definition: model.h:476
Link point tag.
Definition: tag.h:51
Model()
Default constructor. It is necesary to load() model before using.
Definition: model.h:50
Partial CoM tag (subset of links)
Definition: tag.h:85
ModelParameters model_parameters_
Definition: model.h:40
void load(const ModelParameters &model_parameters, const std::string &urdf_filename)
Load URDF model.
Definition: model.h:86
The root namespace of HuMoTo.
Definition: config.h:12
bool isLinkFixed(const std::size_t link_id) const
True if a body is fixed to its parent.
Definition: model.h:719
std::size_t getLinkId(const std::string &string_id) const
Determines id of a body based on its string id.
Definition: model.h:742
std::size_t getDOFNumber() const
Return number of DoF.
Definition: model.h:143
etools::Vector3 expressInRootFrame(const std::size_t link_id, const etools::Vector3 &point_body_coordinates) const
Express local position in root frame.
Definition: model.h:759
Model(const std::string &urdf_filename)
Construct using URDF model.
Definition: model.h:61
Efficient spatial transform with identity rotation matrix.
etools::Matrix3 getTagOrientation(const TagLinkPtr tag) const
Get orientation of a tag.
Definition: model.h:331
etools::Matrix3 getTagOrientation(const TagPointPtr tag) const
Get orientation of a tag.
Definition: model.h:344
Wraps RBDL model and provides additional functionality.
Definition: model.h:37
double getTagMass(const TagCoMPtr tag) const
Get mass.
Definition: model.h:401
CoM tag.
Definition: tag.h:72
void getTagJacobian(Eigen::MatrixXd &jacobian, const TagPartialCoMPtr tag) const
Get CoM jacbian for a set of bodies.
Definition: model.h:440
rigidbody::RigidBodyPose getTagPose(const TagPointPtr tag) const
Get tag pose.
Definition: model.h:379
boost::shared_ptr< const TagPoint > TagPointPtr
Definition: tag.h:66
Parameters of the model.
Definition: model.h:19
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3
Definition: eigentools.h:77
double getTagMass(const TagLinkPtr tag) const
Get mass.
Definition: model.h:427