motor-python 0.0.2__py3-none-any.whl

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,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"
motor_python/utils.py ADDED
@@ -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
@@ -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,9 @@
1
+ motor_python/__init__.py,sha256=Qj1a01QckaNqIJr7l-KiIqE9uqgXNVkdrkjBaLoZFqA,48
2
+ motor_python/__main__.py,sha256=ZQ5onJIoPOtu5EHZFg45g11-xdn9wb9zAy9eylZ9nD0,1111
3
+ motor_python/cube_mars_motor.py,sha256=xuGWt4KcMOTbGtiODXR-HGkGLZ5FDxWINnKM9xAKtg8,151
4
+ motor_python/defintions.py,sha256=84ktNPHBI63zKxScWpm-nmb8hnMzATi_1A1Z4ZQ8aWA,903
5
+ motor_python/utils.py,sha256=Un4v-RiBLkqMzFwnI9XL2dwe3l6E_kU7lpMYvasfRBQ,1811
6
+ motor_python-0.0.2.dist-info/METADATA,sha256=IVhknjVQuQFleBdLoJqDEjguRQgd7u43GHvS2weRH-I,2236
7
+ motor_python-0.0.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
8
+ motor_python-0.0.2.dist-info/licenses/LICENSE,sha256=J_-eQzWwyPIh9eTZiUZaRO2IRicN-EQlYTMvlmYtdM0,1070
9
+ motor_python-0.0.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -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.