CARLA
Loading...
Searching...
No Matches
RightHandedRotation.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9namespace carla {
10namespace geom {
11
12 /// Euler angles of a rotation expressed in a **right-handed** frame, in
13 /// degrees. This is the boundary type for ROS / REP-103 "FLU" consumers:
14 /// x forward, y **left**, z up, every axis turned by the right-hand rule.
15 ///
16 /// The three angles compose as the usual intrinsic Z-Y-X (yaw, then pitch,
17 /// then roll) sequence, i.e. `R = Rz(yaw) * Ry(pitch) * Rx(roll)` with the
18 /// standard right-handed elementary matrices. That is exactly what
19 /// `scipy.spatial.transform.Rotation.from_euler("xyz", ...)`,
20 /// `tf2::Quaternion::setRPY` and NVIDIA's ClipGT `rig.json` all mean by
21 /// "roll pitch yaw".
22 ///
23 /// This is **not** `carla::geom::Rotation`. CARLA's frame is left-handed
24 /// (x forward, y **right**, z up) and its rotator has mixed signs; the
25 /// exact mapping is
26 ///
27 /// right_handed.roll = carla.roll
28 /// right_handed.pitch = -carla.pitch
29 /// right_handed.yaw = -carla.yaw
30 ///
31 /// which is its own inverse. Use `Rotation::ToRightHanded()` /
32 /// `Rotation::FromRightHanded()` rather than flipping signs by hand, and
33 /// see `Docs/coordinate_conventions.md`.
35
36 /// Rotation about the forward (+X) axis, degrees, right-hand rule.
37 float roll = 0.0f;
38
39 /// Rotation about the left (+Y) axis, degrees, right-hand rule.
40 float pitch = 0.0f;
41
42 /// Rotation about the up (+Z) axis, degrees, right-hand rule.
43 float yaw = 0.0f;
44
46
47 constexpr RightHandedRotation(float in_roll, float in_pitch, float in_yaw)
48 : roll(in_roll),
49 pitch(in_pitch),
50 yaw(in_yaw) {
51 }
52
53 constexpr bool operator==(const RightHandedRotation &rhs) const {
54 return (roll == rhs.roll) && (pitch == rhs.pitch) && (yaw == rhs.yaw);
55 }
56
57 constexpr bool operator!=(const RightHandedRotation &rhs) const {
58 return !(*this == rhs);
59 }
60 };
61
62} // namespace geom
63} // namespace carla
This file contains definitions of common data structures used in traffic manager.
Euler angles of a rotation expressed in a right-handed frame, in degrees.
float yaw
Rotation about the up (+Z) axis, degrees, right-hand rule.
constexpr bool operator==(const RightHandedRotation &rhs) const
float roll
Rotation about the forward (+X) axis, degrees, right-hand rule.
constexpr bool operator!=(const RightHandedRotation &rhs) const
constexpr RightHandedRotation(float in_roll, float in_pitch, float in_yaw)
float pitch
Rotation about the left (+Y) axis, degrees, right-hand rule.