Fuse IMU data into a Quaternion pose.
To install the library run: pip install py-imu
- Install Poetry
make initto create the virtual environment and install dependenciesmake formatto format the code and check for errorsmake testto run the test suitemake cleanto delete the temporary files and directoriespoetry publish --buildto build and publish to https://pypi.org/project/py-imu
from py_imu.madgwick import Madgwick
from py_imu.motion import Motion
from py_imu.quaternion import Vector3D
def main():
"""Test the modules in py-imu."""
madgwick = Madgwick(frequency=100.0, gain=0.033)
estimator = Motion(
declination=9.27, latitude=32.253460, altitude=730, magfield=47392.3
)
# provide time increment dt based on time expired between each sensor reading
for data in data_stream:
gyr = Vector3D(data[0:3])
acc = Vector3D(data[3:6])
madgwick.update(gyr=gyr, acc=acc, dt=0.01)
estimator.update(q=madgwick.q, acc=acc, timestamp=0.01, moving=True)
if __name__ == "__main__":
main()