TinyRobotics
Loading...
Searching...
No Matches
Orientation3D.h
1#pragma once
2#include <cmath>
3
4#include "TinyRobotics/units/Units.h"
5
6namespace tinyrobotics {
7
8/**
9 * @class Orientation3D
10 * @ingroup coordinates
11 * @brief Simple 3D orientation class (yaw, pitch, roll in radians)
12 */
13class Orientation3D {
14 public:
15 Orientation3D() = default;
16 Orientation3D(float yaw, float pitch, float roll)
17 : yaw(yaw), pitch(pitch), roll(roll) {}
18 Orientation3D(Angle yaw, Angle pitch, Angle roll) { set(yaw, pitch, roll); }
19
20 float yaw = 0.0f; ///< Yaw angle (radians)
21 float pitch = 0.0f; ///< Pitch angle (radians)
22 float roll = 0.0f; ///< Roll angle (radians)
23
24 Angle getYaw() const { return Angle(yaw, AngleUnit::RAD); }
25 Angle getPitch() const { return Angle(pitch, AngleUnit::RAD); }
26 Angle getRoll() const { return Angle(roll, AngleUnit::RAD); }
27
28 void set(float newYaw, float newPitch, float newRoll) {
29 yaw = newYaw;
30 pitch = newPitch;
31 roll = newRoll;
32 }
33
34 void set(Angle newYaw, Angle newPitch, Angle newRoll) {
35 yaw = newYaw.getValue(AngleUnit::RAD);
36 pitch = newPitch.getValue(AngleUnit::RAD);
37 roll = newRoll.getValue(AngleUnit::RAD);
38 }
39
40 void wrap() {
41 yaw = normalizeAngleRad(yaw);
42 pitch = normalizeAngleRad(pitch);
43 roll = normalizeAngleRad(roll);
44 }
45
46};
47
48} // namespace tinyrobotics
Represents an angle with unit conversion and wrap-around support.
Definition: Angle.h:42
Simple 3D orientation class (yaw, pitch, roll in radians)
Definition: Orientation3D.h:13
float roll
Roll angle (radians)
Definition: Orientation3D.h:22
float pitch
Pitch angle (radians)
Definition: Orientation3D.h:21
float yaw
Yaw angle (radians)
Definition: Orientation3D.h:20
AngleUnit
Supported angle units for conversion and representation.
Definition: Angle.h:11