134 const double x,
const double y,
const double z,
const double yaw = 0,
135 const double pitch = 0,
const double roll = 0);
148 template <
class MATRIX33,
class VECTOR3>
149 inline CPose3D(
const MATRIX33& rot,
const VECTOR3& xyz)
155 for (
int r = 0;
r < 3;
r++)
223 out_HM.insertMatrix(0, 0,
m_ROT);
224 for (
int i = 0; i < 3; i++) out_HM(i, 3) =
m_coords[i];
225 out_HM(3, 0) = out_HM(3, 1) = out_HM(3, 2) = 0.;
272 double& out_pitch)
const;
286 double lx,
double ly,
double lz,
double& gx,
double& gy,
double& gz,
293 bool use_small_rot_approx =
false)
const;
305 local_point.
x, local_point.
y, local_point.
z, global_point.
x,
306 global_point.
y, global_point.
z);
316 local_point.
x, local_point.
y, local_point.
z, global_point.
x,
317 global_point.
y, dummy_z);
323 double lx,
double ly,
double lz,
float& gx,
float& gy,
float& gz)
const
325 double ggx, ggy, ggz;
327 gx =
static_cast<float>(ggx);
328 gy =
static_cast<float>(ggy);
329 gz =
static_cast<float>(ggz);
342 const double gx,
const double gy,
const double gz,
double& lx,
343 double& ly,
double& lz,
362 const double eps = 1e-6)
const
439 const double x0,
const double y0,
const double z0,
const double yaw = 0,
440 const double pitch = 0,
const double roll = 0);
447 template <
typename VECTORLIKE>
448 inline void setFromXYZQ(
const VECTORLIKE&
v,
const size_t index_offset = 0)
453 v[index_offset + 3],
v[index_offset + 4],
v[index_offset + 5],
454 v[index_offset + 6]);
455 q.rotationMatrixNoResize(
m_ROT);
467 const double yaw_,
const double pitch_,
const double roll_)
478 template <
class ARRAYORVECTOR>
481 m_ROT.set_unsafe(0, 0, vec12[0]);
482 m_ROT.set_unsafe(0, 1, vec12[3]);
483 m_ROT.set_unsafe(0, 2, vec12[6]);
484 m_ROT.set_unsafe(1, 0, vec12[1]);
485 m_ROT.set_unsafe(1, 1, vec12[4]);
486 m_ROT.set_unsafe(1, 2, vec12[7]);
487 m_ROT.set_unsafe(2, 0, vec12[2]);
488 m_ROT.set_unsafe(2, 1, vec12[5]);
489 m_ROT.set_unsafe(2, 2, vec12[8]);
502 template <
class ARRAYORVECTOR>
505 vec12[0] =
m_ROT.get_unsafe(0, 0);
506 vec12[3] =
m_ROT.get_unsafe(0, 1);
507 vec12[6] =
m_ROT.get_unsafe(0, 2);
508 vec12[1] =
m_ROT.get_unsafe(1, 0);
509 vec12[4] =
m_ROT.get_unsafe(1, 1);
510 vec12[7] =
m_ROT.get_unsafe(1, 2);
511 vec12[2] =
m_ROT.get_unsafe(2, 0);
512 vec12[5] =
m_ROT.get_unsafe(2, 1);
513 vec12[8] =
m_ROT.get_unsafe(2, 2);
587 throw std::runtime_error(
588 "CPose3D::operator[]: Index of bounds.");
624 if (!m.fromMatlabStringFormat(
s))
626 ASSERTMSG_(m.rows() == 1 && m.cols() == 6,
"Expected vector length=6");
628 m.get_unsafe(0, 0), m.get_unsafe(0, 1), m.get_unsafe(0, 2),
661 bool pseudo_exponential =
false);
666 bool pseudo_exponential =
false);
709 const CPose3D& D, Eigen::Matrix<double, 12, 6>& jacob);
718 Eigen::Matrix<double, 12, 6>& jacob);
758 static constexpr
bool empty() {
return false; }
763 throw std::logic_error(
format(
764 "Try to change the size of CPose3D to %u.",
765 static_cast<unsigned>(
n)));
771 std::ostream&
operator<<(std::ostream& o,
const CPose3D&
p);
777 bool operator==(
const CPose3D& p1,
const CPose3D& p2);
778 bool operator!=(
const CPose3D& p1,
const CPose3D& p2);
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#define DECLARE_MEXPLUS_FROM(complete_type)
This must be inserted if a custom conversion method for MEX API is implemented in the class.
#define DECLARE_MEX_CONVERSION
This must be inserted if a custom conversion method for MEX API is implemented in the class.
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually,...
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ,...
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
A class used to store a 2D point.
A class used to store a 3D point.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
CPose3D & operator+=(const CPose3D &b)
Make (b can be "this" without problems)
void inverseComposeFrom(const CPose3D &A, const CPose3D &B)
Makes this method is slightly more efficient than "this= A - B;" since it avoids the temporary objec...
static constexpr bool empty()
type_value & getPoseMean()
static void jacob_dexpeD_de(const CPose3D &D, Eigen::Matrix< double, 12, 6 > &jacob)
The Jacobian d (e^eps * D) / d eps , with eps=increment in Lie Algebra.
void composePoint(double lx, double ly, double lz, float &gx, float &gy, float &gz) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
const double & operator[](unsigned int i) const
void operator*=(const double s)
Scalar multiplication of x,y,z,yaw,pitch & roll (angles will be wrapped to the ]-pi,...
bool isHorizontal(const double tolerance=0) const
Return true if the 6D pose represents a Z axis almost exactly vertical (upwards or downwards),...
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
CPose3D operator-(const CPose3D &b) const
Compute
void sphericalCoordinates(const mrpt::math::TPoint3D &point, double &out_range, double &out_yaw, double &out_pitch) const
Computes the spherical coordinates of a 3D point as seen from the 6D pose specified by this object.
double m_yaw
These variables are updated every time that the object rotation matrix is modified (construction,...
static constexpr bool is_PDF()
void getAsVector(mrpt::math::CVectorDouble &v) const
Returns a 1x6 vector with [x y z yaw pitch roll].
std::string asString() const
void setFromXYZQ(const VECTORLIKE &v, const size_t index_offset=0)
Set the pose from a 3D position (meters) and a quaternion, stored as [x y z qr qx qy qz] in a 7-eleme...
mrpt::math::CArrayDouble< 3 > m_coords
The translation vector [x,y,z] access directly or with x(), y(), z() setter/getter methods.
void inverseComposePoint(const mrpt::math::TPoint3D &g, mrpt::math::TPoint3D &l) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
double pitch() const
Get the PITCH angle (in radians)
void inverseComposePoint(const mrpt::math::TPoint2D &g, mrpt::math::TPoint2D &l, const double eps=1e-6) const
overload for 2D points
void addComponents(const CPose3D &p)
Scalar sum of all 6 components: This is diferent from poses composition, which is implemented as "+" ...
double roll() const
Get the ROLL angle (in radians)
static CPose3D exp(const mrpt::math::CArrayNumeric< double, 6 > &vect, bool pseudo_exponential=false)
Exponentiate a Vector in the SE(3) Lie Algebra to generate a new CPose3D (static method).
void ln_jacob(mrpt::math::CMatrixFixedNumeric< double, 6, 12 > &J) const
Jacobian of the logarithm of the 3x4 matrix defined by this pose.
void setFromValues(const double x0, const double y0, const double z0, const double yaw=0, const double pitch=0, const double roll=0)
Set the pose from a 3D position (meters) and yaw/pitch/roll angles (radians) - This method recomputes...
CPose3D(const mrpt::math::CArrayDouble< 12 > &vec12)
Constructor from an array with these 12 elements: [r11 r21 r31 r12 r22 r32 r13 r23 r33 tx ty tz] wher...
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
CPose3D(const MATRIX33 &rot, const VECTOR3 &xyz)
Constructor from a 3x3 rotation matrix and a the translation given as a 3-vector, a 3-array,...
void composePoint(const mrpt::math::TPoint3D &local_point, mrpt::math::TPoint2D &global_point) const
This version of the method assumes that the resulting point has no Z component (use with caution!...
void rebuildRotationMatrix()
Rebuild the homog matrix from the angles.
void inverseComposePoint(const double gx, const double gy, const double gz, double &lx, double &ly, double &lz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr) const
Computes the 3D point L such as .
static void ln_rot_jacob(const mrpt::math::CMatrixDouble33 &R, mrpt::math::CMatrixFixedNumeric< double, 3, 9 > &M)
Static function to compute the Jacobian of the SO(3) Logarithm function, evaluated at a given 3x3 rot...
CPose3D operator+(const CPose3D &b) const
The operator is the pose compounding operator.
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[x y z yaw pitch roll]",...
void inverse()
Convert this pose into its inverse, saving the result in itself.
CPose3D(TConstructorFlags_Poses)
Fast constructor that leaves all the data uninitialized - call with UNINITIALIZED_POSE as argument.
double distanceEuclidean6D(const CPose3D &o) const
The euclidean distance between two poses taken as two 6-length vectors (angles in radians).
static void resize(const size_t n)
const double & const_reference
static constexpr bool is_3D()
std::ptrdiff_t difference_type
void changeCoordinatesReference(const CPose3D &p)
makes: this = p (+) this
double value_type
The type of the elements.
void setFrom12Vector(const ARRAYORVECTOR &vec12)
Set pose from an array with these 12 elements: [r11 r21 r31 r12 r22 r32 r13 r23 r33 tx ty tz] where r...
bool m_ypr_uptodate
Whether yaw/pitch/roll members are up-to-date since the last rotation matrix update.
mrpt::math::CArrayDouble< 3 > ln_rotation() const
Take the logarithm of the 3x3 rotation matrix, generating the corresponding vector in the Lie Algebra...
CPose3D()
Default constructor, with all the coordinates set to zero.
void composePoint(const mrpt::math::TPoint3D &local_point, mrpt::math::TPoint3D &global_point) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
CPose3D(const mrpt::math::CMatrixDouble33 &rot, const mrpt::math::CArrayDouble< 3 > &xyz)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const type_value & getPoseMean() const
void fromStringRaw(const std::string &s)
Same as fromString, but without requiring the square brackets in the string.
mrpt::math::TPose3D asTPose() const
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[x y z yaw pitch roll]",...
double yaw() const
Get the YAW angle (in radians)
void setRotationMatrix(const mrpt::math::CMatrixDouble33 &ROT)
Sets the 3x3 rotation matrix.
static mrpt::math::CMatrixDouble33 exp_rotation(const mrpt::math::CArrayNumeric< double, 3 > &vect)
Exponentiate a vector in the Lie algebra to generate a new SO(3) (a 3x3 rotation matrix).
mrpt::math::CArrayDouble< 6 > ln() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void getAsQuaternion(mrpt::math::CQuaternionDouble &q, mrpt::math::CMatrixFixedNumeric< double, 4, 3 > *out_dq_dr=nullptr) const
Returns the quaternion associated to the rotation of this object (NOTE: XYZ translation is ignored)
void setToNaN() override
Set all data fields to quiet NaN.
void updateYawPitchRoll() const
Updates Yaw/pitch/roll members from the m_ROT
const mrpt::math::CMatrixDouble33 & getRotationMatrix() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setYawPitchRoll(const double yaw_, const double pitch_, const double roll_)
Set the 3 angles of the 3D pose (in radians) - This method recomputes the internal rotation coordinat...
void getAs12Vector(ARRAYORVECTOR &vec12) const
Get the pose representation as an array with these 12 elements: [r11 r21 r31 r12 r22 r32 r13 r23 r33 ...
CPose3D getOppositeScalar() const
Return the opposite of the current pose instance by taking the negative of all its components individ...
static void jacob_dAexpeD_de(const CPose3D &A, const CPose3D &D, Eigen::Matrix< double, 12, 6 > &jacob)
The Jacobian d (A * e^eps * D) / d eps , with eps=increment in Lie Algebra.
void composeFrom(const CPose3D &A, const CPose3D &B)
Makes "this = A (+) B"; this method is slightly more efficient than "this= A + B;" since it avoids th...
void getYawPitchRoll(double &yaw, double &pitch, double &roll) const
Returns the three angles (yaw, pitch, roll), in radians, from the rotation matrix.
void normalizeAngles()
Rebuild the internal matrix & update the yaw/pitch/roll angles within the ]-PI,PI] range (Must be cal...
mrpt::math::CMatrixDouble33 m_ROT
The 3x3 rotation matrix, access with getRotationMatrix(), setRotationMatrix() (It's not safe to set t...
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
static constexpr size_type max_size()
static constexpr size_type size()
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,...
A 3D pose, with a 3D translation and a rotation in 3D parameterized in rotation-vector form (equivale...
A base class for representing a pose in 2D or 3D.
double x() const
Common members of all points & poses classes.
The virtual base class which provides a unified interface for all persistent objects in MRPT.
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
#define ASSERT_BELOW_(__A, __B)
#define THROW_EXCEPTION(msg)
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
#define ASSERT_ABOVEEQ_(__A, __B)
GLdouble GLdouble GLdouble r
GLsizei const GLchar ** string
GLdouble GLdouble GLdouble GLdouble q
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
CPose2D operator-(const CPose2D &p)
Unary - operator: return the inverse pose "-p" (Note that is NOT the same than a pose with negative x...
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z]
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double RAD2DEG(const double x)
Radians to degrees.
double DEG2RAD(const double x)
Degrees to radians.
double x
X,Y,Z coordinates.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).