Got angle and angular velocity (DMP algorithm)

The tutorial introduces the use of DMP algorithm to calculate the attitude angle.

DMP algorithm

DMP is the motion engine inside the MPU6050, the full name of which is Digital Motion Processor. It directly outputs quaternions, which can reduce the workload of the peripheral microprocessor and avoid tedious filtering and data fusion.

Motion Driver is a software package for its motion sensors from Invensense. It is not all open source. The core algorithm part is compiled into a static link library for ARM processors and MSP430 processors, and is suitable for sensors such as MPU6050, MPU6500, MPU9150, and MPU9250.

Quaternion solution

Using the MPU6050 driver library provided by InvenSense, the raw data will be converted into quaternion output. We need to calculate the quaternion and finally get the attitude data (Euler angle): heading angle (Yaw), roll angle (Roll) and pitch angle (Pitch).

image-20240806150245483

Quaternion to Euler angle

Quaternion

Quaternion is a mathematical tool used to represent three-dimensional rotation, but it is not very intuitive to observe.

Quaternions consist of four real numbers, and the basic representation is as follows:

q=q0+q1i+q2j+q3k

Euler angle

Euler angle is a way to describe the rotation state of an object in three-dimensional space. It is usually composed of three angle values: yaw, roll, and pitch, which is convenient for observing posture.

Conversion formula

Solution code

MPU6050 DMP outputs the quaternion after attitude settlement, in q30 format, magnified 2^32 times (q30 = 2^32 = 1073741824).

Software code

Balance car PID control basics: 08-13 tutorial only provides one project file.