Attitude estimation using IMU measurements in Python
Project description
AttiPy
AttiPy is a lightweight Python library for representing and estimating the attitude (orientation) of a body using IMU measurements and optional external aiding. It provides an attitude abstraction with clearly defined reference frames and rotation conventions, and a multiplicative extended Kalman filter (MEKF) for attitude estimation.
Installation
pip install attipy
Quick start
Convert to/from a variety of attitude representations using the Attitude class:
import attipy as ap
# From Euler angles to unit quaternion
att = ap.Attitude.from_euler([0.0, 0.0, 0.0])
q = att.as_quaternion()
Estimate attitude from IMU (accelerometer and gyroscope) and heading measurements
using the MEKF class:
import attipy as ap
import numpy as np
# Parameters
fs = 10.0 # sampling rate in Hz
acc_noise_density = 0.001 # accelerometer noise density in (m/s^2)/√Hz
gyro_noise_density = 0.0001 # gyroscope noise density in (rad/s)/√Hz
bg = (0.001, 0.002, 0.003) # gyroscope bias in rad/s
yaw_std = 0.01 # heading noise standard deviation in rad
# Position, velocity, attitude and IMU reference signals
t, pos, vel, euler, f, w = ap.pva_sim(fs)
# IMU and heading measurements (with noise)
rng = np.random.default_rng(42)
f_meas = f + acc_noise_density * np.sqrt(fs) * rng.standard_normal(f.shape)
w_meas = w + bg + gyro_noise_density * np.sqrt(fs) * rng.standard_normal(w.shape)
yaw_meas = euler[:, 2] + yaw_std * rng.standard_normal(euler[:, 2].shape)
# Estimate attitude using MEKF
att0 = ap.Attitude.from_euler(euler[0])
mekf = ap.MEKF(fs, att0)
euler_est = []
for f_i, w_i, y_i in zip(f_meas, w_meas, yaw_meas):
mekf.update(f_i / fs, w_i / fs, yaw=y_i, yaw_var=yaw_std**2)
euler_est.append(mekf.attitude.as_euler())
euler_est = np.asarray(euler_est)
Limitations and assumptions
- Intended for small-area, low-velocity applications; Earth rotation effects are neglected.
- Accelerometer biases are not estimated; accelerometer biases will manifest as tilt errors.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file attipy-0.0.14.tar.gz.
File metadata
- Download URL: attipy-0.0.14.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79876b0cce739e183623c493e8408890d636f145c04483c2df22f30040e7babb
|
|
| MD5 |
c474a726be7d8181b6a8ecc2bc313860
|
|
| BLAKE2b-256 |
faf736e018fb151dd2e37eeb4cfbaae49dc36f3f4033980f277b4f13b51912c8
|
Provenance
The following attestation bundles were made for attipy-0.0.14.tar.gz:
Publisher:
publish.yaml on vegardrsolum/attipy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
attipy-0.0.14.tar.gz -
Subject digest:
79876b0cce739e183623c493e8408890d636f145c04483c2df22f30040e7babb - Sigstore transparency entry: 1154986952
- Sigstore integration time:
-
Permalink:
vegardrsolum/attipy@d98c545cb9306fbc1569ba65a7889aa1ef2f9093 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vegardrsolum
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@d98c545cb9306fbc1569ba65a7889aa1ef2f9093 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file attipy-0.0.14-py3-none-any.whl.
File metadata
- Download URL: attipy-0.0.14-py3-none-any.whl
- Upload date:
- Size: 23.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9fe27a74ac423a59da6a132f11fee0d302d85141aaf5a615e8d9fee52ca6816
|
|
| MD5 |
bd53d9a90cb193cd2775bb9950a5c40e
|
|
| BLAKE2b-256 |
f078344fc01a305946ddd42f426e1c5c1a29a34ce4280e65d3d4cc0c692a7c59
|
Provenance
The following attestation bundles were made for attipy-0.0.14-py3-none-any.whl:
Publisher:
publish.yaml on vegardrsolum/attipy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
attipy-0.0.14-py3-none-any.whl -
Subject digest:
a9fe27a74ac423a59da6a132f11fee0d302d85141aaf5a615e8d9fee52ca6816 - Sigstore transparency entry: 1154986955
- Sigstore integration time:
-
Permalink:
vegardrsolum/attipy@d98c545cb9306fbc1569ba65a7889aa1ef2f9093 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vegardrsolum
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@d98c545cb9306fbc1569ba65a7889aa1ef2f9093 -
Trigger Event:
workflow_dispatch
-
Statement type: