humoto
model.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4  @author Jan Michalczyk
5  @copyright 2014-2017 INRIA. Licensed under the Apache License, Version 2.0.
6  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
7 
8  @brief
9 */
10 
11 #pragma once
12 
13 namespace humoto
14 {
15  namespace pepper_ik
16  {
17  /**
18  * @brief Stores robot command
19  */
21  {
22  public:
23  Eigen::VectorXd joint_angles_;
24  etools::Vector3 wheel_velocities_;
25  etools::Vector3 base_velocities_;
27 
28 
29  public:
30  /**
31  * @brief Log
32  *
33  * @param[in,out] logger logger
34  * @param[in] parent parent
35  * @param[in] name name
36  */
38  const LogEntryName &parent = LogEntryName(),
39  const std::string &name = "robot_command") const
40  {
41  LogEntryName subname = parent; subname.add(name);
42  logger.log(LogEntryName(subname).add("joint_angles"), joint_angles_);
43  logger.log(LogEntryName(subname).add("wheel_velocities"), wheel_velocities_);
44  logger.log(LogEntryName(subname).add("base_velocities"), base_velocities_);
45  logger.log(LogEntryName(subname).add("time_interval"), time_interval_);
46  }
47  };
48 
49 
50 
51  /**
52  * @brief Model
53  *
54  * @tparam t_features these features identify model
55  */
56  template <int t_features>
58  {
59  private:
60  class SavedState
61  {
62  public:
64 
65  etools::Vector3 base_position_;
67 
69 
70  public:
72  {
73  initialized_ = false;
74  }
75  };
76 
77 
80 
83 
85 
87 
88  /// state of the model
90 
91 
92  private:
93  /**
94  * @brief Initialize tags
95  */
96  void initialize()
97  {
98  std::string base_orientation_string_id;
99  std::string base_position_string_id;
100 
101 
102  ModelDescription<t_features>::getBaseOrientationLinkStringId(base_orientation_string_id);
103  ModelDescription<t_features>::getBasePositionLinkStringId(base_position_string_id);
104 
105 
106  base_orientation_tag_ = rbdl_model_.getLinkTag(base_orientation_string_id);
107  base_position_tag_ = rbdl_model_.getLinkTag(base_position_string_id);
108 
109 
110  std::vector<std::string> base_links_string_ids;
111  std::vector<std::string> body_links_string_ids;
112 
113  ModelDescription<t_features>::getBaseLinksStringIds(base_links_string_ids);
114  ModelDescription<t_features>::getBodyLinksStringIds(body_links_string_ids);
115 
116  base_com_tag_ = rbdl_model_.getCoMTag(base_links_string_ids);
117  body_com_tag_ = rbdl_model_.getCoMTag(body_links_string_ids);
118  }
119 
120 
121  public:
122  typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(ModelDescription<t_features>::JOINTS_DOF_NUMBER) JointAnglesVector;
123 
124 
125  public:
127  {
128  public:
129  JointAnglesVector joint_position_bounds_min_;
130  JointAnglesVector joint_position_bounds_max_;
131  JointAnglesVector joint_velocity_bounds_;
132  etools::Vector3 wheel_velocities_max_;
133  double error_tol_;
134 
135 
136  public:
137  /**
138  * @brief Initialize bounds.
139  */
141  {
142  error_tol_ = 1e-7;
143 
144  ModelDescription<t_features>::getJointPositionBounds(joint_position_bounds_min_,
145  joint_position_bounds_max_);
146 
147  ModelDescription<t_features>::getJointVelocityBounds(joint_velocity_bounds_);
148 
149  ModelDescription<t_features>::getMaxWheelVelocities(wheel_velocities_max_);
150  }
151 
152 
153  /**
154  * @brief Check joint angle position bounds
155  *
156  * @param[in] joint_angles
157  */
158  void checkJointPositions(const JointAnglesVector & joint_angles) const
159  {
160  for (EigenIndex i = 0; i < joint_angles.size(); ++i)
161  {
162  double value = joint_angles[i];
163 
164  if ( boost::math::isnan(value) )
165  {
166  std::stringstream msg;
167  msg << std::setprecision(std::numeric_limits<double>::digits10);
168  msg << "Joint angle '" << i
169  << "' cannot be set to '" << value
170  << "'.";
171  HUMOTO_THROW_MSG(msg.str());
172  }
173 
174 
175  if (value < joint_position_bounds_min_[i] - error_tol_)
176  {
177  std::stringstream msg;
178  msg << std::setprecision(std::numeric_limits<double>::digits10);
179  msg << "Lower bound of joint '" << i
180  << "' is violated. Value = '" << value
181  << "'. Bound = '" << joint_position_bounds_min_[i] << "'.";
182  HUMOTO_THROW_MSG(msg.str());
183  }
184 
185 
186  if (value > joint_position_bounds_max_[i] + error_tol_)
187  {
188  std::stringstream msg;
189  msg << std::setprecision(std::numeric_limits<double>::digits10);
190  msg << "Upper bound of joint '" << i
191  << "' is violated. Value = '" << value
192  << "'. Bound = '" << joint_position_bounds_max_[i] << "'.";
193  HUMOTO_THROW_MSG(msg.str());
194  }
195  }
196  }
197 
198 
199  /**
200  * @brief Check joint velocity bounds
201  *
202  * @param[in] joint_angles_from from this configuration
203  * @param[in] joint_angles_to to this configuration
204  * @param[in] dt within this time interval
205  */
206  void checkJointVelocities( const JointAnglesVector & joint_angles_from,
207  const JointAnglesVector & joint_angles_to,
208  const double dt) const
209  {
210  for (EigenIndex i = 0; i < joint_angles_from.size(); ++i)
211  {
212  double joint_vel = std::abs(joint_angles_to[i] - joint_angles_from[i]) / dt;
213  if (joint_vel > joint_velocity_bounds_[i])
214  {
215  std::stringstream msg;
216  msg << std::setprecision(std::numeric_limits<double>::digits10);
217  msg << "Velocity bound of joint '" << i
218  << "' is violated. Value = '" << joint_vel
219  << "'. Bound = '" << joint_velocity_bounds_[i] << "'.";
220  HUMOTO_THROW_MSG(msg.str());
221  }
222  }
223  }
224 
225 
226  /**
227  * @brief Check velocities of the wheels
228  *
229  * @param[in] velocities
230  */
231  void checkWheelVelocities(const etools::Vector3 &velocities) const
232  {
233  for (EigenIndex i = 0; i < velocities.size(); ++i)
234  {
235  double value = velocities[i];
236 
237  if ( boost::math::isnan(value) )
238  {
239  std::stringstream msg;
240  msg << std::setprecision(std::numeric_limits<double>::digits10);
241  msg << "Velocity of wheel '" << i
242  << "' cannot be set to '" << value
243  << "'.";
244  HUMOTO_THROW_MSG(msg.str());
245  }
246 
247  if ( (value < -wheel_velocities_max_[i])
248  || (value > wheel_velocities_max_[i]) )
249  {
250  std::stringstream msg;
251  msg << "Velocity of the wheel '" << i
252  << "' is too high. Value = '" << value
253  << "'. Bound = '" << wheel_velocities_max_[i]
254  << "'.";
255  HUMOTO_THROW_MSG(msg.str());
256  }
257  }
258  }
259  };
260 
261 
263 
265 
266 
267 
268  public:
269  /**
270  * @brief Initialize model based on an URDF file.
271  *
272  * @param[in] filename
273  */
274  void loadParameters(const std::string & filename)
275  {
277 
278  if (ModelFeatures::ROOT_PLANAR & t_features)
279  {
280  rbdl_param.floating_base_ = false;
281  }
282  else
283  {
284  rbdl_param.floating_base_ = true;
285  }
286 
287  rbdl_model_.load(rbdl_param, filename);
288 
289  HUMOTO_ASSERT( ModelDescription<t_features>::DOF_NUMBER == rbdl_model_.getDOFNumber(),
290  "The loaded model has unexpected number of degrees of freedom.");
291 
292  initialize();
293  root_motion_to_wheels_ = ModelDescription<t_features>::getRootMotionToWheelsTransform();
294 
295  rbdl_model_.update(generalized_coordinates_.asVector());
296  }
297 
298 
299  /**
300  * @brief Make internal copy of the current state to avoid
301  * losing it while iteratively solving IK.
302  */
304  {
305  saved_state_.base_orientation_ = getBaseOrientation();
306  saved_state_.base_position_ = getBasePosition();
307  saved_state_.generalized_coordinates_ = generalized_coordinates_;
308  saved_state_.initialized_ = true;
309  }
310 
311 
312  /**
313  * @brief Get position of the base CoM.
314  *
315  * @return com_position
316  */
317  etools::Vector3 getBaseCoM() const
318  {
319  return (rbdl_model_.getTagPosition(base_com_tag_));
320  }
321 
322 
323  /**
324  * @brief Get base mass
325  *
326  * @return mass
327  */
328  double getBaseMass() const
329  {
330  return (rbdl_model_.getTagMass(base_com_tag_));
331  }
332 
333 
334  /**
335  * @brief Get position of the upper body CoM.
336  *
337  * @return com_position
338  */
339  etools::Vector3 getBodyCoM() const
340  {
341  return (rbdl_model_.getTagPosition(body_com_tag_));
342  }
343 
344 
345  /**
346  * @brief Get body mass
347  *
348  * @return mass
349  */
350  double getBodyMass() const
351  {
352  return (rbdl_model_.getTagMass(body_com_tag_));
353  }
354 
355 
356  /**
357  * @brief Get position of the robot's CoM.
358  *
359  * @return com_position
360  */
361  etools::Vector3 getCoM() const
362  {
363  return (rbdl_model_.getTagPosition(rbdl::TagCoMPtr (new rbdl::TagCoM)));
364  }
365 
366 
367  /**
368  * @brief Get mass of the robot
369  *
370  * @return mass of the upper body
371  */
372  double getMass() const
373  {
374  return (rbdl_model_.getTagMass(rbdl::TagCoMPtr (new rbdl::TagCoM)));
375  }
376 
377 
378  /**
379  * @brief Get Jacobian of the base CoM.
380  *
381  * @param[out] jacobian
382  */
383  void getBaseCoMJacobian(Eigen::MatrixXd &jacobian) const
384  {
385  rbdl_model_.getTagJacobian(jacobian, base_com_tag_);
386  }
387 
388 
389  /**
390  * @brief Get Jacobian of the upper body CoM.
391  *
392  * @param[out] jacobian
393  */
394  void getCoMJacobian(Eigen::MatrixXd &jacobian) const
395  {
396  rbdl_model_.getTagJacobian(jacobian, rbdl::TagCoMPtr (new rbdl::TagCoM));
397  }
398 
399 
400  /**
401  * @brief Get Jacobian of the upper body CoM.
402  *
403  * @param[out] jacobian
404  */
405  void getBodyCoMJacobian(Eigen::MatrixXd &jacobian) const
406  {
407  rbdl_model_.getTagJacobian(jacobian, body_com_tag_);
408  }
409 
410 
411  /**
412  * @brief Get base orientation Jacobian.
413  *
414  * @param[out] jacobian
415  */
416  void getBaseOrientationJacobian(Eigen::MatrixXd &jacobian) const
417  {
418  rbdl_model_.getTagJacobian<rbdl::SpatialType::ROTATION>(jacobian, base_orientation_tag_);
419  }
420 
421 
422  /**
423  * @brief Get base orientation.
424  *
425  * @return rotation matrix
426  */
428  {
429  return (rbdl_model_.getTagOrientation(base_orientation_tag_));
430  }
431 
432 
433  /**
434  * @brief Return Yaw angle of base orientation
435  *
436  * @return Yaw angle
437  */
438  double getBaseYaw() const
439  {
440  return (convertMatrixToEulerAngles(getBaseOrientation(), rigidbody::EulerAngles::RPY).z());
441  }
442 
443 
444  /**
445  * @brief Get tag
446  *
447  * @param[in] id id (string)
448  *
449  * @return tag
450  */
451  rbdl::TagLinkPtr getLinkTag(const std::string & id) const
452  {
453  return (rbdl_model_.getLinkTag(id));
454  }
455 
456 
457  /**
458  * @brief Get tag orientation.
459  *
460  * @param[in] tag
461  *
462  * @return rotation matrix
463  */
465  {
466  return (rbdl_model_.getTagOrientation(tag));
467  }
468 
469 
470  /**
471  * @brief Get tag position.
472  *
473  * @param[in] tag
474  *
475  * @return position vector
476  */
477  etools::Vector3 getTagPosition(const rbdl::TagLinkPtr tag) const
478  {
479  return (rbdl_model_.getTagPosition(tag));
480  }
481 
482 
483  /**
484  * @brief Get tag orientation Jacobian
485  *
486  * @param[out] jacobian
487  * @param[in] tag
488  */
489  void getTagOrientationJacobian( Eigen::MatrixXd &jacobian,
490  const rbdl::TagLinkPtr tag) const
491  {
492  rbdl_model_.getTagJacobian<rbdl::SpatialType::ROTATION>(jacobian, tag);
493  }
494 
495 
496  /**
497  * @brief Get tag complete Jacobian
498  *
499  * @param[out] jacobian
500  * @param[in] tag
501  */
502  void getTagCompleteJacobian( Eigen::MatrixXd &jacobian,
503  const rbdl::TagLinkPtr tag) const
504  {
505  rbdl_model_.getTagJacobian<rbdl::SpatialType::COMPLETE>(jacobian, tag);
506  }
507 
508 
509  /**
510  * @brief Get base position.
511  *
512  * @return rotation matrix
513  */
514  etools::Vector3 getBasePosition() const
515  {
516  return (rbdl_model_.getTagPosition(base_position_tag_));
517  }
518 
519 
520  /**
521  * @brief Compute robot command
522  *
523  * @param[out] command
524  * @param[in] dt time interval between the new and the saved state
525  * @param[in] error_tol tolerance for checking satisfaction of the bounds
526  */
527  void getRobotCommand( RobotCommand & command,
528  const double dt,
529  const double error_tol = 1e-7) const
530  {
531  if (! saved_state_.initialized_)
532  {
533  HUMOTO_THROW_MSG("This function requires the previous state to be saved.");
534  }
535 
536  constraints_.checkJointPositions(generalized_coordinates_.joint_angles_);
537  constraints_.checkJointVelocities( saved_state_.generalized_coordinates_.joint_angles_,
538  generalized_coordinates_.joint_angles_,
539  dt);
540 
541 
542  etools::Matrix3 base_orientation = getBaseOrientation();
543 
544  etools::Vector3 base_translation_velocity = (getBasePosition() - saved_state_.base_position_)/dt;
545  etools::Vector3 base_rotation_velocity = rigidbody::getRotationErrorAngleAxis(
546  saved_state_.base_orientation_,
547  base_orientation)/dt;
548 
549  command.joint_angles_ = generalized_coordinates_.joint_angles_;
550 
551  command.base_velocities_ << base_translation_velocity.x(),
552  base_translation_velocity.y(),
553  base_rotation_velocity.z();
554 
555  command.wheel_velocities_ = root_motion_to_wheels_*base_orientation.transpose()*command.base_velocities_;
556  constraints_.checkWheelVelocities(command.wheel_velocities_);
557 
558  command.time_interval_ = dt;
559  }
560 
561 
562  /**
563  * @brief Correct state if the actual sampling interval is
564  * different from the expected.
565  *
566  * @param[in] command
567  * @param[in] time_interval
568  */
569  void correct( const RobotCommand & command,
570  const double time_interval)
571  {
572  if (time_interval > 0.0)
573  {
574  if (t_features & ModelFeatures::ROOT_PLANAR)
575  {
576  // base pose
577  etools::Vector3 position;
578  etools::Vector3 rpy;
579 
580  generalized_coordinates_.getRootPosition(position);
581  generalized_coordinates_.getRootOrientation(rpy);
582 
583  position.x() += time_interval * command.base_velocities_.x();
584  position.y() += time_interval * command.base_velocities_.y();
585 
586  rpy.z() += time_interval * command.base_velocities_(2);
587 
588  generalized_coordinates_.setRootPosition(position);
589  generalized_coordinates_.setRootOrientation(rpy);
590 
591  // joint angles
592  generalized_coordinates_.joint_angles_ +=
593  (command.joint_angles_ - generalized_coordinates_.joint_angles_)
594  * time_interval / command.time_interval_;
595  }
596  else
597  {
598  /**
599  * @todo Implement correction of the base position for
600  * the models where the root does not coincide with
601  * the base.
602  */
603  HUMOTO_THROW_MSG("Correction for this type of model is not implemented.");
604  }
605 
606  // update model
607  rbdl_model_.update(generalized_coordinates_.asVector());
608  }
609  }
610 
611 
612  /**
613  * @brief Correct state if the actual sampling interval is
614  * different from the expected.
615  *
616  * @param[in] generalized_coordinates
617  * @param[in] command
618  * @param[in] time_interval
619  *
620  * @note This version of correct() function updates the state
621  * and then corrects it, in some cases this allows to avoid
622  * update of the kinematic model.
623  */
625  const RobotCommand & command,
626  const double time_interval)
627  {
628  if (time_interval > 0.0)
629  {
630  generalized_coordinates_ = generalized_coordinates;
631  correct(command, time_interval);
632  }
633  else
634  {
635  updateState(generalized_coordinates);
636  }
637  }
638 
639 
640  /**
641  * @brief Checks validity of the current state.
642  */
643  void checkCurrentState() const
644  {
645  constraints_.checkJointPositions(generalized_coordinates_.joint_angles_);
646  }
647 
648 
649  /**
650  * @brief Check validity of translation from one state to
651  * another in the given time interval. 'generalized_coordinates_to' is assumed to
652  * be model's current state.
653  *
654  * @param[in] generalized_coordinates_from
655  * @param[in] dt
656  * @param[in] error_tol
657  */
659  const double dt,
660  const double error_tol = 1e-7) const
661  {
662  checkStateTransition(generalized_coordinates_from, generalized_coordinates_, dt, error_tol);
663  }
664 
665 
666  /**
667  * @brief Check validity of translation from one state to
668  * another in the given time interval.
669  *
670  * @param[in] generalized_coordinates_from
671  * @param[in] generalized_coordinates_to
672  * @param[in] dt
673  * @param[in] error_tol
674  */
676  const humoto::pepper_ik::GeneralizedCoordinates<t_features> & generalized_coordinates_to,
677  const double dt,
678  const double error_tol = 1e-7) const
679  {
680  constraints_.checkJointPositions(generalized_coordinates_to.joint_angles_);
681  constraints_.checkJointVelocities( generalized_coordinates_from.joint_angles_,
682  generalized_coordinates_to.joint_angles_,
683  dt);
684 
685  etools::Vector3 root_from;
686  etools::Vector3 root_to;
687 
688  ModelDescription<t_features>::getRootPosition(root_from, generalized_coordinates_from.joint_angles_);
689  ModelDescription<t_features>::getRootPosition(root_to, generalized_coordinates_to.joint_angles_);
690 
691  if (! root_from.isApprox(root_to, error_tol))
692  {
693  HUMOTO_THROW_MSG("Root translational motion is not allowed.");
694  }
695 
696  generalized_coordinates_from.getRootOrientation(root_from);
697  generalized_coordinates_to.getRootOrientation(root_to);
698 
699 
700  etools::Vector3 rot_error = rigidbody::getRotationErrorAngleAxis(
703 
704  if (! rot_error.isZero(error_tol))
705  {
706  HUMOTO_THROW_MSG("Root rotational motion is not allowed.");
707  }
708  }
709 
710 
711 
712  /**
713  * @brief Update model state.
714  *
715  * @param[in] model_state model state.
716  */
717  void updateState(const humoto::ModelState &model_state)
718  {
719  const humoto::pepper_ik::GeneralizedCoordinates<t_features> &generalized_coordinates =
720  dynamic_cast <const humoto::pepper_ik::GeneralizedCoordinates<t_features> &> (model_state);
721 
722  generalized_coordinates_ = generalized_coordinates;
723 
724  rbdl_model_.update(generalized_coordinates_.asVector());
725  }
726 
727 
728  /**
729  * @brief Return current model state.
730  *
731  * @return current state
732  */
734  {
735  return(generalized_coordinates_);
736  }
737 
738 
739  /**
740  * @brief Computes errors with respect to the given motion parameters.
741  *
742  * @param[out] motion_param_errors
743  * @param[in] motion_param
744  *
745  * @return MotionParameters class, where all members represent
746  * errors instead of the actual values.
747  */
748  void getStateError( MotionParameters &motion_param_errors,
749  const MotionParameters &motion_param) const
750  {
751  motion_param_errors.base_com_position_ = motion_param.base_com_position_ - getBaseCoM();
752  motion_param_errors.body_com_position_ = motion_param.body_com_position_ - getBodyCoM();
753 
755  getBaseOrientation(),
758  }
759 
760 
761 
762  /**
763  * @brief Returns pose of the root of the default robot model
764  * (root = torso)
765  *
766  * @return root pose
767  */
769  {
770  std::string id;
771  etools::Vector3 position;
772 
773  ModelDescription<t_features>::getTorsoRootLocation(id, position);
774 
775  return (rbdl_model_.getTagPose(rbdl_model_.getPointTag(id, position)));
776  }
777 
778 
779  /**
780  * @brief Log
781  *
782  * @param[in,out] logger logger
783  * @param[in] parent parent
784  * @param[in] name name
785  */
787  const LogEntryName &parent = LogEntryName(),
788  const std::string &name = "model") const
789  {
790  LogEntryName subname = parent; subname.add(name);
791  generalized_coordinates_.log(logger, subname, "state");
792 
793  logger.log(LogEntryName(subname).add("root_motion_to_wheels"), root_motion_to_wheels_);
794  }
795  };
796  }
797 }
boost::shared_ptr< const TagLink > TagLinkPtr
Definition: tag.h:44
etools::Vector3 base_position_
Definition: model.h:65
void loadParameters(const std::string &filename)
Initialize model based on an URDF file.
Definition: model.h:274
boost::shared_ptr< const TagPartialCoM > TagPartialCoMPtr
Definition: tag.h:99
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="robot_command") const
Log.
Definition: model.h:37
etools::Vector3 base_velocities_
Definition: model.h:25
double getBodyMass() const
Get body mass.
Definition: model.h:350
void getRootPosition(etools::Vector3 &position) const
Get position of the root.
JointAnglesVector joint_velocity_bounds_
Definition: model.h:131
#define HUMOTO_LOCAL
Definition: export_import.h:26
etools::Vector3 wheel_velocities_
Definition: model.h:24
Stores robot command.
Definition: model.h:20
asVector() const
Returns generalized coordinates as a single vector [root_pose; joint_angles].
Desired motion parameters.
Definition: common.h:78
etools::Vector3 getBaseCoM() const
Get position of the base CoM.
Definition: model.h:317
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 rbdl::TagLinkPtr tag) const
Get tag position.
Definition: model.h:477
rbdl::TagLinkPtr base_orientation_tag_
Definition: model.h:81
void initialize()
Initialize tags.
Definition: model.h:96
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
Definition: logger.h:997
#define HUMOTO_ASSERT(condition, message)
etools::Vector3 base_com_position_
Definition: common.h:90
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
void getRootOrientation(etools::Vector3 &rpy) const
Get orientation of the root.
etools::Vector3 body_com_position_
Definition: common.h:91
void saveCurrentState()
Make internal copy of the current state to avoid losing it while iteratively solving IK...
Definition: model.h:303
etools::Vector3 wheel_velocities_max_
Definition: model.h:132
#define HUMOTO_THROW_MSG(s)
HUMOTO_THROW_MSG throws an error message concatenated with the name of the function (if supported)...
Represents log entry name.
Definition: logger.h:169
EIGEN_DEFAULT_DENSE_INDEX_TYPE EigenIndex
Definition: utility.h:26
etools::Matrix3 getTagOrientation(const rbdl::TagLinkPtr tag) const
Get tag orientation.
Definition: model.h:464
humoto::rbdl::Model rbdl_model_
Definition: model.h:262
void checkJointPositions(const JointAnglesVector &joint_angles) const
Check joint angle position bounds.
Definition: model.h:158
etools::Matrix3 getBaseOrientation() const
Get base orientation.
Definition: model.h:427
humoto::pepper_ik::GeneralizedCoordinates< t_features > generalized_coordinates_
Definition: model.h:68
JointAnglesVector joint_position_bounds_min_
Definition: model.h:129
void getTagCompleteJacobian(Eigen::MatrixXd &jacobian, const rbdl::TagLinkPtr tag) const
Get tag complete Jacobian.
Definition: model.h:502
JointAnglesVector joint_position_bounds_max_
Definition: model.h:130
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
void checkStateTransition(const humoto::pepper_ik::GeneralizedCoordinates< t_features > &generalized_coordinates_from, const double dt, const double error_tol=1e-7) const
Check validity of translation from one state to another in the given time interval. &#39;generalized_coordinates_to&#39; is assumed to be model&#39;s current state.
Definition: model.h:658
void setRootPosition(const etools::Vector3 &position)
Set position of the root.
etools::Vector3 getBasePosition() const
Get base position.
Definition: model.h:514
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
void checkWheelVelocities(const etools::Vector3 &velocities) const
Check velocities of the wheels.
Definition: model.h:231
etools::Matrix3 base_orientation_
Definition: model.h:66
void checkCurrentState() const
Checks validity of the current state.
Definition: model.h:643
void getBodyCoMJacobian(Eigen::MatrixXd &jacobian) const
Get Jacobian of the upper body CoM.
Definition: model.h:405
etools::Vector3 getRotationErrorAngleAxis(const etools::Matrix3 &current, const etools::Matrix3 &reference)
Definition: rotary_state.h:123
void getStateError(MotionParameters &motion_param_errors, const MotionParameters &motion_param) const
Computes errors with respect to the given motion parameters.
Definition: model.h:748
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
Definition: logger.h:555
void getCoMJacobian(Eigen::MatrixXd &jacobian) const
Get Jacobian of the upper body CoM.
Definition: model.h:394
Eigen::VectorXd joint_angles_
Definition: model.h:23
double getBaseMass() const
Get base mass.
Definition: model.h:328
void checkStateTransition(const humoto::pepper_ik::GeneralizedCoordinates< t_features > &generalized_coordinates_from, const humoto::pepper_ik::GeneralizedCoordinates< t_features > &generalized_coordinates_to, const double dt, const double error_tol=1e-7) const
Check validity of translation from one state to another in the given time interval.
Definition: model.h:675
void load(const ModelParameters &model_parameters, const std::string &urdf_filename)
Load URDF model.
Definition: model.h:86
rbdl::TagPartialCoMPtr base_com_tag_
Definition: model.h:78
The root namespace of HuMoTo.
Definition: config.h:12
std::size_t getDOFNumber() const
Return number of DoF.
Definition: model.h:143
rbdl::TagLinkPtr getLinkTag(const std::string &id) const
Get tag.
Definition: model.h:451
Instances of this class are passed to a virtual method &#39;humoto::TaskBase::form()&#39;, so even though this class is basically useless in its present form we cannot avoid its definition using a template.
Definition: model.h:41
double getMass() const
Get mass of the robot.
Definition: model.h:372
const GeneralizedCoordinates< t_features > & getState() const
Return current model state.
Definition: model.h:733
Abstract class to be used for interfaces.
Definition: model.h:18
etools::Vector3 getCoM() const
Get position of the robot&#39;s CoM.
Definition: model.h:361
etools::Matrix3 getTagOrientation(const TagLinkPtr tag) const
Get orientation of a tag.
Definition: model.h:331
void getRobotCommand(RobotCommand &command, const double dt, const double error_tol=1e-7) const
Compute robot command.
Definition: model.h:527
etools::Matrix3 root_motion_to_wheels_
Definition: model.h:84
rbdl::TagPartialCoMPtr body_com_tag_
Definition: model.h:79
void getBaseCoMJacobian(Eigen::MatrixXd &jacobian) const
Get Jacobian of the base CoM.
Definition: model.h:383
rigidbody::RigidBodyPose getTorsoRootPose()
Returns pose of the root of the default robot model (root = torso)
Definition: model.h:768
Wraps RBDL model and provides additional functionality.
Definition: model.h:37
void updateState(const humoto::ModelState &model_state)
Update model state.
Definition: model.h:717
Constraints constraints_
Definition: model.h:264
void checkJointVelocities(const JointAnglesVector &joint_angles_from, const JointAnglesVector &joint_angles_to, const double dt) const
Check joint velocity bounds.
Definition: model.h:206
void correct(const humoto::pepper_ik::GeneralizedCoordinates< t_features > &generalized_coordinates, const RobotCommand &command, const double time_interval)
Correct state if the actual sampling interval is different from the expected.
Definition: model.h:624
LogEntryName & add(const char *name)
extends entry name with a subname
Definition: logger.h:232
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="model") const
Log.
Definition: model.h:786
humoto::pepper_ik::GeneralizedCoordinates< t_features > generalized_coordinates_
state of the model
Definition: model.h:89
double getTagMass(const TagCoMPtr tag) const
Get mass.
Definition: model.h:401
CoM tag.
Definition: tag.h:72
void getBaseOrientationJacobian(Eigen::MatrixXd &jacobian) const
Get base orientation Jacobian.
Definition: model.h:416
void getTagJacobian(Eigen::MatrixXd &jacobian, const TagPartialCoMPtr tag) const
Get CoM jacbian for a set of bodies.
Definition: model.h:440
double getBaseYaw() const
Return Yaw angle of base orientation.
Definition: model.h:438
etools::Vector3 getBodyCoM() const
Get position of the upper body CoM.
Definition: model.h:339
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="model_state") const
Log.
#define EIGENTOOLS_CONSTANT_SIZE_VECTOR(rows)
Definition: eigentools.h:58
void correct(const RobotCommand &command, const double time_interval)
Correct state if the actual sampling interval is different from the expected.
Definition: model.h:569
void setRootOrientation(const etools::Vector3 &rpy)
Set orientation of the root.
SavedState saved_state_
Definition: model.h:86
Parameters of the model.
Definition: model.h:19
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3
Definition: eigentools.h:77
rbdl::TagLinkPtr base_position_tag_
Definition: model.h:82
etools::Matrix3 convertEulerAnglesToMatrix(const etools::Vector3 &euler_angles, const EulerAngles::Type euler_angles_type)
Convert rotation matrix to Euler angles.
Definition: rotary_state.h:71
void getTagOrientationJacobian(Eigen::MatrixXd &jacobian, const rbdl::TagLinkPtr tag) const
Get tag orientation Jacobian.
Definition: model.h:489
Constraints()
Initialize bounds.
Definition: model.h:140
etools::Vector3 base_orientation_rpy_
Definition: common.h:93