|
CARLA
|
Quaternion representing a 3D rotation, stored as (x, y, z, w).
More...
#include <Quaternion.h>
Public Member Functions | |
| Quaternion | Conjugate () const |
| Conjugate of this quaternion. | |
| Vector3D | GetForwardVector () const |
| Unit vector pointing toward the local X axis of this rotation, expressed in CARLA's left-handed frame. | |
| Vector3D | GetRightVector () const |
| Unit vector pointing toward the local Y axis of this rotation, expressed in CARLA's left-handed frame. | |
| Vector3D | GetUpVector () const |
| Unit vector pointing toward the local Z axis of this rotation, expressed in CARLA's left-handed frame. | |
| Quaternion | Inverse () const |
| Inverse of this quaternion (assumes non-zero norm). | |
| RightHandedVector3D | InverseRotatedVector (const RightHandedVector3D &in) const |
| Inverse rotation of a right-handed vector. | |
| float | Length () const |
| MSGPACK_DEFINE_ARRAY (x, y, z, w) | |
| bool | operator!= (const Quaternion &rhs) const |
| Quaternion | operator* (const Quaternion &rhs) const |
Hamilton product (*this) * rhs. | |
| bool | operator== (const Quaternion &rhs) const |
| Quaternion ()=default | |
| Quaternion (const RightHandedRotation &rotation) | |
Quaternion of a right-handed (FLU) Euler triple, degrees, intrinsic Z-Y-X: q = qz(yaw) * qy(pitch) * qx(roll). | |
| Quaternion (const Rotation &rotation) | |
| Quaternion of a CARLA (left-handed) Euler rotation, degrees. | |
| constexpr | Quaternion (float ix, float iy, float iz, float iw) |
| RightHandedVector3D | RotatedVector (const RightHandedVector3D &in) const |
| Rotate a right-handed vector by this quaternion. | |
| Rotation | Rotator () const |
| Convert this quaternion back to a CARLA (left-handed) Euler rotation. | |
| RightHandedRotation | ToRightHandedRotation () const |
| This rotation as right-handed (FLU) Euler angles, degrees, intrinsic Z-Y-X. | |
| Quaternion | UnitQuaternion () const |
Public Attributes | |
| float | w = 1.0f |
| float | x = 0.0f |
| float | y = 0.0f |
| float | z = 0.0f |
Quaternion representing a 3D rotation, stored as (x, y, z, w).
Frame: right-handed, x forward / y left / z up (ROS REP-103 "FLU"). It is the quaternion of RightHandedRotation, not of CARLA's left-handed Rotation, and it is bit-for-bit the one the ROS 2 bridge publishes (ros2::TransformFromCarlaRotation in carla/ros2/publishers/TransformQuaternion.h).
The Quaternion(const Rotation &) constructor therefore performs a handedness change: it routes through Rotation::ToRightHanded(), which negates yaw and pitch and leaves roll alone. (The #9751 commit message says "yaw and roll"; that is wrong – see Docs/coordinate_conventions.md.) With those signs the basis vectors of Quaternion(r) – which convert back to CARLA's frame on the way out – reproduce, column for column, the matrix of Rotation::RotateVector and Transform::GetMatrix.
Definition at line 37 of file geom/Quaternion.h.
|
default |
Referenced by Conjugate(), Inverse(), operator*(), and UnitQuaternion().
|
inlineconstexpr |
Definition at line 57 of file geom/Quaternion.h.
|
inlineexplicit |
Quaternion of a right-handed (FLU) Euler triple, degrees, intrinsic Z-Y-X: q = qz(yaw) * qy(pitch) * qx(roll).
This is the textbook right-handed roll-pitch-yaw formula – no sign tricks live here.
Definition at line 67 of file geom/Quaternion.h.
References carla::geom::RightHandedRotation::pitch, carla::geom::RightHandedRotation::roll, w, x, y, carla::geom::RightHandedRotation::yaw, and z.
|
inlineexplicit |
Quaternion of a CARLA (left-handed) Euler rotation, degrees.
The handedness change happens exactly once, in Rotation::ToRightHanded(): yaw and pitch are negated, roll is not. The resulting (x, y, z, w) is in the right-handed FLU frame and is the value the ROS 2 bridge publishes.
Definition at line 94 of file geom/Quaternion.h.
|
inline |
Conjugate of this quaternion.
For a unit quaternion the conjugate is also its inverse.
Definition at line 191 of file geom/Quaternion.h.
References Quaternion(), w, x, y, and z.
Referenced by TEST().
|
inline |
Unit vector pointing toward the local X axis of this rotation, expressed in CARLA's left-handed frame.
The canonical axes are passed through the Vector3D -> RightHandedVector3D boundary conversion so the Y-sign flip happens on both ends of the rotation.
Definition at line 173 of file geom/Quaternion.h.
References RotatedVector().
|
inline |
Unit vector pointing toward the local Y axis of this rotation, expressed in CARLA's left-handed frame.
Definition at line 179 of file geom/Quaternion.h.
References RotatedVector().
|
inline |
Unit vector pointing toward the local Z axis of this rotation, expressed in CARLA's left-handed frame.
Definition at line 185 of file geom/Quaternion.h.
References RotatedVector().
|
inline |
Inverse of this quaternion (assumes non-zero norm).
Definition at line 196 of file geom/Quaternion.h.
References Quaternion(), w, x, y, and z.
Referenced by InverseRotatedVector(), TEST(), and TEST().
|
inline |
Inverse rotation of a right-handed vector.
For a unit quaternion this is equivalent to rotating by the conjugate.
Definition at line 165 of file geom/Quaternion.h.
References Inverse(), and RotatedVector().
|
inline |
Definition at line 205 of file geom/Quaternion.h.
Referenced by UnitQuaternion().
|
inline |
Definition at line 235 of file geom/Quaternion.h.
|
inline |
Hamilton product (*this) * rhs.
Definition at line 219 of file geom/Quaternion.h.
References Quaternion(), w, x, y, and z.
|
inline |
|
inline |
Rotate a right-handed vector by this quaternion.
Computes q * v_pure * q_conjugate via the Rodrigues form v + 2w*(q.xyz x v) + 2*(q.xyz x (q.xyz x v)).
Definition at line 148 of file geom/Quaternion.h.
References w, x, carla::geom::RightHandedVector3D::x, y, carla::geom::RightHandedVector3D::y, z, and carla::geom::RightHandedVector3D::z.
Referenced by GetForwardVector(), GetRightVector(), GetUpVector(), InverseRotatedVector(), TEST(), and TEST().
|
inline |
Convert this quaternion back to a CARLA (left-handed) Euler rotation.
Inverse of the Quaternion(Rotation) constructor; the handedness change is undone once, by Rotation::FromRightHanded().
Definition at line 126 of file geom/Quaternion.h.
References carla::geom::Rotation::FromRightHanded(), w, x, y, and z.
|
inline |
This rotation as right-handed (FLU) Euler angles, degrees, intrinsic Z-Y-X.
Inverse of Quaternion(const RightHandedRotation &).
Definition at line 104 of file geom/Quaternion.h.
Referenced by TEST().
|
inline |
Definition at line 209 of file geom/Quaternion.h.
| float carla::geom::Quaternion::w = 1.0f |
Definition at line 47 of file geom/Quaternion.h.
Referenced by Conjugate(), Inverse(), Length(), operator*(), operator==(), Quaternion(), RotatedVector(), Rotator(), TEST(), TEST(), TEST(), TEST(), ToRightHandedRotation(), and UnitQuaternion().
| float carla::geom::Quaternion::x = 0.0f |
Definition at line 44 of file geom/Quaternion.h.
Referenced by Conjugate(), Inverse(), Length(), operator*(), operator==(), Quaternion(), RotatedVector(), Rotator(), TEST(), TEST(), TEST(), TEST(), ToRightHandedRotation(), and UnitQuaternion().
| float carla::geom::Quaternion::y = 0.0f |
Definition at line 45 of file geom/Quaternion.h.
Referenced by Conjugate(), Inverse(), Length(), operator*(), operator==(), Quaternion(), RotatedVector(), Rotator(), TEST(), TEST(), TEST(), TEST(), ToRightHandedRotation(), and UnitQuaternion().
| float carla::geom::Quaternion::z = 0.0f |
Definition at line 46 of file geom/Quaternion.h.
Referenced by Conjugate(), Inverse(), Length(), operator*(), operator==(), Quaternion(), RotatedVector(), Rotator(), TEST(), TEST(), TEST(), TEST(), ToRightHandedRotation(), and UnitQuaternion().