Class Transform¶
Defined in File transform.hpp
Class Documentation¶
-
class Transform¶
Represents a transformation from one coordinate frame to another. A Static Transform from frame A to frame B defines a relationship between the two frames, such that a spatial measurement in frame A can be represented equivalently in frame B by applying a translational and rotational offset. This process is known as applying a transform.
Static Transforms are specified as a translation and rotation of some “follower” frame relative to some “base” frame. The “translation” is the follower frame’s origin in base frame, and the “rotation” is the follower frame’s orientation relative to the base frame’s orientation.
Conceptually, translations are applied “before” rotations. This means that the origin of the follower frame is entirely defined by the translation in the base frame, and the rotation serves only to change the orientation of the follower frame’s axes relative to the base frame.
A Dynamic Transform is an extension of a Static Transform that can store linear velocity, linear acceleration, and angular velocity. This class handles both, automatically determining whether it is static or dynamic.
Utilizes ARM’s CMSIS matrix operations.
Public Functions
-
Transform(const Position &translation, const Orientation &rotation)¶
- Parameters:
rotation – Initial rotation of this transformation.
position – Initial translation of this transformation.
-
Transform(Position &&translation, Orientation &&rotation)¶
-
Transform(const CMSISMat<3, 1> &translation, const CMSISMat<3, 3> &rotation)¶
- Parameters:
rotation – Initial rotation of this transformation.
position – Initial translation of this transformation.
-
Transform(float x, float y, float z, float rx, float ry, float rz)¶
Constructs rotations using XYZ Euler angles, so rotations are applied in order of rx, ry, then rz. As an example, for an x-forward, z-up coordinate system, this is in the order of roll, pitch, then yaw.
- Parameters:
x – Initial x-component of the translation.
y – Initial y-component of the translation.
z – Initial z-component of the translation.
rx – Initial rotation angle about the x-axis.
ry – Initial rotation angle about the y-axis.
rz – Initial rotation angle about the z-axis.
-
Transform(const Position &translation, const Orientation &rotation, const Vector &velocity, const Vector &acceleration, const Vector &angularVelocity)¶
- Parameters:
translation – Initial translation of this transformation.
rotation – Initial rotation of this transformation.
velocity – Translational velocity of this transformation.
acceleration – Translational acceleration of this transformation.
angularVelocity – Angular velocity pseudovector of this transformation.
-
Transform(Position &&translation, Orientation &&rotation, Vector &&velocity, Vector &&acceleration, Vector &&angularVelocity)¶
- Parameters:
translation – Initial translation of this transformation.
rotation – Initial rotation of this transformation.
velocity – Translational velocity of this transformation.
acceleration – Translational acceleration of this transformation.
angularVelocity – Angular velocity pseudovector of this transformation.
-
Transform(const DynamicPosition &dynamicPosition, const DynamicOrientation &dynamicOrientation)¶
- Parameters:
rotation – Initial rotation of this transformation.
position – Initial translation of this transformation.
-
Transform(DynamicPosition &&dynamicPosition, DynamicOrientation &&dynamicOrientation)¶
-
Transform(const CMSISMat<3, 1> &translation, const CMSISMat<3, 3> &rotation, const CMSISMat<3, 1> &velocity, const CMSISMat<3, 1> &acceleration, const CMSISMat<3, 3> &angularVelocity)¶
- Parameters:
translation – Initial translation of this transformation.
rotation – Initial rotation of this transformation.
velocity – Translational velocity of this transformation.
acceleration – Translational acceleration of this transformation.
angularVelocity – Angular velocity skew symmetric matrix of this transformation.
-
Transform(CMSISMat<3, 1> &&translation, CMSISMat<3, 3> &&rotation, CMSISMat<3, 1> &&velocity, CMSISMat<3, 1> &&acceleration, CMSISMat<3, 3> &&angularVelocity)¶
- Parameters:
translation – Initial translation of this transformation.
rotation – Initial rotation of this transformation.
velocity – Translational velocity of this transformation.
acceleration – Translational acceleration of this transformation.
angularVelocity – Angular velocity skew symmetric matrix of this transformation.
-
Transform(float x, float y, float z, float vx, float vy, float vz, float ax, float ay, float az, float rx, float ry, float rz, float wx, float wy, float wz)¶
Constructs rotations using XYZ Euler angles, so rotations are applied in order of rx, ry, then rx.
- Parameters:
x – Initial x-component of the translation.
y – Initial y-component of the translation.
z – Initial z-component of the translation.
vx – Initial x-component of the translational velocity.
vy – Initial y-component of the translational velocity.
vz – Initial z-component of the translational velocity.
ax – Initial x-component of the translational acceleration.
ay – Initial y-component of the translational acceleration.
az – Initial z-component of the translational acceleration.
rx – Initial rotation angle about the x-axis.
ry – Initial rotation angle about the y-axis.
rz – Initial rotation angle about the z-axis.
wx – Initial angular velocity about the x-axis.
wy – Initial angular velocity about the y-axis.
wz – Initial angular velocity about the z-axis.
-
Vector apply(const Vector &vector) const¶
Rotates a vector in the base frame to a vector in the follower frame.
Intended to be used for things like velocities and accelerations which represent the difference between two positions in space, since both positions get translated the same way, causing the translation to cancel out.
Note
Only accurate for static transforms!
-
DynamicPosition apply(const DynamicPosition &dynamicPosition) const¶
Brings a dynamic position in the base frame to one in the follower frame.
-
Orientation apply(const Orientation &orientation) const¶
Brings an orientation in the base frame to one in the follower frame.
-
DynamicOrientation apply(const DynamicOrientation &dynamicOrientation) const¶
Brings a dynamic orientation in the base frame to one in the follower frame.
-
inline void updateTranslation(const Position &newTranslation)¶
Updates the translation of the current transformation matrix.
- Parameters:
newTranslation – updated position of follower in base frame.
-
inline void updateTranslation(Position &&newTranslation)¶
Updates the translation of the current transformation matrix.
- Parameters:
newTranslation – updated position of follower in base frame.
-
inline void updateTranslation(float x, float y, float z)¶
Updates the translation of the current transformation matrix.
- Parameters:
x – new translation x-component.
y – new translation y-component.
z – new translation z-component.
-
inline void updateTranslation(const DynamicPosition &newTranslation)¶
Updates the translation of the current transformation matrix.
- Parameters:
newTranslation – updated position of follower in base frame.
-
inline void updateTranslation(DynamicPosition &&newTranslation)¶
Updates the translation of the current transformation matrix.
- Parameters:
newTranslation – updated position of follower in base frame.
-
inline void updateRotation(const Orientation &newRotation)¶
Updates the rotation of the current transformation matrix.
- Parameters:
newRotation – updated orientation of follower frame in base frame.
-
inline void updateRotation(Orientation &&newRotation)¶
Updates the rotation of the current transformation matrix.
- Parameters:
newRotation – updated orientation of follower frame in base frame.
-
inline void updateRotation(float roll, float pitch, float yaw)¶
Updates the rotation of the current transformation matrix. Takes rotation angles in the order of roll->pitch->yaw.
- Parameters:
roll – updated rotation angle about the x-axis.
pitch – updated rotation angle about the y-axis.
yaw – updated rotation angle about the z-axis.
-
inline void updateRotation(const DynamicOrientation &newRotation)¶
Updates the rotation of the current transformation matrix.
- Parameters:
newRotation – updated orientation of follower frame in base frame.
-
inline void updateRotation(DynamicOrientation &&newRotation)¶
Updates the rotation of the current transformation matrix.
- Parameters:
newRotation – updated orientation of follower frame in base frame.
-
inline void updateVelocity(const Vector &newVelocity)¶
Updates the velocity of the current transform.
- Parameters:
newVelocity – updated velocity of follower in base frame.
-
inline void updateVelocity(Vector &&newVelocity)¶
Updates the velocity of the current transform.
- Parameters:
newVelocity – updated velocity of follower in base frame.
-
inline void updateVelocity(float vx, float vy, float vz)¶
Updates the velocity of the current transform.
- Parameters:
vx – new velocity x-component.
vy – new velocity y-component.
vz – new velocity z-component.
-
inline void updateAcceleration(const Vector &newAcceleration)¶
Updates the acceleration of the current transform.
- Parameters:
updateAcceleration – updated acceleration of follower in base frame.
-
inline void updateAcceleration(Vector &&newAcceleration)¶
Updates the acceleration of the current transform.
- Parameters:
updateAcceleration – updated acceleration of follower in base frame.
-
inline void updateAcceleration(float ax, float ay, float az)¶
Updates the acceleration of the current transform.
- Parameters:
ax – new acceleration x-component.
ay – new acceleration y-component.
az – new acceleration z-component.
-
inline void updateAngularVelocity(const Vector &newAngularVelocity)¶
Updates the angular velocity of the current transform.
- Parameters:
updateAngularVelocity – updated angular velocity of follower in base frame.
-
inline void updateAngularVelocity(Position &&newAngularVelocity)¶
Updates the angular velocity of the current transform.
- Parameters:
updateAngularVelocity – updated angular velocity of follower in base frame.
-
inline void updateAngularVelocity(float vr, float vp, float vy)¶
Updates the angular velocity of the current transform.
- Parameters:
ax – new angular velocity x-component.
ay – new angular velocity y-component.
az – new angular velocity z-component.
-
Transform getInverse() const¶
Note
This is only instantaneously correct for dynamic transforms; It can no longer be projected forward in time and behave the same way as the original. This is due to the now reversed translation-rotation that would be required to truly mimic the motion of the original. Ex: Consider a dynamic transform with only non-zero translation and angular velocity. Projecting this forward will cause the follower frame to rotate around its origin. Intuitively, one would expect the inverted transform to have its follower frame rotate around the base frame origin. However, this circular translation can only be approximated here with translational velocity/acceleration. The true inverse would need to be the composition of a rotation then a translation.
- Returns:
Inverse of this Transform.
-
Transform compose(const Transform &second) const¶
Returns the composed transformation of the given transformations.
- Returns:
Transformation from this transform’s base frame to
second’s follower frame.
-
Transform composeStatic(const Transform &second) const¶
Returns the composed transformation of the given transformations, ignoring any time derivatives.
- Returns:
Static transformation from this transform’s base frame to
second’s follower frame.
-
Transform projectForward(float dt) const¶
Projects this transform forward in time according to its translational velocity/acceleration and angular velocity.
- Parameters:
dt – Seconds to project forward (can be negative)
- Returns:
Projected transform
-
inline DynamicPosition getDynamicTranslation() const¶
-
inline Orientation getRotation() const¶
-
inline DynamicOrientation getDynamicOrientation() const¶
-
float getRoll() const¶
Get the roll of this transformation.
-
float getPitch() const¶
Get the pitch of this transformation.
-
float getYaw() const¶
Get the yaw of this transformation.
-
float getRollVelocity() const¶
Get the roll velocity of this transformation.
-
float getPitchVelocity() const¶
Get the pitch velocity of this transformation.
-
float getYawVelocity() const¶
Get the yaw velocity of this transformation.
-
inline float getX() const¶
Get the x-component of this transform’s translation.
-
inline float getY() const¶
Get the y-component of this transform’s translation.
-
inline float getZ() const¶
Get the z-component of this transform’s translation.
-
inline float getXVel() const¶
Get the x-component of this transform’s linear velocity.
-
inline float getYVel() const¶
Get the y-component of this transform’s linear velocity.
-
inline float getZVel() const¶
Get the z-component of this transform’s linear velocity.
-
inline float getXAcc() const¶
Get the x-component of this transform’s linear acceleration.
-
inline float getYAcc() const¶
Get the y-component of this transform’s linear acceleration.
-
inline float getZAcc() const¶
Get the z-component of this transform’s linear acceleration.
-
inline bool isDynamic() const¶
Whether there are any non-zero derivatives.
-
Transform(const Position &translation, const Orientation &rotation)¶