Attitude and Heading Reference Systems.
Project description
AHRS: Attitude and Heading Reference Systems
AHRS is a zoo of functions and objects written in Python helping you to estimate the orientation and position of robotic systems.
Orginally, an AHRS is defined as a set of orthogonal sensors providing attitude information about an aircraft. This field is now expanding to smaller devices, like wearables, automated transportation and all kinds of robots in motion.
The module AHRS is developed with a focus on fast prototyping and easy modularity.
AHRS is compatible with Python 3.6 and above.
Installation
AHRS may be installed using pip:
pip install ahrs
Or using the latest version from the repository:
git clone https://github.com/Mayitzin/ahrs.git
cd ahrs
python setup.py install
AHRS depends on the most distributed packages of Python. If you don't have them, they will be automatically downloaded and installed.
Using AHRS
To play with orientations, for example, we can use the orientation
module.
>>> import ahrs
>>> # Rotation matrix of 30.0 degrees around X-axis
... ahrs.common.orientation.rotation('x', 30.0)
array([[ 1. , 0. , 0. ],
[ 0. , 0.8660254, -0.5 ],
[ 0. , 0.5 , 0.8660254]])
>>> # Rotation sequence of the form: R_y(10.0)@R_x(20.0)@R_z(30.0)
... ahrs.common.orientation.rot_seq('yXy', [10.0, 20.0, 30.0])
array([[ 0.77128058, 0.05939117, 0.63371836],
[ 0.17101007, 0.93969262, -0.29619813],
[-0.61309202, 0.33682409, 0.71461018]])
It also works nicely with Quaternions.
>>> import numpy as np
>>> q = np.random.random(4)
>>> # It automatically normalizes any given vector
... ahrs.common.orientation.q2R(q)
array([[ 0.76811067, 0.3546719 , 0.53311709],
[ 0.55044928, 0.05960693, -0.83273802],
[-0.32712625, 0.93308888, -0.14944417]])
ahrs
also includes a module that simplifies data loading and visualizing
>>> data = ahrs.utils.io.load("ExampleData.mat")
>>> ahrs.utils.plot_sensors(data.gyr, data.acc, data.mag)
If you want to use the sensor data to estimate the attitude, use the filters
module that includes various (more coming) algorithms for it.
>>> madgwick = ahrs.filters.Madgwick()
>>> Q = np.tile([1., 0., 0., 0.], (data.num_samples, 1)) # Allocate an array for all quaternions
>>> d2g = ahrs.common.DEG2RAD # Constant to convert degrees to radians
>>> for t in range(1, data.num_samples):
... Q[t] = madgwick.updateMARG(d2g*data.gyr[t], data.acc[t], data.mag[t], Q[t-1])
...
>>> ahrs.utils.plot_quaternions(Q)
Documentation
A comprehensive documentation, with examples, will soon come to Read the Docs.
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
Hashes for AHRS-0.1.2.post3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71ea83dafdceb72f6affe897e5e9a04d16c94a1106e16cb15365f8ba40f00afb |
|
MD5 | 08e4e80ccef2bf196fefb914b945a405 |
|
BLAKE2b-256 | fe006f1e6d5a54a73def322a3c5996e12869b4aa9948c788482a68ec7c18a67e |