9 #ifndef CPOSE3DROTVEC_H 10 #define CPOSE3DROTVEC_H 55 m_coords[0]=m_coords[1]=m_coords[2]=0;
56 m_rotvec[0]=m_rotvec[1]=m_rotvec[2]=0;
65 inline CPose3DRotVec(
const double vx,
const double vy,
const double vz,
const double x,
const double y,
const double z) {
66 m_coords[0]=
x; m_coords[1]=
y; m_coords[2]=
z;
67 m_rotvec[0]=vx; m_rotvec[1]=vy; m_rotvec[2]=vz;
72 m_rotvec[0]=
v[0]; m_rotvec[1]=
v[1]; m_rotvec[2]=
v[2];
73 m_coords[0]=
v[3]; m_coords[1]=
v[4]; m_coords[2]=
v[5];
97 m_coords[0]=vec6[3]; m_coords[1]=vec6[4]; m_coords[2]=vec6[5];
98 m_rotvec[0]=vec6[0]; m_rotvec[1]=vec6[1]; m_rotvec[2]=vec6[2];
111 out_HM.block<3,3>(0,0) = getRotationMatrix();
112 out_HM.set_unsafe(0,3,m_coords[0]);
113 out_HM.set_unsafe(1,3,m_coords[1]);
114 out_HM.set_unsafe(2,3,m_coords[2]);
115 out_HM.set_unsafe(3,0,0); out_HM.set_unsafe(3,1,0); out_HM.set_unsafe(3,2,0); out_HM.set_unsafe(3,3,1);
149 this->m_rotvec[0] = aux[0];
150 this->m_rotvec[1] = aux[1];
151 this->m_rotvec[2] = aux[2];
153 this->m_coords[0] = m.get_unsafe(0,3);
154 this->m_coords[1] = m.get_unsafe(1,3);
155 this->m_coords[2] = m.get_unsafe(2,3);
158 void setFromXYZAndAngles(
const double x,
const double y,
const double z,
const double yaw=0,
const double pitch=0,
const double roll=0 );
161 void sphericalCoordinates(
165 double &out_pitch )
const;
171 void composePoint(
double lx,
double ly,
double lz,
double &gx,
double &gy,
double &gz,
179 composePoint(local_point.
x,local_point.
y,local_point.
z, global_point.
x,global_point.
y,global_point.
z );
187 void inverseComposePoint(
const double gx,
const double gy,
const double gz,
double &lx,
double &ly,
double &lz,
207 composeFrom(*
this,
b);
248 inline double rx()
const {
return m_rotvec[0]; }
249 inline double ry()
const {
return m_rotvec[1]; }
250 inline double rz()
const {
return m_rotvec[2]; }
252 inline double &
rx() {
return m_rotvec[0]; }
253 inline double &
ry() {
return m_rotvec[1]; }
254 inline double &
rz() {
return m_rotvec[2]; }
258 m_coords+=
p.m_coords;
259 m_rotvec+=
p.m_rotvec;
283 m_coords[0]=x0; m_coords[1]=y0; m_coords[2]=z0;
284 m_rotvec[0]=vx; m_rotvec[1]=vy; m_rotvec[2]=vz;
291 template <
class ARRAYORVECTOR>
294 m_rotvec[0]=vec6[3]; m_rotvec[1]=vec6[4]; m_rotvec[2]=vec6[5];
295 m_coords[0]=vec6[0]; m_coords[1]=vec6[1]; m_coords[2]=vec6[2];
303 template <
class ARRAYORVECTOR>
306 vec6[0]=m_coords[0]; vec6[1]=m_coords[1]; vec6[2]=m_coords[2];
307 vec6[3]=m_rotvec[0]; vec6[4]=m_rotvec[1]; vec6[5]=m_rotvec[2];
311 template <
class ARRAYORVECTOR>
312 inline void getAsVector(ARRAYORVECTOR &
v)
const {
v.resize(6); getAs6Vector(
v); }
318 case 0:
return m_coords[0];
319 case 1:
return m_coords[1];
320 case 2:
return m_coords[2];
321 case 3:
return m_rotvec[0];
322 case 4:
return m_rotvec[1];
323 case 5:
return m_rotvec[2];
325 throw std::runtime_error(
"CPose3DRotVec::operator[]: Index of bounds.");
332 case 0:
return m_coords[0];
333 case 1:
return m_coords[1];
334 case 2:
return m_coords[2];
335 case 3:
return m_rotvec[0];
336 case 4:
return m_rotvec[1];
337 case 5:
return m_rotvec[2];
339 throw std::runtime_error(
"CPose3DRotVec::operator[]: Index of bounds.");
355 if (!m.fromMatlabStringFormat(
s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
357 for (
int i=0;i<3;i++) m_coords[i]=m.get_unsafe(0,i);
358 for (
int i=0;i<3;i++) m_rotvec[i]=m.get_unsafe(0,3+i);
379 enum { is_3D_val = 1 };
380 static inline bool is_3D() {
return is_3D_val!=0; }
381 enum { rotation_dimensions = 3 };
382 enum { is_PDF_val = 0 };
383 static inline bool is_PDF() {
return is_PDF_val!=0; }
402 static inline bool empty() {
return false; }
404 static inline void resize(
const size_t n) {
if (
n!=
static_size)
throw std::logic_error(
format(
"Try to change the size of CPose3DRotVec to %u.",static_cast<unsigned>(
n))); }
CPose3DRotVec(const double vx, const double vy, const double vz, const double x, const double y, const double z)
Constructor with initilization of the pose.
void changeCoordinatesReference(const CPose3DRotVec &p)
makes: this = p (+) this
const double & operator[](unsigned int i) const
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...
void asString(std::string &s) const
Returns a human-readable textual representation of the object: "[x y z rx ry rz]".
const type_value & getPoseMean() const
void setFromValues(const double x0, const double y0, const double z0, const double vx, const double vy, const double vz)
Set the pose from a 3D position (meters) and yaw/pitch/roll angles (radians) - This method recomputes...
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
#define DEFINE_SERIALIZABLE_PRE(class_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
mrpt::math::TPoint2D BASE_IMPEXP operator+(const CPose2D &pose, const mrpt::math::TPoint2D &pnt)
Compose a 2D point from a new coordinate base given by a 2D pose.
#define THROW_EXCEPTION(msg)
GLdouble GLdouble GLdouble GLdouble q
void addComponents(const CPose3DRotVec &p)
Scalar sum of all 6 components: This is diferent from poses composition, which is implemented as "+" ...
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
void setFromTransformationMatrix(const mrpt::math::CMatrixDouble44 &m)
double & operator[](unsigned int i)
double z
X,Y,Z coordinates.
const mrpt::math::CMatrixDouble33 getRotationMatrix() const
CPose3DRotVec type_value
Used to emulate CPosePDF types, for example, in mrpt::graphs::CNetworkOfPoses.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[x y z yaw pitch roll]"...
A numeric matrix of compile-time fixed size.
void getAs6Vector(ARRAYORVECTOR &vec6) const
Gets pose as an array with these 6 elements: [x y z vx vy vz] where v{xyz} is the rotation vector and...
void composeFrom(const CPose3DRotVec &A, const CPose3DRotVec &B, mrpt::math::CMatrixFixedNumeric< double, 6, 6 > *out_jacobian_drvtC_drvtA=NULL, mrpt::math::CMatrixFixedNumeric< double, 6, 6 > *out_jacobian_drvtC_drvtB=NULL)
Makes "this = A (+) B"; this method is slightly more efficient than "this= A + B;" since it avoids th...
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void setFrom6Vector(const ARRAYORVECTOR &vec6)
Set pose from an array with these 6 elements: [x y z vx vy vz] where v{xyz} is the rotation vector an...
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
double value_type
The type of the elements.
CPose2D BASE_IMPEXP operator-(const CPose2D &p)
Unary - operator: return the inverse pose "-p" (Note that is NOT the same than a pose with negative x...
A base class for representing a pose in 2D or 3D.
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
A class used to store a 2D point.
A class used to store a 3D point.
static void resize(const size_t n)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
type_value & getPoseMean()
CPose3DRotVec(TConstructorFlags_Poses constructor_dummy_param)
Fast constructor that leaves all the data uninitialized - call with UNINITIALIZED_POSE as argument...
size_t size(const MATRIXLIKE &m, const int dim)
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
CPose3DRotVec(const mrpt::math::CArrayDouble< 6 > &v)
Constructor with initilization of the pose from a vector [w1 w2 w3 x y z].
mrpt::math::CArrayDouble< 3 > m_rotvec
The rotation vector [vx,vy,vz].
mrpt::math::CMatrixDouble44 getHomogeneousMatrixVal() const
const double & const_reference
void inverseComposeFrom(const CPose3DRotVec &A, const CPose3DRotVec &B)
Makes this method is slightly more efficient than "this= A - B;" since it avoids the temporary objec...
CPose3DRotVec(const CPose3DRotVec &o)
Copy constructor.
#define DEFINE_SERIALIZABLE_POST(class_name)
std::ptrdiff_t difference_type
CPose3DRotVec(const double *vec6)
Constructor from an array with these 6 elements: [w1 w2 w3 x y z] where r{ij} are the entries of the ...
static size_type max_size()
A 3D pose, with a 3D translation and a rotation in 3D parameterized in rotation-vector form (equivale...
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
#define ASSERTMSG_(f, __ERROR_MSG)
void getAsVector(ARRAYORVECTOR &v) const
Like getAs6Vector() but for dynamic size vectors (required by base class CPoseOrPoint) ...
CPose3DRotVec()
Default constructor, with all the coordinates set to zero.
std::vector< T1 > & operator*=(std::vector< T1 > &a, const std::vector< T2 > &b)
a*=b (element-wise multiplication)
std::string asString() const
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z].
mrpt::math::CArrayDouble< 3 > m_coords
The translation vector [x,y,z].