C++版本

This commit is contained in:
cyy_mac
2026-07-26 21:19:22 +08:00
parent 265173e746
commit ee2289d826
6 changed files with 980 additions and 0 deletions

45
fast_lowcmd_cpp/README.md Normal file
View File

@@ -0,0 +1,45 @@
# fast_lowcmd_cpp
Native CPython extension for the Go1 PRO LowCmd hot path.
It keeps the implementation separate from the main `go1_pro_sdk` package until
the robot-side timing and byte-equivalence checks are stable.
## Build
```bash
cd /root/go1_pro_sdk/fast_lowcmd_cpp
PYTHONPATH=/root/go1_pro_sdk python3 setup.py build_ext --inplace
```
On the Mac conda environment:
```bash
cd /Users/chenyouyuan/cyy_ws/go1_pro_sdk/fast_lowcmd_cpp
PYTHONPATH=/Users/chenyouyuan/cyy_ws/go1_pro_sdk conda run -n free_dog_sdk python setup.py build_ext --inplace
```
## Test
```bash
PYTHONPATH=.:.. python3 -m pytest test_fast_lowcmd.py
```
## Benchmark
```bash
PYTHONPATH=.:.. python3 benchmark_fast_lowcmd.py
```
## API
```python
from fast_lowcmd import FastLowCmdBuilder
builder = FastLowCmdBuilder()
packet = builder.build_encrypted_servo12(q, kp=28.0, kd=0.7)
damping_packet = builder.build_encrypted_damping()
```
The generated bytes are expected to match the Python SDK exactly for the tested
packet forms.