motorbridge-smart-servo Python Binding Guide
This package is the PyO3 + maturin Python binding for MotorBridge Smart Servo. It currently targets the FashionStar UART smart-servo protocol.
Current status (important): angle write/control commands are temporarily considered unsupported in this project release line. Read/monitor APIs are the supported and recommended path.
The Rust core is compiled into motorbridge_smart_servo._native, so the wheel
contains native code directly. There is no runtime ctypes.CDLL(...) loading
step and no external ABI DLL/SO required by Python.
What "Raw" vs "Calibrated/Filtered" Data Means
read_angle() returns an AngleSample with:
raw_deg: protocol angle from the servo packet.filtered_deg: reliability-filtered angle for application logic.reliable:Falsewhen the filter is temporarily holding the last safe value.
For control/planning/business logic, use filtered_deg.
sample = bus.read_angle(servo_id=0, multi_turn=True)
raw_angle = sample.raw_deg
safe_angle = sample.filtered_deg
is_reliable = sample.reliable
API Summary
Main classes:
SmartServoBus(vendor-neutral entry)FashionStarServo(direct vendor class)
Common methods:
scan(max_id=253) -> list[int]ping(servo_id) -> boolread_angle(servo_id, multi_turn=True) -> AngleSampleread_raw_angle(servo_id, multi_turn=True) -> floatread_filtered_angle(servo_id, multi_turn=True) -> floatmonitor(servo_id, multi_turn=True, interval_s=0.02, count=None)set_angle(servo_id, angle_deg, multi_turn=False, interval_ms=0)
Note: set_angle is currently kept for API compatibility, but write-control
behavior is not guaranteed at this stage.
Quick Start (Development Install)
Linux/macOS:
cd bindings/python
python -m pip install -U pip maturin
python -m pip install -e .
Windows PowerShell:
cd bindings\python
python -m pip install -U pip maturin
python -m pip install -e .
Basic Usage
from motorbridge_smart_servo import SmartServoBus
with SmartServoBus.open(
vendor="fashionstar",
port="/dev/ttyUSB0", # e.g. "COM5" on Windows
baudrate=1_000_000,
) as bus:
online = bus.scan(max_id=20)
print("online:", online)
sample = bus.read_angle(0, multi_turn=True)
print(
f"raw={sample.raw_deg:.3f}, "
f"filtered={sample.filtered_deg:.3f}, "
f"reliable={sample.reliable}"
)
# Use filtered angle in your control logic.
angle_for_control = sample.filtered_deg
Direct vendor class:
from motorbridge_smart_servo import FashionStarServo
with FashionStarServo("/dev/ttyUSB0", 1_000_000) as bus:
print(bus.ping(0))
Continuous Monitoring
with SmartServoBus.open(vendor="fashionstar", port="/dev/ttyUSB0") as bus:
for sample in bus.monitor(0, multi_turn=True, interval_s=0.02):
print(
f"raw={sample.raw_deg:9.3f} "
f"filtered={sample.filtered_deg:9.3f} "
f"reliable={sample.reliable}"
)
monitor() keeps streaming after transient timeout once at least one valid
sample has been observed. In those moments you can see reliable=False while
filtered_deg holds the last safe value.
Move Command (Temporarily Unsupported)
with SmartServoBus.open(vendor="fashionstar", port="/dev/ttyUSB0") as bus:
bus.set_angle(0, -45.0, multi_turn=False, interval_ms=500)
For now, treat movement control as experimental and disabled in production use. Use read/monitor methods for stable operation.
Build a Wheel (.whl)
Linux/macOS:
cd bindings/python
python -m pip install -U pip maturin build twine
python -m maturin build --release --out dist
python -m twine check dist/*
python -m pip install --force-reinstall dist/*.whl
Windows PowerShell:
cd bindings\python
python -m pip install -U pip maturin build twine
python -m maturin build --release --out dist
python -m twine check dist\*
python -m pip install --force-reinstall (Get-ChildItem dist\*.whl | Select-Object -Last 1).FullName
Build Wheels for Publishing (Recommended)
For distribution, build in CI for each target platform (Windows/Linux/macOS) to avoid local toolchain differences.
Suggested targets:
- Windows:
x86_64 - Linux:
x86_64,aarch64 - macOS:
arm64(and optionallyx86_64)
This package uses abi3 (cp39-abi3), so one wheel per platform/arch can
cover multiple Python versions (3.9+), but you still need separate wheels per
OS/architecture.
Publish to PyPI
- Update version in
bindings/python/pyproject.toml. - Build wheels and (optionally) source dist.
- Validate artifacts:
python -m twine check dist/*
- Upload to TestPyPI first:
python -m twine upload --repository testpypi dist/*
- Install from TestPyPI and run smoke test:
python -m pip install -i https://test.pypi.org/simple/ motorbridge-smart-servo
python -c "import motorbridge_smart_servo; print('ok')"
- Upload to production PyPI:
python -m twine upload dist/*
Use API tokens for Twine auth (__token__ username).
Release Checklist
cargo test --workspacepython -m compileall bindings/python/src examples/python- Import smoke:
python -c "import motorbridge_smart_servo as m; print(m.__name__)" - CLI smoke:
python -m motorbridge_smart_servo.cli --help twine check dist/*
Troubleshooting
externally-managed-environment(PEP 668): use a virtual environment.No such file or directorywhen opening serial port: wrongportpath.- Permission denied on Linux serial device: add user to
dialoutand relogin. library_pathargument is unsupported with PyO3 backend by design.
Metadata
Release files for motorbridge-smart-servo 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| motorbridge_smart_servo-0.0.4.tar.gz | 20.4 kB | Without provenance | Details for motorbridge_smart_servo-0.0.4.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| motorbridge_smart_servo-0.0.4-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for motorbridge_smart_servo-0.0.4-cp39-abi3-win_amd64.whl |
| motorbridge_smart_servo-0.0.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for motorbridge_smart_servo-0.0.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| motorbridge_smart_servo-0.0.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for motorbridge_smart_servo-0.0.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| motorbridge_smart_servo-0.0.4-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for motorbridge_smart_servo-0.0.4-cp39-abi3-macosx_11_0_arm64.whl |
Total release size: 1.2 MB
Release files / motorbridge_smart_servo-0.0.4.tar.gz
| Download URL | motorbridge_smart_servo-0.0.4.tar.gz |
|---|---|
| Size | 20.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb65f3f6e765e6b1915071c255caaf112fad3796fa1761aeee0132d15b8a0989
|
|
BLAKE2b-256 checksum How to use checksums |
e65645af87189dc49abbe46157b792b7c71f502a5f819f04e7485de0cfa52d9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / motorbridge_smart_servo-0.0.4-cp39-abi3-win_amd64.whl
| Download URL | motorbridge_smart_servo-0.0.4-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 194.1 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ea3baa9ba25bcec5541f3d86d73a3406ba2fcffe5dbf900c22e058638fc31ab0
|
|
BLAKE2b-256 checksum How to use checksums |
2dfa539ea123a5660c22c5e5cdad62d7bc5e931c816a0ffd402ae6e4623ab45b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / motorbridge_smart_servo-0.0.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | motorbridge_smart_servo-0.0.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 348.1 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8c1982643c496c9f425fa9238f9a92ba601d77f4f2279df68c6868e7b997cbe1
|
|
BLAKE2b-256 checksum How to use checksums |
9b6be65e7227a510236c6334cf054c501d3de2cbd463f4c594e42c6e965d5143
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / motorbridge_smart_servo-0.0.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | motorbridge_smart_servo-0.0.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 345.7 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
348cef6a647e5c7f9cc8e8ce1f3c806af4522e1087172bac2f8a1a0daa3592b6
|
|
BLAKE2b-256 checksum How to use checksums |
3fd271c87063b826433553ce8869b99df3e4f191b107710dd5c905e637512b10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / motorbridge_smart_servo-0.0.4-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | motorbridge_smart_servo-0.0.4-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 304.4 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
8bc1f034fa9f96e23229a834db6e7cfe1368dba7b9a2a6f6dbd316448c4390dc
|
|
BLAKE2b-256 checksum How to use checksums |
e9eebec4b3acf55cd18e7db83a6d951caccf699533dbd038c1f0b5f2d16d5208
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for motorbridge-smart-servo 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.