Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
pymavlink.quaternion.QuaternionBase Class Reference
Inheritance diagram for pymavlink.quaternion.QuaternionBase:
Inheritance graph

Public Member Functions

def __eq__ (self, other)
def __getitem__ (self, index)
def __init__ (self, attitude=[1)
def __mul__ (self, other)
def __str__ (self)
def __truediv__ (self, other)
def close (self, other)
def dcm (self)
def dcm (self, dcm)
def euler (self)
def euler (self, euler)
def inversed (self)
def norm (self)
def normalize (self)
def q (self)
def q (self, q)
def transform (self, v)

Static Public Member Functions

def norm_array (q)
def normalize_array (q)

Public Attributes


Private Member Functions

def _dcm_to_euler (self, dcm)
def _dcm_to_q (self, dcm)
def _euler_to_dcm (self, euler)
def _euler_to_q (self, euler)
def _mul_array (self, p, q)
def _q_inversed (self, q)
def _q_to_dcm (self, q)

Private Attributes


Detailed Description

Quaternion class, this is the version which supports numpy arrays
If you need support for Matrix3 look at the Quaternion class

    >>> from quaternion import QuaternionBase
    >>> import numpy as np
    >>> q = QuaternionBase([np.radians(20), np.radians(20), np.radians(20)])
    >>> print(q)
    [ 0.9603483   0.13871646  0.19810763  0.13871646]
    >>> print(q.dcm)
    [[ 0.88302222 -0.21147065  0.41898917]
     [ 0.3213938   0.92303098 -0.21147065]
     [-0.34202014  0.3213938   0.88302222]]
    >>> q = QuaternionBase([1, 0, 0, 0])
    >>> print(q.euler)
    [ 0. -0.  0.]
    >>> m = [[1, 0, 0], [0, 0, -1], [0, 1, 0]]
    >>> q = QuaternionBase(m)
    >>> vector = [0, 1, 0]
    >>> vector2 = q.transform(vector)

Definition at line 20 of file

Constructor & Destructor Documentation

def pymavlink.quaternion.QuaternionBase.__init__ (   self,
  attitude = [1 
Construct a quaternion from an attitude

:param attitude: another QuaternionBase,
    3 element list [roll, pitch, yaw],
    4 element list [w, x, y ,z], DCM (3x3 array)

Definition at line 45 of file

Member Function Documentation

def pymavlink.quaternion.QuaternionBase.__eq__ (   self,
Equality test (same orientation, not necessarily same rotation)

:param other: a QuaternionBase
:returns: true if the quaternions are equal

Definition at line 203 of file

def pymavlink.quaternion.QuaternionBase.__getitem__ (   self,
Returns the quaternion entry at index

Definition at line 79 of file

def pymavlink.quaternion.QuaternionBase.__mul__ (   self,
:param other: QuaternionBase
:returns: multiplaction of this Quaternion with other

Definition at line 227 of file

def pymavlink.quaternion.QuaternionBase.__str__ (   self)
String of quaternion values

Definition at line 449 of file

def pymavlink.quaternion.QuaternionBase.__truediv__ (   self,
:param other: QuaternionBase
:returns: division of this Quaternion with other

Definition at line 241 of file

def pymavlink.quaternion.QuaternionBase._dcm_to_euler (   self,
Create DCM from euler angles
:param dcm: 3x3 dcm array
:returns: array [roll, pitch, yaw] in rad

Definition at line 417 of file

def pymavlink.quaternion.QuaternionBase._dcm_to_q (   self,
Create q from dcm
    - Shoemake, Quaternions,

:param dcm: 3x3 dcm array
returns: quaternion array

Definition at line 350 of file

def pymavlink.quaternion.QuaternionBase._euler_to_dcm (   self,
Create DCM from euler angles
:param euler: array [roll, pitch, yaw] in rad
:returns: 3x3 dcm array

Definition at line 386 of file

def pymavlink.quaternion.QuaternionBase._euler_to_q (   self,
Create q array from euler angles
:param euler: array [roll, pitch, yaw] in rad
:returns: array q which represents a quaternion [w, x, y, z]

Definition at line 295 of file

def pymavlink.quaternion.QuaternionBase._mul_array (   self,
Performs multiplication of the 2 quaterniona arrays p and q
:param p: array of len 4
:param q: array of len 4
:returns: array of len, result of p * q (with p, q quaternions)

Definition at line 276 of file

def pymavlink.quaternion.QuaternionBase._q_inversed (   self,
Returns inversed quaternion q
:param q: array q which represents a quaternion [w, x, y, z]
:returns: inversed array q which is a quaternion [w, x, y ,z]

Definition at line 440 of file

def pymavlink.quaternion.QuaternionBase._q_to_dcm (   self,
Create DCM from q
:param q: array q which represents a quaternion [w, x, y, z]
:returns: 3x3 dcm array

Definition at line 322 of file

def pymavlink.quaternion.QuaternionBase.close (   self,
Equality test with tolerance
(same orientation, not necessarily same rotation)

:param other: a QuaternionBase
:returns: true if the quaternions are almost equal

Definition at line 214 of file

def pymavlink.quaternion.QuaternionBase.dcm (   self)
Get the DCM

:returns: 3x3 array

Definition at line 130 of file

def pymavlink.quaternion.QuaternionBase.dcm (   self,
Set the DCM
:param dcm: 3x3 array

Definition at line 146 of file

def pymavlink.quaternion.QuaternionBase.euler (   self)
Get the euler angles.
The convention is Tait-Bryan (ZY'X'')

:returns: array containing the euler angles [roll, pitch, yaw]

Definition at line 97 of file

def pymavlink.quaternion.QuaternionBase.euler (   self,
Set the euler angles
:param euler: list or array of the euler angles [roll, pitch, yaw]

Definition at line 115 of file

def pymavlink.quaternion.QuaternionBase.inversed (   self)
Get inversed quaternion

:returns: inversed quaternion

Definition at line 194 of file

def pymavlink.quaternion.QuaternionBase.norm (   self)
Returns norm of quaternion

:returns: norm (scalar)

Definition at line 181 of file

def pymavlink.quaternion.QuaternionBase.norm_array (   q)
Calculate quaternion norm on array q
:param quaternion: array of len 4
:returns: norm (scalar)

Definition at line 267 of file

def pymavlink.quaternion.QuaternionBase.normalize (   self)
Normalizes the quaternion

Definition at line 189 of file

def pymavlink.quaternion.QuaternionBase.normalize_array (   q)
Normalizes the list with len 4 so that it can be used as quaternion
:param q: array of len 4
:returns: normalized array

Definition at line 255 of file

def pymavlink.quaternion.QuaternionBase.q (   self)
Get the quaternion
:returns: array containing the quaternion elements

Definition at line 65 of file

def pymavlink.quaternion.QuaternionBase.q (   self,
Set the quaternion
:param q: list or array of quaternion values [w, x, y, z]

Definition at line 84 of file

def pymavlink.quaternion.QuaternionBase.transform (   self,
Calculates the vector transformed by this quaternion
:param v: array with len 3 to be transformed
:returns: transformed vector

Definition at line 163 of file

Member Data Documentation


Definition at line 94 of file


Definition at line 93 of file


Definition at line 73 of file


Definition at line 56 of file


Definition at line 60 of file


Definition at line 54 of file

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

Author(s): Lorenz Meier
autogenerated on Sun Apr 7 2019 02:06:02