ImFusion SDK 4.3
Transform< To, From, EigenType > Class Template Reference

#include <ImFusion/Core/Transform.h>

The Transform class provides a transformation from a Frame to another Frame, where each Frame is a coordinate system. More...

Detailed Description

template<auto To, auto From, typename EigenType = Eigen::Matrix4d>
class ImFusion::Transform< To, From, EigenType >

The Transform class provides a transformation from a Frame to another Frame, where each Frame is a coordinate system.


Transform is templated with a To and a From Frames.

Note
To facilitate reading of the transformation chain, the order of the Frames in the template is <To, From>

At compilation time, the validity of Transform operations is checked:

  • Assignment can only be from the same Frame
  • To Frame of the Transform right multiplied must match our From
  • The Frame of the Vector right multiplied must match our From

To define Frames, create a user enumeration where each value represents each Frame.

An example of the Robot transforms:

enum class Robot { Base = 0, Arm, EndEffector };
Transform<Robot::Base, Robot::Arm> base_T_arm; // from Arm to Base
Transform<Robot::Arm, Robot::EndEffector> arm_T_ef; // from EndEffector to Arm
Transform<Robot::Base, Robot::EndEffector> base_T_ef = base_T_arm * arm_T_ef; // from EndEffector to Base
The Transform class provides a transformation from a Frame to another Frame, where each Frame is a co...
Definition Transform.h:94
Definition Scanner.h:29

The following code would not compile:

enum class Robot { Base = 0, Arm, EndEffector };
Transform<Robot::Arm, Robot::EndEffector> arm_T_ef = base_T_arm; // Frames do not match
auto base_T_ef = base_T_arm * ef_T_arm; // From-Frame does not match To-Frame
auto baseVec = base_T_arm * efVec; // From does not match vector Frame
Class representing a vector, defined in a Frame.
Definition Vector.h:46

By default, the Transform uses an Eigen::Matrix4d. A different Eigen matrix can also be used as supporting type, such as Eigen::Isometry3d, or Eigen::Matrix3d for 2D transforms.
Eigen supports operation optimizations, therefore the EigenType will change after calling an operation.
To support these optimizations, use auto as the return of the operation to implicitly hold a Transform<To, From, EigenOperationType> or chain operations in the same line.
For example:

enum class Robot { Base = 0, Arm, EndEffector };
auto base_T_ef = base_T_arm * arm_T_ef; // keeps the operation optimization and the To-From-Frames.
Transform<Robot::EndEffector, Robot::Base> ef_T_base = base_T_ef.inverse() // inverse operation applied, and converted down to Eigen::Matrix4d
auto inverse() const
Returns the inverse Transform, internal value is inverted, and Frames are inverted.
Definition Transform.h:175

The cast() method is useful to skip Transform in the chain of operations when they're Identity, for example:

Transform<Robot::Base, Robot::Arm> base_T_arm;
// from EndEffector to Arm is Identity, lets skip it
auto base_T_ef = base_T_arm.cast<Robot::Base, Robot::EndEffector>();
Transform< NewTo, NewFrom, EigenType > cast() const
Casts the Transform to a new set of Frames. The internal value of the Transform is not modified.
Definition Transform.h:183

A Transform between different Frame enumerations can also be defined, for example:

enum class House { World = 0, Building, Room };
enum class Robot { Base = 0, Arm, EndEffector };
Transform<House::Building, House::Room> build_T_room;
// we assume Building to World transform is Identity
auto world_T_room = build_T_room.cast<House::World, House::Room>();
// transform Robot frames to House frames
Transform<House::Room, Robot::Base> room_T_base;
Transform<Robot::Base, Robot::EndEffector> base_T_ef;
Transform<House::World, Robot::EndEffector> world_T_ef = world_T_room * room_T_base * base_T_ef;
// pose of the end effector in house world frame
auto ef_T_world = world_T_ef.inverse();
Template Parameters
ToFrame where the transform maps to
FromFrame where the transform originates from
EigenTypeUnderlying type of the Transform, should be an Eigen type
See also
Vector

Public Types

using TypeTo = decltype(To)
 
using TypeFrom = decltype(From)
 

Public Member Functions

template<typename OtherEigenType>
 Transform (OtherEigenType m)
 
template<auto OtherTo, auto OtherFrom, typename OtherEigenType>
 Transform (const Transform< OtherTo, OtherFrom, OtherEigenType > &other)
 
template<auto OtherTo, auto OtherFrom>
 Transform (Transform< OtherTo, OtherFrom > &&other)
 
template<auto OtherTo, auto OtherFrom>
Transform< FrameTo, FrameFrom, EigenType > & operator= (Transform< OtherTo, OtherFrom, EigenType > other)
 
template<auto OtherTo, auto OtherFrom, typename OtherEigenType>
Transform< FrameTo, FrameFrom, EigenType > & operator= (const Transform< OtherTo, OtherFrom, OtherEigenType > &other)
 
template<auto OtherTo, auto OtherFrom, typename OtherEigenType>
auto operator* (const Transform< OtherTo, OtherFrom, OtherEigenType > &other) const
 
template<auto OtherFrom, typename OtherEigenVector>
auto operator* (const Vector< OtherFrom, OtherEigenVector > &vector) const
 
auto inverse () const
 Returns the inverse Transform, internal value is inverted, and Frames are inverted.
 
template<auto NewTo, auto NewFrom>
Transform< NewTo, NewFrom, EigenType > cast () const
 Casts the Transform to a new set of Frames. The internal value of the Transform is not modified.
 
EigenType & matrix ()
 
const EigenType & matrix () const
 
 operator EigenType () const
 

Static Public Attributes

static constexpr TypeTo FrameTo = To
 
static constexpr TypeFrom FrameFrom = From
 

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close