Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
sensor::imu::Quaternion Class Reference

Quaternion class. More...

#include <laeImu.h>

Public Member Functions

 Quaternion ()
 Default constructor.
 
 ~Quaternion ()
 Destructor.
 
Quaternion operator= (const Quaternion &rhs)
 Assignment operator. More...
 
void clear ()
 Clear quaternion values.
 
void convertEuler (double phi, double theta, double psi)
 Convert Euler angles to quaternion. More...
 
void convertTaitBryan (double roll, double pitch, double yaw)
 Convert Tait-Bryan angles to quaternion. More...
 

Public Attributes

double m_x
 x
 
double m_y
 y
 
double m_z
 z
 
double m_w
 w
 

Detailed Description

Quaternion class.

Definition at line 118 of file laeImu.h.

Member Function Documentation

void Quaternion::convertEuler ( double  phi,
double  theta,
double  psi 
)

Convert Euler angles to quaternion.

Parameters
phiAngle between x axis and the N axis (radians).
thetaAngle between z axis and the Z axis (radians).
phiAngle between N axis and the X axis (radians).

Definition at line 95 of file laeImu.cxx.

Referenced by ~Quaternion().

96 {
97  double half_phi, half_theta, half_psi;
98  double cos_phi, sin_phi;
99  double cos_theta, sin_theta;
100  double cos_psi, sin_psi;
101 
102  half_phi = phi / 2.0;
103  half_theta = theta / 2.0;
104  half_psi = psi / 2.0;
105 
106  cos_phi = cos(half_phi);
107  sin_phi = sin(half_phi);
108  cos_theta = cos(half_theta);
109  sin_theta = sin(half_theta);
110  cos_psi = cos(half_psi);
111  sin_psi = sin(half_psi);
112 
113  m_x = cos_phi*cos_theta*cos_psi + sin_phi*sin_theta*sin_psi;
114  m_y = sin_phi*cos_theta*cos_psi - cos_phi*sin_theta*sin_psi;
115  m_z = cos_phi*sin_theta*cos_psi + sin_phi*cos_theta*sin_psi;
116  m_w = cos_phi*cos_theta*sin_psi - sin_phi*sin_theta*cos_psi;
117 }
void Quaternion::convertTaitBryan ( double  roll,
double  pitch,
double  yaw 
)

Convert Tait-Bryan angles to quaternion.

Parameters
rollRotation about the x-axis.
pitchRotation about the y-axis.
yawRotation about the z-axis.

Definition at line 119 of file laeImu.cxx.

Referenced by sensor::imu::LaeImu::computeQuaternion(), and ~Quaternion().

120 {
121  double half_roll = 0.5 * roll;
122  double half_pitch = 0.5 * pitch;
123  double half_yaw = 0.5 * yaw;
124 
125  double t0 = cos(half_yaw);
126  double t1 = sin(half_yaw);
127  double t2 = cos(half_roll);
128  double t3 = sin(half_roll);
129  double t4 = cos(half_pitch);
130  double t5 = sin(half_pitch);
131 
132  m_w = t0 * t2 * t4 + t1 * t3 * t5;
133  m_x = t0 * t3 * t4 - t1 * t2 * t5;
134  m_y = t0 * t2 * t5 + t1 * t3 * t4;
135  m_z = t1 * t2 * t4 - t0 * t3 * t5;
136 }
Quaternion Quaternion::operator= ( const Quaternion rhs)

Assignment operator.

Parameters
rhsRight hand side object.
Returns
Returns copy of this.

Definition at line 77 of file laeImu.cxx.

References m_w, m_x, m_y, and m_z.

Referenced by ~Quaternion().

78 {
79  m_x = rhs.m_x;
80  m_y = rhs.m_y;
81  m_z = rhs.m_z;
82  m_w = rhs.m_w;
83 
84  return *this;
85 }

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