CARLA
Loading...
Searching...
No Matches
Rotation Class Reference

Euler angles of a rotation in CARLA's / Unreal's left-handed frame: x forward, y right, z up, degrees. More...

#include <Rotation.h>

Public Member Functions

Vector3D GetForwardVector () const
Vector3D GetRightVector () const
Vector3D GetUpVector () const
void InverseRotateVector (Vector3D &in_point) const
 MSGPACK_DEFINE_ARRAY (pitch, yaw, roll)
Rotation Normalize () const
 operator FRotator () const
bool operator!= (const Rotation &rhs) const
Rotation operator+ (const Rotation &rhs) const
Rotation & operator+= (const Rotation &rhs)
Rotation operator- (const Rotation &rhs) const
Rotation & operator-= (const Rotation &rhs)
bool operator== (const Rotation &rhs) const
Vector3D RotateVector (const Vector3D &in_point) const
void RotateVector (Vector3D &in_point) const
 Rotation ()=default
 Rotation (const FRotator &rotator)
constexpr Rotation (float p, float y, float r)
constexpr RightHandedRotation ToRightHanded () const
 This rotation expressed in a right-handed, x-forward / y-**left** / z-up frame (ROS REP-103 "FLU"), as intrinsic Z-Y-X Euler angles under the right-hand rule.

Static Public Member Functions

static constexpr Rotation FromRightHanded (const RightHandedRotation &rhs)
 Inverse of ToRightHanded().

Public Attributes

float pitch = 0.0f
float roll = 0.0f
float yaw = 0.0f

Detailed Description

Euler angles of a rotation in CARLA's / Unreal's left-handed frame: x forward, y right, z up, degrees.

The three angles compose as R = Rz(+yaw) * Ry(-pitch) * Rx(-roll) with the standard (right-handed) elementary matrices, which is the same thing as saying:

  • +yaw turns the nose to the right;
  • +pitch tilts the nose up -> forward.z = +sin(pitch);
  • +roll drops the right side -> right.z = -cos(pitch)*sin(roll).

This is CARLA 0.9.x's documented convention and it is what the engine builds from the same FRotator, verified against rendered camera frames on UE5.8. RotateVector, Transform::GetMatrix and Math::Get{Forward,Right,Up}Vector all live in this frame and must not be "corrected" towards a right-handed convention.

For ROS / REP-103 consumers convert explicitly at the boundary with ToRightHanded() / FromRightHanded(); see RightHandedRotation and Docs/coordinate_conventions.md.

Definition at line 45 of file Rotation.h.

Constructor & Destructor Documentation

◆ Rotation() [1/3]

◆ Rotation() [2/3]

carla::geom::Rotation::Rotation ( float p,
float y,
float r )
inlineconstexpr

Definition at line 66 of file Rotation.h.

◆ Rotation() [3/3]

carla::geom::Rotation::Rotation ( const FRotator & rotator)
inline

Definition at line 271 of file Rotation.h.

Member Function Documentation

◆ FromRightHanded()

constexpr Rotation carla::geom::Rotation::FromRightHanded ( const RightHandedRotation & rhs)
inlinestaticconstexpr

Inverse of ToRightHanded().

The mapping is an involution, so the same three sign flips apply in both directions.

Definition at line 212 of file Rotation.h.

Referenced by TEST().

◆ GetForwardVector()

◆ GetRightVector()

Vector3D carla::geom::Rotation::GetRightVector ( ) const
inline

Definition at line 79 of file Rotation.h.

Referenced by AProceduralBuilding::UpdateTransformPositionToNextSide().

◆ GetUpVector()

Vector3D carla::geom::Rotation::GetUpVector ( ) const
inline

Definition at line 83 of file Rotation.h.

Referenced by ACarlaGameModeBase::DebugShowSignals().

◆ InverseRotateVector()

void carla::geom::Rotation::InverseRotateVector ( Vector3D & in_point) const
inline

Definition at line 131 of file Rotation.h.

◆ MSGPACK_DEFINE_ARRAY()

◆ Normalize()

Definition at line 164 of file Rotation.h.

◆ operator FRotator()

carla::geom::Rotation::operator FRotator ( ) const
inline

Definition at line 274 of file Rotation.h.

◆ operator!=()

bool carla::geom::Rotation::operator!= ( const Rotation & rhs) const
inline

Definition at line 226 of file Rotation.h.

◆ operator+()

Rotation carla::geom::Rotation::operator+ ( const Rotation & rhs) const
inline

Definition at line 234 of file Rotation.h.

◆ operator+=()

Rotation & carla::geom::Rotation::operator+= ( const Rotation & rhs)
inline

Definition at line 250 of file Rotation.h.

◆ operator-()

Rotation carla::geom::Rotation::operator- ( const Rotation & rhs) const
inline

Definition at line 242 of file Rotation.h.

◆ operator-=()

Rotation & carla::geom::Rotation::operator-= ( const Rotation & rhs)
inline

Definition at line 257 of file Rotation.h.

◆ operator==()

bool carla::geom::Rotation::operator== ( const Rotation & rhs) const
inline

Definition at line 220 of file Rotation.h.

◆ RotateVector() [1/2]

Vector3D carla::geom::Rotation::RotateVector ( const Vector3D & in_point) const
inline

Definition at line 125 of file Rotation.h.

◆ RotateVector() [2/2]

void carla::geom::Rotation::RotateVector ( Vector3D & in_point) const
inline

Definition at line 87 of file Rotation.h.

◆ ToRightHanded()

RightHandedRotation carla::geom::Rotation::ToRightHanded ( ) const
inlineconstexpr

This rotation expressed in a right-handed, x-forward / y-**left** / z-up frame (ROS REP-103 "FLU"), as intrinsic Z-Y-X Euler angles under the right-hand rule.

Mirroring the Y axis maps Rz(+yaw) * Ry(-pitch) * Rx(-roll) onto Rz(-yaw) * Ry(+(-pitch)) * Rx(+roll), so pitch and yaw flip sign and roll does not. Example: Rotation(pitch=20, yaw=30, roll=10) becomes RightHandedRotation(roll=10, pitch=-20, yaw=-30).

Definition at line 206 of file Rotation.h.

Member Data Documentation

◆ pitch

Definition at line 52 of file Rotation.h.

◆ roll

Definition at line 56 of file Rotation.h.

◆ yaw

Definition at line 54 of file Rotation.h.


The documentation for this class was generated from the following file: