PX4 Firmware
PX4 Autopilot Software http://px4.io
rotation.h File Reference

Vector rotation library. More...

#include <unistd.h>
#include <mathlib/mathlib.h>
#include <matrix/math.hpp>
Include dependency graph for rotation.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rot_lookup_t
 

Enumerations

enum  Rotation {
  ROTATION_NONE = 0, ROTATION_YAW_45 = 1, ROTATION_YAW_90 = 2, ROTATION_YAW_135 = 3,
  ROTATION_YAW_180 = 4, ROTATION_YAW_225 = 5, ROTATION_YAW_270 = 6, ROTATION_YAW_315 = 7,
  ROTATION_ROLL_180 = 8, ROTATION_ROLL_180_YAW_45 = 9, ROTATION_ROLL_180_YAW_90 = 10, ROTATION_ROLL_180_YAW_135 = 11,
  ROTATION_PITCH_180 = 12, ROTATION_ROLL_180_YAW_225 = 13, ROTATION_ROLL_180_YAW_270 = 14, ROTATION_ROLL_180_YAW_315 = 15,
  ROTATION_ROLL_90 = 16, ROTATION_ROLL_90_YAW_45 = 17, ROTATION_ROLL_90_YAW_90 = 18, ROTATION_ROLL_90_YAW_135 = 19,
  ROTATION_ROLL_270 = 20, ROTATION_ROLL_270_YAW_45 = 21, ROTATION_ROLL_270_YAW_90 = 22, ROTATION_ROLL_270_YAW_135 = 23,
  ROTATION_PITCH_90 = 24, ROTATION_PITCH_270 = 25, ROTATION_ROLL_270_YAW_270 = 26, ROTATION_ROLL_180_PITCH_270 = 27,
  ROTATION_PITCH_90_YAW_180 = 28, ROTATION_PITCH_90_ROLL_90 = 29, ROTATION_YAW_293_PITCH_68_ROLL_90 = 30, ROTATION_PITCH_90_ROLL_270 = 31,
  ROTATION_PITCH_9_YAW_180 = 32, ROTATION_PITCH_45 = 33, ROTATION_PITCH_315 = 34, ROTATION_ROLL_90_YAW_270 = 35,
  ROTATION_MAX
}
 Enum for board and external compass rotations. More...
 

Functions

__EXPORT matrix::Dcmf get_rot_matrix (enum Rotation rot)
 Get the rotation matrix. More...
 
__EXPORT matrix::Quatf get_rot_quaternion (enum Rotation rot)
 Get the rotation quaternion. More...
 
__EXPORT void rotate_3f (enum Rotation rot, float &x, float &y, float &z)
 rotate a 3 element float vector in-place More...
 

Variables

const rot_lookup_t rot_lookup []
 

Detailed Description

Vector rotation library.

Definition in file rotation.h.

Enumeration Type Documentation

◆ Rotation

enum Rotation

Enum for board and external compass rotations.

This enum maps from board attitude to airframe attitude.

Enumerator
ROTATION_NONE 
ROTATION_YAW_45 
ROTATION_YAW_90 
ROTATION_YAW_135 
ROTATION_YAW_180 
ROTATION_YAW_225 
ROTATION_YAW_270 
ROTATION_YAW_315 
ROTATION_ROLL_180 
ROTATION_ROLL_180_YAW_45 
ROTATION_ROLL_180_YAW_90 
ROTATION_ROLL_180_YAW_135 
ROTATION_PITCH_180 
ROTATION_ROLL_180_YAW_225 
ROTATION_ROLL_180_YAW_270 
ROTATION_ROLL_180_YAW_315 
ROTATION_ROLL_90 
ROTATION_ROLL_90_YAW_45 
ROTATION_ROLL_90_YAW_90 
ROTATION_ROLL_90_YAW_135 
ROTATION_ROLL_270 
ROTATION_ROLL_270_YAW_45 
ROTATION_ROLL_270_YAW_90 
ROTATION_ROLL_270_YAW_135 
ROTATION_PITCH_90 
ROTATION_PITCH_270 
ROTATION_ROLL_270_YAW_270 
ROTATION_ROLL_180_PITCH_270 
ROTATION_PITCH_90_YAW_180 
ROTATION_PITCH_90_ROLL_90 
ROTATION_YAW_293_PITCH_68_ROLL_90 
ROTATION_PITCH_90_ROLL_270 
ROTATION_PITCH_9_YAW_180 
ROTATION_PITCH_45 
ROTATION_PITCH_315 
ROTATION_ROLL_90_YAW_270 
ROTATION_MAX 

Definition at line 51 of file rotation.h.

Function Documentation

◆ get_rot_matrix()

__EXPORT matrix::Dcmf get_rot_matrix ( enum Rotation  rot)

Get the rotation matrix.

Definition at line 45 of file rotation.cpp.

References math::radians(), and rot_lookup.

Referenced by DfAK8963Wrapper::DfAK8963Wrapper(), DfHmc5883Wrapper::DfHmc5883Wrapper(), DfLsm9ds1Wrapper::DfLsm9ds1Wrapper(), DfMPU6050Wrapper::DfMPU6050Wrapper(), do_accel_calibration(), VehicleAcceleration::ParametersUpdate(), VehicleAngularVelocity::ParametersUpdate(), sensors::VotedSensorsUpdate::parametersUpdate(), and read_accelerometer_avg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_rot_quaternion()

__EXPORT matrix::Quatf get_rot_quaternion ( enum Rotation  rot)

Get the rotation quaternion.

Definition at line 54 of file rotation.cpp.

References math::radians(), and rot_lookup.

Referenced by MavlinkStreamAttitudeQuaternion::send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotate_3f()

__EXPORT void rotate_3f ( enum Rotation  rot,
float &  x,
float &  y,
float &  z 
)

Variable Documentation

◆ rot_lookup

const rot_lookup_t rot_lookup[]

Definition at line 97 of file rotation.h.

Referenced by get_rot_matrix(), and get_rot_quaternion().