This package provides an Extended Kalman Filter (EKF) algorithm for attitude estimation by fusing data from inertial measurement unit (IMU) sensors. It offers robust and accurate estimation of Quaternion and Euler angles representing the orientation of the sensor in 3D space.
Project description
imumaster
这个库中目前仅适用于一种常见坐标系定义下的惯性传感器姿态,通过EKF算法对传感器数据(九轴——加速度计、陀螺仪、磁力计)进行姿态解算并返回惯性传感器运动过程中解算结果——欧拉角和四元数。
imu传感器以及地面坐标系均为右手坐标系
imu传感器坐标系定义:x轴指向前,y轴指向左,z轴指向上;
地面坐标系的定义:x轴指向北,y轴指向西,z轴指向天;
欧拉角定义:
翻滚角Roll——绕x轴旋转;
俯仰角Pitch——绕y轴旋转;
偏航角Yaw——绕z轴旋转。
另外还提供四元数的通用计算函数,如加减乘,共轭,逆,范数,归一化等。
Quick Start
1.install
pip install imumaster
2.import
from imumaster import EKF_AHRS
3.initial
EKF = EKF_AHRS(sample_dt, g_vector, x_k_minus_1, P_k_minus_1, Q_noise=, R1_noise, R2_noise)
params introduction:
sample_dt——采样间隔;
g_vector——重力向量在惯性传感器的感应方向,默认为指向正上方:
[0,0,1]
x_k_minus_1——EKF解算的状态量,这里采用四元数作为状态量。默认为:
[1.0, 0.0, 0.0, 0.0]
也可根据加速度和磁力计数据自行计算初始四元数。
P_k_minus_1——状态量的协方差。默认为:
[[0.001 0. 0. 0. ]
[0. 0.001 0. 0. ]
[0. 0. 0.001 0. ]
[0. 0. 0. 0.001]]
Q_noise—— 过程噪声协方差矩阵。默认为:
[[0.1 0. 0. 0. ]
[0. 0.1 0. 0. ]
[0. 0. 0.1 0. ]
[0. 0. 0. 0.1]]
# R2磁力计
R1_noise——加速度计观测噪声协方差矩阵。默认为:
[[3.8 0. 0. ]
[0. 3.8 0. ]
[0. 0. 3.8]]
R2_noise——磁力计观测噪声协方差矩阵。默认为:
[[0.5 0. 0. ]
[0. 0.5 0. ]
[0. 0. 0.5]]
4.姿态解算。
roll, pitch, yaw, quaternion = EKF.ekf_apply(accel, gyro, mag)
类型说明
accel, gyro, mag 分别为包含三个轴向数据的一维数组。
roll, pitch, yaw 分别为浮点数。
quaternion 为四元数一维数组,quaternion = [w, x, y, z],四元数实部/标量在前。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file imutesting-0.0.20.tar.gz
.
File metadata
- Download URL: imutesting-0.0.20.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83d0d8e45043e728bbeb72b564e3fc61ca3e6d90d7df05b6e01f7354dd2e2c94 |
|
MD5 | 1e366c16fc80d60c825856241ee03a22 |
|
BLAKE2b-256 | 2112e24f218cc0da8fd7050d3ed6733f63165b38af17c8281ecbbc10818700b1 |
File details
Details for the file imutesting-0.0.20-py3-none-any.whl
.
File metadata
- Download URL: imutesting-0.0.20-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c901b8361904edd678e1875e6ff6aae46397565c4e2167c8356849442a286bdb |
|
MD5 | 1e8467fa3eb69885b89eae9507898fe6 |
|
BLAKE2b-256 | 7dd002ba83fe1510e6ed890570857fb8a829a3f41a72fb018055730e09884a8b |