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
[legend]

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

 dcm
 
 euler
 
 q
 

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

 _dcm
 
 _euler
 
 _q
 

Detailed Description

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

Usage:
    >>> 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 quaternion.py.

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 quaternion.py.

Member Function Documentation

def pymavlink.quaternion.QuaternionBase.__eq__ (   self,
  other 
)
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 quaternion.py.

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

Definition at line 79 of file quaternion.py.

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

Definition at line 227 of file quaternion.py.

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

Definition at line 449 of file quaternion.py.

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

Definition at line 241 of file quaternion.py.

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

Definition at line 417 of file quaternion.py.

def pymavlink.quaternion.QuaternionBase._dcm_to_q (   self,
  dcm 
)
private
Create q from dcm
Reference:
    - Shoemake, Quaternions,
    http://www.cs.ucr.edu/~vbz/resources/quatut.pdf

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

Definition at line 350 of file quaternion.py.

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

Definition at line 386 of file quaternion.py.

def pymavlink.quaternion.QuaternionBase._euler_to_q (   self,
  euler 
)
private
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 quaternion.py.

def pymavlink.quaternion.QuaternionBase._mul_array (   self,
  p,
  q 
)
private
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 quaternion.py.

def pymavlink.quaternion.QuaternionBase._q_inversed (   self,
  q 
)
private
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 quaternion.py.

def pymavlink.quaternion.QuaternionBase._q_to_dcm (   self,
  q 
)
private
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 quaternion.py.

def pymavlink.quaternion.QuaternionBase.close (   self,
  other 
)
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 quaternion.py.

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

:returns: 3x3 array

Definition at line 130 of file quaternion.py.

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

Definition at line 146 of file quaternion.py.

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 quaternion.py.

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

Definition at line 115 of file quaternion.py.

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

:returns: inversed quaternion

Definition at line 194 of file quaternion.py.

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

:returns: norm (scalar)

Definition at line 181 of file quaternion.py.

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

Definition at line 267 of file quaternion.py.

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

Definition at line 189 of file quaternion.py.

def pymavlink.quaternion.QuaternionBase.normalize_array (   q)
static
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 quaternion.py.

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

Definition at line 65 of file quaternion.py.

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

Definition at line 84 of file quaternion.py.

def pymavlink.quaternion.QuaternionBase.transform (   self,
  v 
)
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 quaternion.py.

Member Data Documentation

pymavlink.quaternion.QuaternionBase._dcm
private

Definition at line 94 of file quaternion.py.

pymavlink.quaternion.QuaternionBase._euler
private

Definition at line 93 of file quaternion.py.

pymavlink.quaternion.QuaternionBase._q
private

Definition at line 73 of file quaternion.py.

pymavlink.quaternion.QuaternionBase.dcm

Definition at line 56 of file quaternion.py.

pymavlink.quaternion.QuaternionBase.euler

Definition at line 60 of file quaternion.py.

pymavlink.quaternion.QuaternionBase.q

Definition at line 54 of file quaternion.py.


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


mavlink
Author(s): Lorenz Meier
autogenerated on Sun Jul 7 2019 03:22:08