Metadata-Version: 2.4
Name: bc_stark_sdk
Version: 1.1.1
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
License-File: LICENSE
Summary: BrainCo Stark SDK
Author: BrainCo
License: 	
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Source Code, https://github.com/BrainCoTech/bc-stark-sdk

# BrainCo Stark SDK

Industrial dexterous hand control SDK supporting multiple protocols and platforms.

## Supported Devices

| Device | Type | Motor | Touch | Protocol |
|--------|------|-------|-------|----------|
| Revo1 Basic | 1 | 6-DOF | - | Modbus, CAN |
| Revo1 Touch | 2 | 6-DOF | Capacitive | Modbus, CAN |
| Revo1 Advanced | 3 | 6-DOF | - | Modbus, CAN |
| Revo1 Advanced Touch | 4 | 6-DOF | Capacitive | Modbus, CAN |
| Revo2 Basic | 5 | 6-DOF | - | Modbus, CAN, CANFD |
| Revo2 Touch | 6 | 6-DOF | Capacitive | Modbus, CAN, CANFD |
| Revo2 Touch Pressure | 7 | 6-DOF | Pressure | Modbus, CAN, CANFD |

### Touch Sensor Types

| Type | Devices | Features |
|------|---------|----------|
| Capacitive | Revo1 Touch, Revo1 Advanced Touch, Revo2 Touch | Normal/tangential force, proximity |
| Pressure (Modulus) | Revo2 Touch Pressure | High-precision pressure distribution |

## Protocol & Platform

| Protocol | Linux | macOS | Windows | Adapter |
|----------|:-----:|:-----:|:-------:|---------|
| Modbus RTU | ✅ | ✅ | ✅ | - |
| CAN 2.0 | ✅ | ✅ | ✅ | ZQWL (built-in) |
| CAN FD | ✅ | ✅ | ✅ | ZQWL (built-in) |
| CAN 2.0/FD | ✅ | ❌ | ✅ | ZLG (external DLL) |
| EtherCAT | ✅ | ❌ | ❌ | - |

## API Overview

- Motor control (position, speed, current, force)
- Motor status (angle, current, error, voltage, etc.)
- Touch sensor (proximity, contact, pressure)
- Device info (SN, firmware version, hand type)
- System config (baudrate, CAN ID, limits)
- DFU (firmware update)

Full API: [C Header](dist/include/stark-sdk.h) | [Python Stubs](python/bc_stark_sdk/main_mod.pyi)

## Quick Start

### Python

```bash
# Development build
conda activate py310
bash scripts/build_python.sh

# Run example
cd examples/python/revo2
python revo2_ctrl.py
```

### C/C++

```bash
# Build SDK
bash scripts/build_c.sh

# Build & run examples
cd examples/stark/c
make
make run revo2_ctrl
```

### Rust (internal)

```bash
# Run example
cargo run --example stark_test

# Test
cargo test stark_msg -- --show-output
```

## Build & Publish

### Python

```bash
# Setup conda environment (first time)
conda create -n py310 python=3.10
conda activate py310
pip install maturin patchelf

# Development build
bash scripts/build_python.sh

# Generate stubs (.pyi)
bash scripts/run_stub_gen.sh

# Publish to PyPI
bash scripts/publish_python.sh
```

### C/C++

```bash
# Build SDK
bash scripts/build_c.sh

# Build and upload to OSS
bash scripts/build_c.sh -upload
```

## Cross-Platform Build

### Windows (cross-compile from macOS/Linux)

```bash
# Prerequisites: brew install mingw-w64 && rustup target add x86_64-pc-windows-gnu

# Build Windows DLL
bash scripts/build_win.sh

# Build C++ examples for Windows
cd examples/stark/c
make TARGET=win
```

### Windows (native via GitHub Actions)

Production Windows builds use GitHub Actions with MSVC:

- `.github/workflows/build-c.yml` - Build and upload C SDK (Windows/Linux/macOS)
- `.github/workflows/build-python.yml` - Build and publish Python wheels

### Linux (via Docker)

```bash
# Enter container
docker exec -it projects_x86_64 bash   # x86_64
docker exec -it projects_arm64 bash    # ARM64

# Inside container:
cd bc-stark-sdk
bash scripts/build_c.sh
conda activate py310
bash scripts/build_python.sh
```

## Code Generation

```bash
# Generate C header (stark-sdk.h)
cargo b --lib --release --features stark-cbindgen

# Generate Python stubs (.pyi)
bash scripts/run_stub_gen.sh

# Copy to example repo
bash scripts/copy-to-example.sh
```

## Scripts Reference

| Script | Description |
|--------|-------------|
| `build_c.sh` | Build C SDK (native platform) |
| `build_c.sh -upload` | Build and upload to CDN |
| `build_win.sh` | Cross-compile Windows DLL |
| `build_python.sh` | Build Python wheel (dev) |
| `publish_python.sh` | Publish to PyPI |
| `run_stub_gen.sh` | Generate Python type stubs |
| `copy-to-example.sh` | Sync to example repository |

## Documentation

- [Protocol Overview](docs/PROTOCOL_OVERVIEW.md) - Modbus/CAN/EtherCAT comparison
- [Architecture](docs/ARCHITECTURE.md) - Internal code structure
- [Rust Examples](examples/README.md) - Rust example reference
- [C++ Examples](examples/stark/c/README.md) - Build & run guide
- [CAN Adapter Guide](docs/CAN_ADAPTER_GUIDE.md) - ZQWL/ZLG/SocketCAN setup
- [CAN ID Guide](docs/CAN_ID_GUIDE.md) - CAN protocol details
- [CAN Protocol Comparison](docs/CAN_PROTOCOL_COMPARISON.md) - CAN 2.0 vs CANFD
- [Revo1 Advanced Touch](docs/REVO1_ADVANCED_TOUCH_DESIGN.md) - Hybrid device design
- [EtherCAT Commands](docs/ETHERCAT_COMMANDS.md) - EtherCAT CLI reference
- [Shared Buffer API](docs/SHARED_BUFFER_API.md) - High-performance data collection
- [Parameter Spec](docs/统一参数范围规范.md) - Unified parameter ranges
- [Technical Architecture](docs/StarkSDK-Technical-Architecture.md) - External system design

## Links

- [Example](https://github.com/BrainCoTech/stark-serialport-example)
- [PyPI](https://pypi.org/project/bc-stark-sdk/)
- [Online Docs](https://www.brainco-hz.com/docs/revolimb-hand/revo2/get_sdk.html)

