39 const std::string &name =
"robot_command")
const 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_);
56 template <
int t_features>
98 std::string base_orientation_string_id;
99 std::string base_position_string_id;
102 ModelDescription<t_features>::getBaseOrientationLinkStringId(base_orientation_string_id);
103 ModelDescription<t_features>::getBasePositionLinkStringId(base_position_string_id);
106 base_orientation_tag_ = rbdl_model_.getLinkTag(base_orientation_string_id);
107 base_position_tag_ = rbdl_model_.getLinkTag(base_position_string_id);
110 std::vector<std::string> base_links_string_ids;
111 std::vector<std::string> body_links_string_ids;
113 ModelDescription<t_features>::getBaseLinksStringIds(base_links_string_ids);
114 ModelDescription<t_features>::getBodyLinksStringIds(body_links_string_ids);
116 base_com_tag_ = rbdl_model_.getCoMTag(base_links_string_ids);
117 body_com_tag_ = rbdl_model_.getCoMTag(body_links_string_ids);
144 ModelDescription<t_features>::getJointPositionBounds(joint_position_bounds_min_,
145 joint_position_bounds_max_);
147 ModelDescription<t_features>::getJointVelocityBounds(joint_velocity_bounds_);
149 ModelDescription<t_features>::getMaxWheelVelocities(wheel_velocities_max_);
160 for (
EigenIndex i = 0; i < joint_angles.size(); ++i)
162 double value = joint_angles[i];
164 if ( boost::math::isnan(value) )
166 std::stringstream msg;
167 msg << std::setprecision(std::numeric_limits<double>::digits10);
168 msg <<
"Joint angle '" << i
169 <<
"' cannot be set to '" << value
175 if (value < joint_position_bounds_min_[i] - error_tol_)
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] <<
"'.";
186 if (value > joint_position_bounds_max_[i] + error_tol_)
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] <<
"'.";
207 const JointAnglesVector & joint_angles_to,
208 const double dt)
const 210 for (
EigenIndex i = 0; i < joint_angles_from.size(); ++i)
212 double joint_vel = std::abs(joint_angles_to[i] - joint_angles_from[i]) / dt;
213 if (joint_vel > joint_velocity_bounds_[i])
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] <<
"'.";
233 for (
EigenIndex i = 0; i < velocities.size(); ++i)
235 double value = velocities[i];
237 if ( boost::math::isnan(value) )
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
247 if ( (value < -wheel_velocities_max_[i])
248 || (value > wheel_velocities_max_[i]) )
250 std::stringstream msg;
251 msg <<
"Velocity of the wheel '" << i
252 <<
"' is too high. Value = '" << value
253 <<
"'. Bound = '" << wheel_velocities_max_[i]
287 rbdl_model_.
load(rbdl_param, filename);
290 "The loaded model has unexpected number of degrees of freedom.");
293 root_motion_to_wheels_ = ModelDescription<t_features>::getRootMotionToWheelsTransform();
330 return (rbdl_model_.
getTagMass(base_com_tag_));
352 return (rbdl_model_.
getTagMass(body_com_tag_));
529 const double error_tol = 1e-7)
const 538 generalized_coordinates_.joint_angles_,
544 etools::Vector3 base_translation_velocity = (getBasePosition() - saved_state_.
base_position_)/dt;
547 base_orientation)/dt;
549 command.
joint_angles_ = generalized_coordinates_.joint_angles_;
552 base_translation_velocity.y(),
553 base_rotation_velocity.z();
570 const double time_interval)
572 if (time_interval > 0.0)
577 etools::Vector3 position;
592 generalized_coordinates_.joint_angles_ +=
593 (command.
joint_angles_ - generalized_coordinates_.joint_angles_)
626 const double time_interval)
628 if (time_interval > 0.0)
630 generalized_coordinates_ = generalized_coordinates;
631 correct(command, time_interval);
635 updateState(generalized_coordinates);
660 const double error_tol = 1e-7)
const 662 checkStateTransition(generalized_coordinates_from, generalized_coordinates_, dt, error_tol);
678 const double error_tol = 1e-7)
const 682 generalized_coordinates_to.joint_angles_,
685 etools::Vector3 root_from;
686 etools::Vector3 root_to;
688 ModelDescription<t_features>::getRootPosition(root_from, generalized_coordinates_from.joint_angles_);
689 ModelDescription<t_features>::getRootPosition(root_to, generalized_coordinates_to.joint_angles_);
691 if (! root_from.isApprox(root_to, error_tol))
704 if (! rot_error.isZero(error_tol))
722 generalized_coordinates_ = generalized_coordinates;
724 rbdl_model_.
update(generalized_coordinates_.asVector());
735 return(generalized_coordinates_);
755 getBaseOrientation(),
771 etools::Vector3 position;
773 ModelDescription<t_features>::getTorsoRootLocation(
id, position);
788 const std::string &name =
"model")
const 791 generalized_coordinates_.
log(logger, subname,
"state");
793 logger.log(
LogEntryName(subname).add(
"root_motion_to_wheels"), root_motion_to_wheels_);
boost::shared_ptr< const TagLink > TagLinkPtr
etools::Vector3 base_position_
void loadParameters(const std::string &filename)
Initialize model based on an URDF file.
boost::shared_ptr< const TagPartialCoM > TagPartialCoMPtr
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="robot_command") const
Log.
etools::Vector3 base_velocities_
double getBodyMass() const
Get body mass.
void getRootPosition(etools::Vector3 &position) const
Get position of the root.
JointAnglesVector joint_velocity_bounds_
etools::Vector3 wheel_velocities_
asVector() const
Returns generalized coordinates as a single vector [root_pose; joint_angles].
Desired motion parameters.
etools::Vector3 getBaseCoM() const
Get position of the base CoM.
TagPointPtr getPointTag(const std::string &link_string_id, const etools::Vector3 &position_local) const
Tag for a point on a link.
rigidbody::RigidBodyPose getTagPose(const TagLinkPtr tag) const
Get tag pose.
etools::Vector3 getTagPosition(const rbdl::TagLinkPtr tag) const
Get tag position.
rbdl::TagLinkPtr base_orientation_tag_
void initialize()
Initialize tags.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
#define HUMOTO_ASSERT(condition, message)
etools::Vector3 base_com_position_
void update(const Eigen::VectorXd &joint_angles)
Update model.
TagLinkPtr getLinkTag(const std::string &link_string_id) const
Tag for a link.
void getRootOrientation(etools::Vector3 &rpy) const
Get orientation of the root.
etools::Vector3 body_com_position_
void saveCurrentState()
Make internal copy of the current state to avoid losing it while iteratively solving IK...
etools::Vector3 wheel_velocities_max_
#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.
EIGEN_DEFAULT_DENSE_INDEX_TYPE EigenIndex
etools::Matrix3 getTagOrientation(const rbdl::TagLinkPtr tag) const
Get tag orientation.
humoto::rbdl::Model rbdl_model_
void checkJointPositions(const JointAnglesVector &joint_angles) const
Check joint angle position bounds.
etools::Matrix3 getBaseOrientation() const
Get base orientation.
humoto::pepper_ik::GeneralizedCoordinates< t_features > generalized_coordinates_
JointAnglesVector joint_position_bounds_min_
void getTagCompleteJacobian(Eigen::MatrixXd &jacobian, const rbdl::TagLinkPtr tag) const
Get tag complete Jacobian.
JointAnglesVector joint_position_bounds_max_
etools::Vector3 getTagPosition(const TagPartialCoMPtr tag) const
Get CoM of several bodies.
boost::shared_ptr< const TagCoM > TagCoMPtr
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. 'generalized_coordinates_to' is assumed to be model's current state.
void setRootPosition(const etools::Vector3 &position)
Set position of the root.
etools::Vector3 getBasePosition() const
Get base position.
etools::Vector3 convertMatrixToEulerAngles(const etools::Matrix3 &rotation_matrix, const EulerAngles::Type euler_angles_type)
Convert rotation matrix to Euler angles.
void checkWheelVelocities(const etools::Vector3 &velocities) const
Check velocities of the wheels.
etools::Matrix3 base_orientation_
void checkCurrentState() const
Checks validity of the current state.
void getBodyCoMJacobian(Eigen::MatrixXd &jacobian) const
Get Jacobian of the upper body CoM.
etools::Vector3 getRotationErrorAngleAxis(const etools::Matrix3 ¤t, const etools::Matrix3 &reference)
void getStateError(MotionParameters &motion_param_errors, const MotionParameters &motion_param) const
Computes errors with respect to the given motion parameters.
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
void getCoMJacobian(Eigen::MatrixXd &jacobian) const
Get Jacobian of the upper body CoM.
Eigen::VectorXd joint_angles_
double getBaseMass() const
Get base mass.
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.
void load(const ModelParameters &model_parameters, const std::string &urdf_filename)
Load URDF model.
rbdl::TagPartialCoMPtr base_com_tag_
The root namespace of HuMoTo.
std::size_t getDOFNumber() const
Return number of DoF.
rbdl::TagLinkPtr getLinkTag(const std::string &id) const
Get tag.
Instances of this class are passed to a virtual method 'humoto::TaskBase::form()', so even though this class is basically useless in its present form we cannot avoid its definition using a template.
double getMass() const
Get mass of the robot.
const GeneralizedCoordinates< t_features > & getState() const
Return current model state.
Abstract class to be used for interfaces.
etools::Vector3 getCoM() const
Get position of the robot's CoM.
etools::Matrix3 getTagOrientation(const TagLinkPtr tag) const
Get orientation of a tag.
void getRobotCommand(RobotCommand &command, const double dt, const double error_tol=1e-7) const
Compute robot command.
etools::Matrix3 root_motion_to_wheels_
rbdl::TagPartialCoMPtr body_com_tag_
void getBaseCoMJacobian(Eigen::MatrixXd &jacobian) const
Get Jacobian of the base CoM.
rigidbody::RigidBodyPose getTorsoRootPose()
Returns pose of the root of the default robot model (root = torso)
Wraps RBDL model and provides additional functionality.
void updateState(const humoto::ModelState &model_state)
Update model state.
void checkJointVelocities(const JointAnglesVector &joint_angles_from, const JointAnglesVector &joint_angles_to, const double dt) const
Check joint velocity bounds.
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.
LogEntryName & add(const char *name)
extends entry name with a subname
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="model") const
Log.
humoto::pepper_ik::GeneralizedCoordinates< t_features > generalized_coordinates_
state of the model
double getTagMass(const TagCoMPtr tag) const
Get mass.
void getBaseOrientationJacobian(Eigen::MatrixXd &jacobian) const
Get base orientation Jacobian.
void getTagJacobian(Eigen::MatrixXd &jacobian, const TagPartialCoMPtr tag) const
Get CoM jacbian for a set of bodies.
double getBaseYaw() const
Return Yaw angle of base orientation.
etools::Vector3 getBodyCoM() const
Get position of the upper body CoM.
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="model_state") const
Log.
void correct(const RobotCommand &command, const double time_interval)
Correct state if the actual sampling interval is different from the expected.
void setRootOrientation(const etools::Vector3 &rpy)
Set orientation of the root.
rbdl::TagLinkPtr base_position_tag_
etools::Matrix3 convertEulerAnglesToMatrix(const etools::Vector3 &euler_angles, const EulerAngles::Type euler_angles_type)
Convert rotation matrix to Euler angles.
void getTagOrientationJacobian(Eigen::MatrixXd &jacobian, const rbdl::TagLinkPtr tag) const
Get tag orientation Jacobian.
Constraints()
Initialize bounds.
etools::Vector3 base_orientation_rpy_