IMU sensor codes in Python for the exosuit
Project description
IMU Module for Python
This is the repository for imu sensor codes for the lower-limb exosuit.
To maximize data rates of multiple connected IMUs, Python free-threading build is required for free threading. Free threading is always disabled when running on versions prior to 3.13, and non free-threading builds.
Install
To install the library, run:
uv pip install imu-python
OR
uv pip install git+https://github.com/TUM-Aries-Lab/imu-module.git@<specific-tag>
Development
- Install uv
git clone git@github.com:TUM-Aries-Lab/imu-module.gitmake 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 directories
Publishing
It's super easy to publish your own packages on PyPI. To build and publish this package, run:
- Update the version number in pyproject.toml and imu_module/init.py
- Commit your changes and add a git tag "<new.version.number>"
- Push the tag
git push --tag
The package can then be found at: https://pypi.org/project/imu-python
Module Usage
"""Basic module usage example."""
import time
from loguru import logger
from imu_python.definitions import IMUUpdateTime
from imu_python.factory import IMUFactory
def main() -> None:
"""Run a simple demonstration."""
sensor_managers = IMUFactory.detect_and_create()
for manager in sensor_managers:
manager.start()
try:
while True:
for manager in sensor_managers:
logger.info(manager.get_data())
time.sleep(IMUUpdateTime.freq_hz)
#Note: this read frequency is independent of IMUs actual hardware frequency
except KeyboardInterrupt:
for manager in sensor_managers:
manager.stop()
if __name__ == "__main__":
main()
Adding a new IMU/Changing the config of an existing IMU
To use an IMU that is not defined in the built-in list of the module (defined IMUs are BNO055, BNO08X, and LSM6DSOX+LIS3MDL), follow these steps to register it to the program:
- Add the Adafruit library and driver for the IMU to your project dependencies.
- Define IMU Config / change the config using
replace(See wiki page for more detail.) Store the new configs inyour_project.imu_configs.py. - Register the model in
pyproject.toml:
[project.entry-points."imu_module.devices"]
NEW_IMU = "your_project.imu_configs:NEW_IMU"
where NEW_IMU is the IMUConfig name and your_project.imu_configs is the file where the IMUConfig is defined.
or override an existing built-in device:
[project.entry-points."imu_module.device_overrides"]
BNO055 = "your_project.imu_configs:BNO055_CUSTOM"
- Save edits. With UV, changes in the
pyproject.tomlare synchronized automatically uponuv run. With pip, poetry and conda, a manual module reinstallation may be necessary.
Program Usage
To run the main pipeline for all connected sensors with optional flag -r to record data:
uv run python -m imu_python
To plot a recorded data file, replace filepath with a path to data file:
uv run python src/imu_python/data_handler/data_plotter.py -f "filepath"
To calibrate all connected sensors:
make calibrate
Structure
├── src
│ └── imu_python
│ ├── calibration
│ │ ├── calibration.py
│ │ ├── ellipsoid_fitting.py
│ │ ├── gain_calculator.py
│ │ └── mag_calibration.py
│ ├── data_handler
│ │ ├── data_plotter.py
│ │ ├── data_reader.py
│ │ └── data_writer.py
│ ├── __init__.py
│ ├── __main__.py
│ ├── base_classes.py
│ ├── builtin_devices.py
│ ├── definitions.py
│ ├── devices.py
│ ├── factory.py
│ ├── i2c_bus.py
│ ├── orientation_filters.py
│ ├── registry.py
│ ├── sensor_manager.py
│ ├── utils.py
│ └── wrapper.py
├── tests
│ ├── calibration
│ │ ├── calibration_test.py
│ │ └── gain_calculator_test.py
│ ├── data_handler
│ │ ├── reader_test.py
│ │ └── writer_test.py
│ ├── __init__.py
│ ├── base_classes_test.py
│ ├── conftest.py
│ ├── devices_test.py
│ ├── factory_test.py
│ ├── i2c_bus_test.py
│ ├── orientation_filter_test.py
│ ├── sensor_manager_test.py
│ ├── utils_test.py
│ └── wrapper_test.py
├── .dockerignore
├── .gitignore
├── .pre-commit-config.yaml
├── .python-version
├── CONTRIBUTING.md
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── pyproject.toml
├── repo_tree.py
└── uv.lock
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 imu_python-0.1.1.tar.gz.
File metadata
- Download URL: imu_python-0.1.1.tar.gz
- Upload date:
- Size: 32.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e48e641a8420b3718aa3dc39e870b93a2984acc434e7c52c3642ddbe0dc7cfcf
|
|
| MD5 |
d6116d3b33611c29614de57627fd1022
|
|
| BLAKE2b-256 |
9006d414bcaefd6a9dfa9954d2692df3c897df0aa684a72a5fdf7e36c781f86c
|
Provenance
The following attestation bundles were made for imu_python-0.1.1.tar.gz:
Publisher:
pypi-publish.yml on TUM-Aries-Lab/imu-module
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imu_python-0.1.1.tar.gz -
Subject digest:
e48e641a8420b3718aa3dc39e870b93a2984acc434e7c52c3642ddbe0dc7cfcf - Sigstore transparency entry: 1347944129
- Sigstore integration time:
-
Permalink:
TUM-Aries-Lab/imu-module@a6e527a2753c592a43c614988791678f6cd4e264 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/TUM-Aries-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@a6e527a2753c592a43c614988791678f6cd4e264 -
Trigger Event:
push
-
Statement type:
File details
Details for the file imu_python-0.1.1-py3-none-any.whl.
File metadata
- Download URL: imu_python-0.1.1-py3-none-any.whl
- Upload date:
- Size: 39.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bca7535f6c888313c550fb329714949acd145980bde9ba33470a8aec35ea167
|
|
| MD5 |
53ea9dbabc8dab024ba184c48c1365cc
|
|
| BLAKE2b-256 |
3862e64a4204f6abb091a415ff5b95aef2bfffa47e48686addeb365ae62686e8
|
Provenance
The following attestation bundles were made for imu_python-0.1.1-py3-none-any.whl:
Publisher:
pypi-publish.yml on TUM-Aries-Lab/imu-module
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imu_python-0.1.1-py3-none-any.whl -
Subject digest:
3bca7535f6c888313c550fb329714949acd145980bde9ba33470a8aec35ea167 - Sigstore transparency entry: 1347944575
- Sigstore integration time:
-
Permalink:
TUM-Aries-Lab/imu-module@a6e527a2753c592a43c614988791678f6cd4e264 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/TUM-Aries-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@a6e527a2753c592a43c614988791678f6cd4e264 -
Trigger Event:
push
-
Statement type: