Metadata-Version: 2.4
Name: codrive
Version: 0.1.1
Summary: Host library and CLI for the CoDrive motor controller
Author-email: Cosyne <kontakt@cosyne.de>
License: MIT
Project-URL: Homepage, https://github.com/cosyne/codrive
Project-URL: Repository, https://github.com/cosyne/codrive
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: pyserial>=3.5
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"

# CoDrive

Python host library and CLI for the **CoDrive** motor controller.

CoDrive is a compact, high-performance motor controller designed for precise velocity, position, and torque control. This package lets you integrate CoDrive into any Python application and provides a ready-to-use command-line interface for quick commissioning and diagnostics.

## Installation

```bash
pip install codrive
```

## Quickstart

### Python API

```python
from codrive import Controller

with Controller("COM3") as ctrl:          # or /dev/ttyUSB0 on Linux
    ctrl.enable()
    ctrl.set_velocity(300)                # 300 RPM
    t = ctrl.get_telemetry()
    print(f"{t.velocity_rpm:.1f} RPM  {t.temperature_c:.1f} °C")
    ctrl.disable()
```

### CLI

```bash
# Enable the drive
codrive COM3 enable

# Spin at 500 RPM
codrive COM3 velocity 500

# Move to 90°
codrive COM3 position 90

# Read live telemetry
codrive COM3 telemetry

# Emergency stop
codrive COM3 estop
```

## Control modes

| Command | Description |
|---------|-------------|
| `set_velocity(rpm)` | Closed-loop speed control |
| `set_position(degrees)` | Absolute position control |
| `set_torque(nm)` | Direct torque / current control |

## Telemetry

`Controller.get_telemetry()` returns a `Telemetry` dataclass with:

- `velocity_rpm` — measured shaft speed (RPM)
- `position_deg` — absolute shaft angle (°)
- `torque_nm` — estimated output torque (N·m)
- `temperature_c` — controller board temperature (°C)
- `fault_flags` — bitmask of active faults

## Requirements

- Python 3.10+
- [pyserial](https://pypi.org/project/pyserial/)
- CoDrive controller connected via USB–serial or UART adapter

## License

MIT © [Cosyne](https://cosyne.de)
