motor-python 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,172 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ ../.coverage
44
+ .coveragerc
45
+ .coverage
46
+ coverage.xml
47
+ .cache
48
+ nosetests.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111
+ .pdm.toml
112
+ .pdm-python
113
+ .pdm-build/
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ .idea
164
+ .idea?
165
+ .DS_Store
166
+ .DS_Store?
167
+
168
+ # pixi environments
169
+ .pixi
170
+ *.egg-info
171
+
172
+ /logs/log_*
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 TUM Aries Lab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: motor_python
3
+ Version: 0.0.2
4
+ Summary: Motor module for exosuit
5
+ Project-URL: homepage, https://github.com/TUM-Aries-Lab/motor-module
6
+ Author-email: Tsmorz <tony.smoragiewicz@tum.de>, Hannes <hannes.nguyen@tum.de>
7
+ License-File: LICENSE
8
+ Requires-Python: <3.14,>=3.11
9
+ Requires-Dist: loguru>=0.7.3
10
+ Requires-Dist: numpy>=2.2.3
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Motor Control Software for Soft Exoskeleton
14
+ [![Coverage Status](https://coveralls.io/repos/github/TUM-Aries-Lab/motor-module/badge.svg?branch=main)](https://coveralls.io/github/TUM-Aries-Lab/motor-module?branch=main)
15
+ ![Docker Image CI](https://github.com/TUM-Aries-Lab/motor-module/actions/workflows/ci.yml/badge.svg)
16
+
17
+
18
+
19
+ ## Install
20
+ To install the library run:
21
+
22
+ ```bash
23
+ uv install motor_python
24
+ ```
25
+
26
+ OR
27
+
28
+ ```bash
29
+ uv install git+https://github.com/TUM-Aries-Lab/motor_python.git@<specific-tag>
30
+ ```
31
+
32
+ ## Publishing
33
+ It's super easy to publish your own packages on PyPI. To build and publish this package run:
34
+ 1. Update the version number in pyproject.toml and imu_module/__init__.py
35
+ 2. Commit your changes and add a git tag "<new.version.number>"
36
+ 3. Push the tag `git push --tag`
37
+
38
+ The package can then be found at: https://pypi.org/project/motor_python
39
+
40
+ ## Module Usage
41
+ ```python
42
+ """Basic docstring for my module."""
43
+
44
+ from loguru import logger
45
+
46
+ from motor_python import definitions
47
+
48
+ def main() -> None:
49
+ """Run a simple demonstration."""
50
+ logger.info("Hello World!")
51
+
52
+ if __name__ == "__main__":
53
+ main()
54
+ ```
55
+
56
+ ## Program Usage
57
+ ```bash
58
+ uv run python -m motor_python
59
+ ```
60
+
61
+ ## Structure
62
+ <!-- TREE-START -->
63
+ ```
64
+ ├── src
65
+ │ └── motor_python
66
+ │ ├── __init__.py
67
+ │ ├── __main__.py
68
+ │ ├── cube_mars_motor.py
69
+ │ ├── defintions.py
70
+ │ └── utils.py
71
+ ├── tests
72
+ │ ├── __init__.py
73
+ │ ├── conftest.py
74
+ │ ├── main_test.py
75
+ │ └── utils_test.py
76
+ ├── .dockerignore
77
+ ├── .gitignore
78
+ ├── .pre-commit-config.yaml
79
+ ├── .python-version
80
+ ├── CONTRIBUTING.md
81
+ ├── Dockerfile
82
+ ├── LICENSE
83
+ ├── Makefile
84
+ ├── README.md
85
+ ├── pyproject.toml
86
+ ├── repo_tree.py
87
+ └── uv.lock
88
+ ```
89
+ <!-- TREE-END -->
@@ -0,0 +1,77 @@
1
+ # Motor Control Software for Soft Exoskeleton
2
+ [![Coverage Status](https://coveralls.io/repos/github/TUM-Aries-Lab/motor-module/badge.svg?branch=main)](https://coveralls.io/github/TUM-Aries-Lab/motor-module?branch=main)
3
+ ![Docker Image CI](https://github.com/TUM-Aries-Lab/motor-module/actions/workflows/ci.yml/badge.svg)
4
+
5
+
6
+
7
+ ## Install
8
+ To install the library run:
9
+
10
+ ```bash
11
+ uv install motor_python
12
+ ```
13
+
14
+ OR
15
+
16
+ ```bash
17
+ uv install git+https://github.com/TUM-Aries-Lab/motor_python.git@<specific-tag>
18
+ ```
19
+
20
+ ## Publishing
21
+ It's super easy to publish your own packages on PyPI. To build and publish this package run:
22
+ 1. Update the version number in pyproject.toml and imu_module/__init__.py
23
+ 2. Commit your changes and add a git tag "<new.version.number>"
24
+ 3. Push the tag `git push --tag`
25
+
26
+ The package can then be found at: https://pypi.org/project/motor_python
27
+
28
+ ## Module Usage
29
+ ```python
30
+ """Basic docstring for my module."""
31
+
32
+ from loguru import logger
33
+
34
+ from motor_python import definitions
35
+
36
+ def main() -> None:
37
+ """Run a simple demonstration."""
38
+ logger.info("Hello World!")
39
+
40
+ if __name__ == "__main__":
41
+ main()
42
+ ```
43
+
44
+ ## Program Usage
45
+ ```bash
46
+ uv run python -m motor_python
47
+ ```
48
+
49
+ ## Structure
50
+ <!-- TREE-START -->
51
+ ```
52
+ ├── src
53
+ │ └── motor_python
54
+ │ ├── __init__.py
55
+ │ ├── __main__.py
56
+ │ ├── cube_mars_motor.py
57
+ │ ├── defintions.py
58
+ │ └── utils.py
59
+ ├── tests
60
+ │ ├── __init__.py
61
+ │ ├── conftest.py
62
+ │ ├── main_test.py
63
+ │ └── utils_test.py
64
+ ├── .dockerignore
65
+ ├── .gitignore
66
+ ├── .pre-commit-config.yaml
67
+ ├── .python-version
68
+ ├── CONTRIBUTING.md
69
+ ├── Dockerfile
70
+ ├── LICENSE
71
+ ├── Makefile
72
+ ├── README.md
73
+ ├── pyproject.toml
74
+ ├── repo_tree.py
75
+ └── uv.lock
76
+ ```
77
+ <!-- TREE-END -->
@@ -0,0 +1,67 @@
1
+ [project]
2
+ name = "motor_python"
3
+ version = "0.0.2"
4
+ description = "Motor module for exosuit"
5
+ readme = "README.md"
6
+ authors = [{ name = "Tsmorz", email = "tony.smoragiewicz@tum.de"},{ name = "Hannes", email = "hannes.nguyen@tum.de" }]
7
+ requires-python = ">=3.11,<3.14"
8
+
9
+ # --- Core dependencies: NO hardware here ---
10
+ dependencies = [
11
+ "numpy>=2.2.3",
12
+ "loguru>=0.7.3",
13
+ ]
14
+
15
+ [dependency-groups]
16
+ dev = [
17
+ "ruff>=0.6.9",
18
+ "mypy>=1.11",
19
+ "pytest>=8.3",
20
+ "pytest-cov>=6.0",
21
+ "pre-commit>=4.1.0",
22
+ "coveralls>=4.0.1",
23
+ "pyright>=1.1.407",
24
+ ]
25
+
26
+ [project.urls]
27
+ homepage = "https://github.com/TUM-Aries-Lab/motor-module"
28
+
29
+ [tool.ruff]
30
+ line-length = 88
31
+ fix = true
32
+
33
+ lint.select = [
34
+ "E","F","W","C90","I","N","D","UP","B","S","YTT","Q","PL","RUF","T20","F841","ERA001",
35
+ ]
36
+
37
+ lint.ignore = [
38
+ "D203","D213","E501","N803","N806","D415","S101","E203","E731",
39
+ "D107","PLR2004","S607","S605","S603",
40
+ ]
41
+
42
+ [tool.ruff.lint.isort]
43
+ known-first-party = ["motor_python"]
44
+ combine-as-imports = true
45
+
46
+ [tool.ruff.format]
47
+ quote-style = "double"
48
+ indent-style = "space"
49
+ line-ending = "lf"
50
+
51
+ [build-system]
52
+ requires = ["hatchling"]
53
+ build-backend = "hatchling.build"
54
+
55
+ [tool.hatch.metadata]
56
+ allow-direct-references = true
57
+
58
+ # Tell hatchling where the package lives (src layout)
59
+ [tool.hatch.build.targets.wheel]
60
+ packages = ["src/motor_python"]
61
+
62
+ [tool.hatch.build.targets.sdist]
63
+ include = [
64
+ "src/motor_python",
65
+ "README.md",
66
+ "LICENSE",
67
+ ]
@@ -0,0 +1,3 @@
1
+ """Sample doc string."""
2
+
3
+ __version__ = "0.0.2"
@@ -0,0 +1,44 @@
1
+ """Sample doc string."""
2
+
3
+ import argparse
4
+
5
+ from loguru import logger
6
+
7
+ from motor_python.definitions import DEFAULT_LOG_LEVEL, LogLevel
8
+ from motor_python.utils import setup_logger
9
+
10
+
11
+ def main(
12
+ log_level: str = DEFAULT_LOG_LEVEL, stderr_level: str = DEFAULT_LOG_LEVEL
13
+ ) -> None:
14
+ """Run the main pipeline.
15
+
16
+ :param log_level: The log level to use.
17
+ :param stderr_level: The std err level to use.
18
+ :return: None
19
+ """
20
+ setup_logger(log_level=log_level, stderr_level=stderr_level)
21
+ logger.info("Hello, world!")
22
+
23
+
24
+ if __name__ == "__main__": # pragma: no cover
25
+ parser = argparse.ArgumentParser("Run the pipeline.")
26
+ parser.add_argument(
27
+ "--log-level",
28
+ default=DEFAULT_LOG_LEVEL,
29
+ choices=list(LogLevel()),
30
+ help="Set the log level.",
31
+ required=False,
32
+ type=str,
33
+ )
34
+ parser.add_argument(
35
+ "--stderr-level",
36
+ default=DEFAULT_LOG_LEVEL,
37
+ choices=list(LogLevel()),
38
+ help="Set the std err level.",
39
+ required=False,
40
+ type=str,
41
+ )
42
+ args = parser.parse_args()
43
+
44
+ main(log_level=args.log_level)
@@ -0,0 +1,8 @@
1
+ """Sample doc string."""
2
+
3
+ from loguru import logger
4
+
5
+
6
+ def motor_v3() -> None:
7
+ """Run dummy code for the motor."""
8
+ logger.info("Hello, world!")
@@ -0,0 +1,43 @@
1
+ """Common definitions for this module."""
2
+
3
+ from dataclasses import asdict, dataclass
4
+ from pathlib import Path
5
+
6
+ import numpy as np
7
+
8
+ np.set_printoptions(precision=3, floatmode="fixed", suppress=True)
9
+
10
+
11
+ # --- Directories ---
12
+ ROOT_DIR: Path = Path("src").parent
13
+ DATA_DIR: Path = ROOT_DIR / "data"
14
+ RECORDINGS_DIR: Path = DATA_DIR / "recordings"
15
+ LOG_DIR: Path = DATA_DIR / "logs"
16
+
17
+ # Default encoding
18
+ ENCODING: str = "utf-8"
19
+
20
+ DATE_FORMAT = "%Y-%m-%d_%H-%M-%S"
21
+
22
+ DUMMY_VARIABLE = "dummy_variable"
23
+
24
+
25
+ @dataclass
26
+ class LogLevel:
27
+ """Log level."""
28
+
29
+ trace: str = "TRACE"
30
+ debug: str = "DEBUG"
31
+ info: str = "INFO"
32
+ success: str = "SUCCESS"
33
+ warning: str = "WARNING"
34
+ error: str = "ERROR"
35
+ critical: str = "CRITICAL"
36
+
37
+ def __iter__(self):
38
+ """Iterate over log levels."""
39
+ return iter(asdict(self).values())
40
+
41
+
42
+ DEFAULT_LOG_LEVEL = LogLevel.info
43
+ DEFAULT_LOG_FILENAME = "log_file"
@@ -0,0 +1,59 @@
1
+ """Configure the logger."""
2
+
3
+ import sys
4
+ from datetime import datetime
5
+ from pathlib import Path
6
+
7
+ from loguru import logger
8
+
9
+ from motor_python.definitions import (
10
+ DATE_FORMAT,
11
+ DEFAULT_LOG_FILENAME,
12
+ DEFAULT_LOG_LEVEL,
13
+ ENCODING,
14
+ LOG_DIR,
15
+ )
16
+
17
+
18
+ def create_timestamped_filepath(suffix: str, output_dir: Path, prefix: str) -> Path:
19
+ """Generate a timestamped filename.
20
+
21
+ :param suffix: Suffix to append to the timestamped filename.
22
+ :param output_dir: Output directory.
23
+ :param prefix: Prefix to append to the timestamped filename.
24
+ :return: Path to the timestamped filename.
25
+ """
26
+ timestamp = datetime.now().strftime(DATE_FORMAT)
27
+ filepath = output_dir / f"{prefix}_{timestamp}.{suffix}"
28
+ filepath.parent.mkdir(parents=True, exist_ok=True) # create dirs if missing
29
+ filepath.touch(exist_ok=True) # create empty file (don't overwrite)
30
+ return filepath
31
+
32
+
33
+ def setup_logger(
34
+ filename: str = DEFAULT_LOG_FILENAME,
35
+ stderr_level: str = DEFAULT_LOG_LEVEL,
36
+ log_level: str = DEFAULT_LOG_LEVEL,
37
+ log_dir: Path | None = None,
38
+ ) -> Path:
39
+ """Configure the logger.
40
+
41
+ :param filename: Name of the file to create.
42
+ :param stderr_level: Logging level to use.
43
+ :param log_level: Logging level to use.
44
+ :param log_dir: Logging directory to use.
45
+ :return: Path to the created logfile.
46
+ """
47
+ logger.remove()
48
+
49
+ if log_dir is None:
50
+ log_filepath = LOG_DIR
51
+ else:
52
+ log_filepath = log_dir
53
+ filepath_with_time = create_timestamped_filepath(
54
+ output_dir=log_filepath, prefix=filename, suffix="log"
55
+ )
56
+ logger.add(sys.stderr, level=stderr_level)
57
+ logger.add(filepath_with_time, level=log_level, encoding=ENCODING, enqueue=True)
58
+ logger.info(f"Logging to '{filepath_with_time}'.")
59
+ return filepath_with_time