28 #include "Eigen/Geometry" 88 : roll_(roll), pitch_(pitch), yaw_(yaw) {}
99 : roll_(
std::atan2(static_cast<T>(2.0) * (qw * qy - qx * qz),
101 static_cast<T>(1.0))),
102 pitch_(
std::asin(static_cast<T>(2.0) * (qw * qx + qy * qz))),
103 yaw_(
std::atan2(static_cast<T>(2.0) * (qw * qz - qx * qy),
105 static_cast<T>(1.0))) {}
118 T
roll()
const {
return roll_; }
130 T
yaw()
const {
return yaw_; }
147 return pitch_ < M_PI_2 && pitch_ > -M_PI_2;
155 T coeff =
static_cast<T
>(0.5);
157 T p = pitch_ * coeff;
168 T qw = cr * cp * cy - sr * sp * sy;
169 T qx = cr * sp * cy - sr * cp * sy;
170 T qy = cr * sp * sy + sr * cp * cy;
171 T qz = cr * cp * sy + sr * sp * cy;
173 return {-qw, -qx, -qy, -qz};
175 return {qw, qx, qy, qz};
EulerAnglesZXY(T yaw)
Constructs a rotation using only yaw (i.e., around the z-axis).
Definition: euler_angles_zxy.h:78
EulerAnglesZXY(T roll, T pitch, T yaw)
Constructs a rotation using arbitrary roll, pitch, and yaw.
Definition: euler_angles_zxy.h:87
void Normalize()
Normalizes roll_, pitch_, and yaw_ to [-PI, PI).
Definition: euler_angles_zxy.h:135
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Eigen::Quaternion< T > ToQuaternion() const
Converts to a quaternion with a non-negative scalar part.
Definition: euler_angles_zxy.h:154
EulerAnglesZXY()
Constructs an identity rotation.
Definition: euler_angles_zxy.h:71
bool IsValid()
Verifies the validity of the specified rotation.
Definition: euler_angles_zxy.h:145
double NormalizeAngle(const double angle)
Normalize angle to [-PI, PI).
T yaw() const
Getter for yaw_.
Definition: euler_angles_zxy.h:130
T Square(const T value)
Compute squared value.
Definition: math_utils.h:141
EulerAnglesZXY(T qw, T qx, T qy, T qz)
Constructs a rotation using components of a quaternion.
Definition: euler_angles_zxy.h:98
T roll() const
Getter for roll_.
Definition: euler_angles_zxy.h:118
Math-related util functions.
Implements a class of Euler angles (actually, Tait-Bryan angles), with intrinsic sequence ZXY...
Definition: euler_angles_zxy.h:66
EulerAnglesZXY(const Eigen::Quaternion< T > &q)
Constructs a rotation from quaternion.
Definition: euler_angles_zxy.h:111
T pitch() const
Getter for pitch_.
Definition: euler_angles_zxy.h:124