Skip to main content

Attitude estimation using inertial measurement units 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(yaw.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, w_i, 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 is neglected, and gravitational acceleration is assumed constant.

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.10.tar.gz (26.7 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.10-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: attipy-0.0.10.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for attipy-0.0.10.tar.gz
Algorithm Hash digest
SHA256 3fc3977299f23abd0e3959e0623933832e0c6e983a49cc289c008994fd76e6cf
MD5 bc3a7fada02f8cd22e22bf9ca70b3e12
BLAKE2b-256 525247fbe0b777ccbe3c189c6c8a894df2fbd184661febdd9f8eaed95ecba5d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: attipy-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for attipy-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 92d8dfc8482f5ccc781f422d884993b6abcf5e0564b52257d44f2654e9c3d03b
MD5 15ecb795fdef32852282a693a130b59b
BLAKE2b-256 e76b9134ae8e5b95a9cfe592880087691be58633ec3f98decd94fa6648f62abc

See more details on using hashes here.

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