44 switch (euler_angles_type)
47 return (rotation_matrix.eulerAngles(0, 1, 2));
51 return (rotation_matrix.eulerAngles(2, 1, 0).reverse());
55 std::stringstream error_msg;
56 error_msg <<
"Euler angles of type '" << euler_angles_type <<
"' are not yet supported.";
74 switch (euler_angles_type)
77 return( ( Eigen::AngleAxisd(euler_angles(
AngleIndex::YAW), Eigen::Vector3d::UnitZ())
79 * Eigen::AngleAxisd(euler_angles(
AngleIndex::ROLL), Eigen::Vector3d::UnitX())).matrix() );
83 return( ( Eigen::AngleAxisd(euler_angles(
AngleIndex::ROLL), Eigen::Vector3d::UnitX())
85 * Eigen::AngleAxisd(euler_angles(
AngleIndex::YAW), Eigen::Vector3d::UnitZ())).matrix() );
89 std::stringstream error_msg;
90 error_msg <<
"Euler angles of type '" << euler_angles_type <<
"' are not yet supported.";
119 return (reference * current.transpose());
126 return (0.5 * ( current.col(0).cross(reference.col(0))
128 current.col(1).cross(reference.col(1))
130 current.col(2).cross(reference.col(2)) ) );
143 const etools::Vector3 &euler_angles,
146 switch (euler_angles_type)
150 << cos(euler_angles.y()) * cos(euler_angles.z()), -sin(euler_angles.z()), 0.0,
151 cos(euler_angles.y()) * sin(euler_angles.z()), cos(euler_angles.z()), 0.0,
152 -sin(euler_angles.y()), 0.0, 1.0 ).finished() );
156 std::stringstream error_msg;
157 error_msg <<
"Euler angles of type '" << euler_angles_type <<
"' are not yet supported.";
178 const etools::Vector3 & angular_velocity,
199 const etools::Vector3 & angular_velocity,
203 double vel = angular_velocity.norm();
205 if (std::abs(vel) < tolerance)
216 + sin(vel*dt) * orient_axis
217 + (1 - cos(vel*dt)) * orient_axis * tilde_axis );
227 #define HUMOTO_CONFIG_SECTION_ID "RotaryState" 228 #define HUMOTO_CONFIG_CONSTRUCTOR RotaryState 229 #define HUMOTO_CONFIG_ENTRIES \ 230 HUMOTO_CONFIG_COMPOUND_(rpy) \ 231 HUMOTO_CONFIG_COMPOUND_(angular_velocity) \ 232 HUMOTO_CONFIG_COMPOUND_(angular_acceleration) 233 #include HUMOTO_CONFIG_DEFINE_ACCESSORS 258 angular_velocity_.setZero();
259 angular_acceleration_.setZero();
294 const std::string &name =
"rotary_state")
const 299 logger.log(
LogEntryName(subname).add(
"angular_velocity") , angular_velocity_);
300 logger.log(
LogEntryName(subname).add(
"angular_acceleration"), angular_acceleration_);
etools::Vector3 angular_velocity_
void unset()
Initialize state (everything is set to NaN).
etools::Matrix3 getRotationError(const etools::Matrix3 ¤t, const etools::Matrix3 &reference)
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="rotary_state") const
Log.
etools::Matrix3 integrateAngularVelocityRodrigues(const etools::Matrix3 &orientation, const etools::Vector3 &angular_velocity, const double dt, const double tolerance=humoto::g_generic_tolerance)
Integrate angular velocity to obtain orientation matrix. Use Rodrigues formula.
RotaryState()
Default constructor.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
Default configurable base is strict.
etools::Vector3 convertEulerAngles(const etools::Vector3 &euler_angles, const EulerAngles::Type euler_angles_type_from, const EulerAngles::Type euler_angles_type_to)
Convert Euler angles to a different set ofEuler angles.
#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.
Class that groups together parameters related to a robot foot.
etools::Vector3 angular_acceleration_
etools::Vector3 convertMatrixToEulerAngles(const etools::Matrix3 &rotation_matrix, const EulerAngles::Type euler_angles_type)
Convert rotation matrix to Euler angles.
etools::Vector3 getRotationErrorAngleAxis(const etools::Matrix3 ¤t, const etools::Matrix3 &reference)
etools::Matrix3 integrateAngularVelocity(const etools::Matrix3 &orientation, const etools::Vector3 &angular_velocity, const double dt)
Integrate angular velocity to obtain orientation matrix. Simple version.
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
The root namespace of HuMoTo.
void setDefaults()
Initialize state (everything is set to zeros).
etools::Matrix3 getOrientationMatrix() const
Return orientation as a 3d matrix.
etools::Matrix3 getEulerRatesToAngularVelocityTransform(const etools::Vector3 &euler_angles, const EulerAngles::Type euler_angles_type)
Returns matrix M such that w = M * de.
LogEntryName & add(const char *name)
extends entry name with a subname
const double g_generic_tolerance
Generic tolerance, should be used by default.
etools::Matrix3 convertEulerAnglesToMatrix(const etools::Vector3 &euler_angles, const EulerAngles::Type euler_angles_type)
Convert rotation matrix to Euler angles.