14 #ifndef ECL_GEOMETRY_LEGACY_POSE2D_HPP_ 15 #define ECL_GEOMETRY_LEGACY_POSE2D_HPP_ 54 template <
typename Float, enum Pose2DStorageType Storage,
typename Enable>
class LegacyPose2D;
67 template <
typename Float, enum Pose2DStorageType Storage,
typename Enable>
73 template <
typename Float,
typename Enable>
83 template <
typename Float,
typename Enable>
102 template <
typename Float, enum Pose2DStorageType Storage>
class Pose2DMath {};
110 template <
typename Float>
115 static RotationMatrixType
Identity() {
return RotationMatrixType::Identity(); }
116 static RotationMatrixType
Rotation(
const RotationMatrixType &rotation) {
return rotation; }
119 static RotationMatrixType
Product(
const RotationMatrixType &rot1,
const RotationMatrixType &rot2) {
return rot1*rot2; }
120 static RotationMatrixType
Product(
const RotationMatrixType &rotation,
const Angle<Float> &angle) {
return rotation*angle.rotationMatrix(); }
121 static RotationMatrixType
Inverse(
const RotationMatrixType &rotation) {
return rotation.transpose(); }
131 template <
typename Float>
159 template <
class Float, enum Pose2DStorageType Storage = RotationMatrixStorage,
typename Enable =
void>
182 template<
typename Float, enum Pose2DStorageType Storage>
188 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
212 LegacyPose2D() : rot( RotationMath::Identity()), trans(Translation::Zero()) {}
221 rot( RotationMath::Rotation(angle)),
222 trans( (Translation() << x,y).finished() )
236 template<
typename Rot,
typename Trans>
237 LegacyPose2D(
const ecl::linear_algebra::MatrixBase<Rot>& R,
const ecl::linear_algebra::MatrixBase<Trans>& T) :
238 rot( RotationMath::Rotation(R) ),
251 template<
typename Trans>
253 rot( RotationMath::Rotation(angle) ),
263 template <enum Pose2DStorageType Storage_>
265 rot(RotationMath::Rotation(pose.rotation())),
266 trans(pose.translation())
279 template <enum Pose2DStorageType Storage_>
281 trans = pose.translation();
282 rot = RotationMath::Rotation(pose.rotation());
298 rot = RotationMath::Rotation(heading);
308 void rotation(
const RotationMatrix &rotation_matrix) {
309 rot = RotationMath::Rotation(rotation_matrix);
331 template <
typename Trans>
332 void translation(
const ecl::linear_algebra::MatrixBase<Trans>& T) {
340 rot = RotationMath::Identity();
356 void setPose(
const Float& x,
const Float& y,
const Angle<Float>& heading) { trans << x,y; rot = RotationMath::Rotation(heading); }
357 void x(
const Float& value) { trans[0] = value; }
358 void y(
const Float& value) { trans[1] = value; }
370 template <
typename Rot>
371 void rotationMatrix(
const ecl::linear_algebra::MatrixBase<Rot>& rotation_matrix) {
372 rot = RotationMath::Rotation(rotation_matrix);
380 const RotationType&
rotation()
const {
return rot; }
386 Float
x()
const {
return trans[0]; }
387 Float
y()
const {
return trans[1]; }
389 RotationMatrix
rotationMatrix()
const {
return RotationMatrixMath::Rotation(rot); }
403 inverse.rotation(RotationMath::Inverse(rot));
404 inverse.translation(-1*(RotationMatrixMath::Rotation(inverse.rot)*trans));
413 template <enum Pose2DStorageType Storage_>
424 *
this = (*this)*pose;
441 template <enum Pose2DStorageType Storage_>
443 return pose.inverse()*(*this);
449 template <
typename OutputStream,
typename Float_, enum Pose2DStorageType Storage_>
450 friend OutputStream& operator<<(OutputStream &ostream , const LegacyPose2D<Float_, Storage_> &pose);
474 template <
typename OutputStream,
typename Float_, enum Pose2DStorageType Storage_>
475 OutputStream& operator<<(OutputStream &ostream , const LegacyPose2D<Float_,Storage_> &pose) {
480 ostream << format(pose.x()) <<
" ";
481 ostream << format(pose.y()) <<
" ";
482 ostream << format(pose.heading());
RotationMatrix rotationMatrix() const
Angle< Float > RotationType
Rotation storage type (angle).
geometry::Pose2DMath< Float, RotationMatrixStorage > RotationMatrixMath
Rotational math specific to rotational matrices.
void x(const Float &value)
Sets the x-coordinate.
Embedded control libraries.
Float y() const
Get the y-coordinate.
geometry::Pose2DMath< Float, RotationAngleStorage > RotationAngleMath
Rotational math specific to rotational angles.
ecl_traits< LegacyPose2D< Float, Storage, typename enable_if< is_float< Float > >::type > >::RotationType RotationType
The type used for storage of the rotation/angle.
void y(const Float &value)
Sets the y-coordinate.
geometry::Pose2DMath< Float, Storage > RotationMath
Rotational math specific to this storage type.
LegacyPose2D< Float, Storage > & operator=(const LegacyPose2D< Float, Storage_ > &pose)
Assign from another Pose2D instance.
LegacyPose2D(const LegacyPose2D< Float, Storage_ > &pose)
Copy constructor that works for copies from any pose type.
Translation & translation()
Return a mutable handle to the rotational storage component.
LegacyPose2D< Float, Storage > operator*(const LegacyPose2D< Float, Storage_ > &pose) const
Combine this pose with the incoming pose.
ecl::linear_algebra::Matrix< Float, 2, 2 > RotationMatrixType
void rotationMatrix(const ecl::linear_algebra::MatrixBase< Rot > &rotation_matrix)
Set the rotational component.
Math functions/selectors for the pose2D class with rotation angle storage.
Pose2DStorageType
Used by the traits to select the storage type for Pose2D classes.
static LegacyPose2D< Float, Storage > Identity()
Static function for returning the idenitity pose, eigen style.
static Angle< Float > Heading(const RotationMatrixType &rotation)
Arbitrary heading angle converter.
void translation(const ecl::linear_algebra::MatrixBase< Trans > &T)
Set the translation vector.
LegacyPose2D(const ecl::linear_algebra::MatrixBase< Rot > &R, const ecl::linear_algebra::MatrixBase< Trans > &T)
Construct the pose using a rotation matrix and a translation vector.
Math functions/selectors for the pose2D class with rotation matrix storage.
LegacyPose2D< Float > & operator*=(const LegacyPose2D< Float > &pose)
Transform this pose by the specified input pose.
Parent template definition for Pose2D.
Float Scalar
Element type.
static RotationMatrixType Rotation(const RotationMatrixType &rotation)
Arbitrary rotation converter.
void rotation(const RotationMatrix &rotation_matrix)
Set the rotational component with a rotation matrix.
Float x() const
Return a const handle to the translation vector.
void heading(const Angle< Float > &value)
Sets the heading.
static Angle< Float > Product(const Angle< Float > &angle, RotationMatrixType &rotation)
Overloaded product calculater for poses.
LegacyPose2D(const Float &x, const Float &y, const Angle< Float > &angle)
Construct the pose using scalars for position and rotation angle.
static Angle< Float > Rotation(const RotationMatrixType &rotation)
Arbitrary rotation converter.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Float Scalar
Eigen style declaration of the element type.
static RotationMatrixType Rotation(const Angle< Float > &angle)
Arbitrary rotation converter.
static RotationMatrixType Product(const RotationMatrixType &rot1, const RotationMatrixType &rot2)
Overloaded product calculater for poses.
ecl::linear_algebra::Matrix< Float, 2, 2 > RotationMatrix
The type used to represent rotation matrices.
static Angle< Float > Heading(const Angle< Float > &angle)
Arbitrary heading angle converter.
void translation(const Float &x, const Float &y)
Set the translation vector from a pair of x,y values.
static RotationMatrixType Product(const RotationMatrixType &rotation, const Angle< Float > &angle)
Overloaded product calculater for poses.
ecl::linear_algebra::Matrix< Float, 2, 1 > Translation
The type used to represent translations.
ecl::linear_algebra::Matrix< Float, 2, 2 > RotationMatrixType
RotationType & rotation()
LegacyPose2D()
Default constructor.
const RotationType & rotation() const
Return a mutable handle to the translation vector.
static RotationMatrixType Inverse(const RotationMatrixType &rotation)
Pose inverse, rotation matrix format.
LegacyPose2D< Float, Storage > inverse() const
Calculate the inverse pose.
static Angle< Float > Product(const Angle< Float > &angle1, const Angle< Float > &angle2)
Overloaded product calculater for poses.
Angle< Float > heading() const
Get the heading.
static RotationMatrixType Identity()
Rotation matrix type for pose2D.
void rotation(const Angle< Float > &heading)
Set the rotational component with a heading angle.
Parent template definition for angles.
Parent template for the pose2D math classes.
C++ interface for angles (degrees/radians).
void setIdentity()
Set this pose to zero rotation and zero translation.
LegacyPose2D(const Angle< Float > &angle, const ecl::linear_algebra::MatrixBase< Trans > &T)
Construct the pose using a rotational angle and a translation vector.
ecl::linear_algebra::Matrix< Float, 2, 2 > RotationType
Rotation storage type (matrix).
static Angle< Float > Inverse(const Angle< Float > &angle)
Pose inverse, angle format.
const Translation & translation() const
Return a const handle to the rotational storage component.
void setPose(const Float &x, const Float &y, const Angle< Float > &heading)
Sets the pose with a triplet.
static Angle< Float > Rotation(const Angle< Float > &radians)
Arbitrary rotation converter.
Float Scalar
Element type.
LegacyPose2D< Float, Storage > relative(const LegacyPose2D< Float, Storage_ > &pose) const
Relative pose between this pose and another.
static Angle< Float > Identity()
Rotation matrix type for pose2D.