Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

attipy-0.0.17.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

attipy-0.0.17-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file attipy-0.0.17.tar.gz.

File metadata

  • Download URL: attipy-0.0.17.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for attipy-0.0.17.tar.gz
Algorithm Hash digest
SHA256 31f571e31452c60e73bf71868d2dbac7c9eaf5b133d15e6ecb06a5722ae4f909
MD5 b8885b2c7bb04e63735b63548f878c51
BLAKE2b-256 74e0099ee72e5027db5545c23265f8090c407d3e98a06c5b77965073f8ee65d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for attipy-0.0.17.tar.gz:

Publisher: publish.yaml on vegardrsolum/attipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file attipy-0.0.17-py3-none-any.whl.

File metadata

  • Download URL: attipy-0.0.17-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for attipy-0.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 9bd2680f414cb2ea8ba4c5079eba843710eabb92884fe62f25655efb11a5e950
MD5 9cd0009b7ceba620acc6a0888a9319b7
BLAKE2b-256 c6864ff42415c254d9af71766b859e2ff58ede7e327e2cebf3c46f5d94179d2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for attipy-0.0.17-py3-none-any.whl:

Publisher: publish.yaml on vegardrsolum/attipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page