Documentation Index
Fetch the complete documentation index at: https://motorbridge.seeedstudio.com/llms.txt
Use this file to discover all available pages before exploring further.
Source:
bindings/python/README.mdmotorbridge Python SDK
Channel Compatibility (PCAN + slcan + CAN-FD + Damiao Serial Bridge)
- Linux SocketCAN uses interface names directly:
can0,can1,slcan0. - For USB-serial CAN adapters, bring up
slcan0first:sudo slcand -o -c -s8 /dev/ttyUSB0 slcan0 && sudo ip link set slcan0 up. - CAN-FD transport is available both in CLI (
--transport socketcanfd) and Python SDK (Controller.from_socketcanfd(...)), and is required for Hexfellow. - Damiao-only serial bridge transport is also available in CLI (
--transport dm-serial --serial-port /dev/ttyACM0 --serial-baud 921600). - Full Damiao serial-bridge interface list and command patterns are documented in
motor_cli/README.md(section3.6inmotor_cli/README.zh-CN.md). - On Linux SocketCAN, do not append bitrate in
--channel(for examplecan0@1000000is invalid). - On Windows (PCAN backend),
can0/can1map toPCAN_USBBUS1/2; optional@bitratesuffix is supported.
motor_abi.
Chinese version: README.zh-CN.md
README Navigation (What Each One Is For)
If this is your first time in this folder, read in this order:- This file: README.md Purpose: Python binding overview (install, API scope, common commands).
- examples/README.md (English) / examples/READMEzh_cn.md (Chinese)
Purpose: practical demo index and run instructions (from simplest to advanced).
2.5.
../motorbridge-docsPurpose: canonical Mintlify documentation site (tutorial + API style docs). - get_started/README.md / get_started/README.zh-CN.md Purpose: pip-first onboarding path (install -> scan -> run).
- DAMIAO_PYTHON_REFERENCE.zh-CN.md Purpose: Damiao Python interface reference (parameter lookup style).
- DAMIAO_binding.md Purpose: Damiao binding implementation notes (design/internal behavior).
- README.zh-CN.md Purpose: Chinese overview for Chinese-speaking teammates.
- If your goal is “run something now”, start with
Start Here (Simplest 2 Examples)inexamples/README.md. - If your goal is CLI parameter lookup, see
../../motor_cli/README.md.
Scope
Packaging note:-
Current package target version:
0.2.9. -
Published wheel includes
motor_abishared library andws_gatewaybinary for that platform. -
After
pip install motorbridge, gateway binary path is typically:.../site-packages/motorbridge/bin/ws_gateway(orws_gateway.exeon Windows). -
Gateway launch command (added to PATH by pip):
motorbridge-gateway -- --bind 127.0.0.1:9002 ...
-
Security note:
- keep loopback bind (
127.0.0.1) for local usage. - if you bind to non-loopback addresses (
0.0.0.0or host IP), exportMOTORBRIDGE_WS_TOKENbefore launch. - clients must pass the token in
x-motorbridge-tokenorAuthorization: Bearer ....
- keep loopback bind (
-
macOS runtime note (only if you see dynamic library load errors):
- Resolve binary path generically:
GW="$(python3 -c "import motorbridge, pathlib; print(pathlib.Path(motorbridge.__file__).resolve().parent/'bin'/'ws_gateway')")" - Use package-local
libdirectory (no machine-specific absolute path):PKG_DIR="$(python3 -c "import motorbridge, pathlib; print(pathlib.Path(motorbridge.__file__).resolve().parent)")"DYLD_LIBRARY_PATH="$PKG_DIR/lib:${DYLD_LIBRARY_PATH:-}" "$GW" --bind 127.0.0.1:9002 --vendor damiao --channel can0 --model auto --motor-id 0x01 --feedback-id 0x11 --dt-ms 20
- Resolve binary path generically:
-
High-level API:
Controller,Motor,Mode -
CLI:
motorbridge-cli -
Controller constructors:
Controller(channel="can0")(SocketCAN/PCAN path)Controller.from_socketcanfd(channel="can0")(CAN-FD path, required by Hexfellow)Controller.from_dm_serial(serial_port="/dev/ttyACM0", baud=921600)(Damiao-only serial bridge)
-
Vendors:
- Damiao:
add_damiao_motor(...) - Hexfellow:
add_hexfellow_motor(...) - MyActuator:
add_myactuator_motor(...) - RobStride:
add_robstride_motor(...) - HighTorque:
add_hightorque_motor(...)
- Damiao:
-
Unified state-query pattern:
- Recommended flow:
request_feedback() -> poll_feedback_once() -> get_state(). - RobStride now supports this unified pattern via ABI-level compatibility (while
robstride_ping()is still available).
- Recommended flow:
Unified Mode Mapping Summary (Top-Level -> Vendor Native)
| Unified Mode | Damiao | RobStride | Hexfellow | MyActuator | HighTorque |
|---|---|---|---|---|---|
Mode.MIT | native MIT | native MIT | native MIT (mode 5) | unsupported | maps to native pos+vel+tqe |
Mode.POS_VEL | native POS_VEL | maps to native Position (run_mode=1 + limit_spd(0x7017) + loc_ref(0x7016)) | native POS_VEL (mode 1) | Position setpoint flow | maps to native pos+vel+tqe |
Mode.VEL | native VEL | native Velocity | unsupported | native velocity setpoint flow | native velocity command |
Mode.FORCE_POS | native FORCE_POS | unsupported | unsupported | unsupported | maps to native pos+vel+tqe |
- RobStride unified high-level control currently covers
MIT/POS_VEL/VEL. - Torque/current is parameter-level only for RobStride (
robstride_write_param_*), not a dedicated unified mode. - RobStride supports
rs-00throughrs-06; pass the real model toadd_robstride_motor(...)because parameter read/write uses the common section 4 runtime parameter table. - RobStride feedback/host default should use
0xFD; scan tries0xFD,0xFF,0xFE,0x00,0xAAby default. - RobStride
feedback_id/host_idis not the motordevice_id; scan hits report the motor ID asprobe/device_id.
Quick Start
CLI Examples
Damiao:rs-00 … rs-06) in Python CLI and SDK calls. The same control methods are available across the series, but manual parameter IDs and data types are selected from that model.
RobStride MIT and POS_VEL quick checks:
Experimental Windows Support (PCAN-USB)
Linux remains the primary target. Windows support is experimental and currently uses PEAK PCAN.- Install PEAK PCAN driver + PCAN-Basic runtime (
PCANBasic.dll). - Use
channelascan0@1000000(maps toPCAN_USBBUS1at 1Mbps).
Example Programs
- Damiao wrapper demo:
examples/python_wrapper_demo.py - Hexfellow CAN-FD demo:
examples/hexfellow_canfd_demo.py(MIT / POS_VEL only) - Damiao maintenance demo:
examples/damiao_maintenance_demo.py - Damiao register rw demo:
examples/damiao_register_rw_demo.py - Damiao dm-serial demo:
examples/damiao_dm_serial_demo.py - RobStride wrapper demo:
examples/robstride_wrapper_demo.py - Full Damiao mode demo:
examples/full_modes_demo.py - Damiao scan / tune / position helpers:
examples/scan_ids_demo.pyexamples/pid_register_tune_demo.pyexamples/pos_ctrl_demo.pyexamples/pos_repl_demo.py
Damiao Full-Coverage Status
Damiao usage in Python examples is now covered end-to-end:- control modes:
mit/pos-vel/vel/force-pos - transport paths: SocketCAN/PCAN constructor +
from_dm_serial(...) - maintenance ops:
clear_error,set_zero_position,set_can_timeout_ms,request_feedback- project guard for Damiao set-zero: call
disable()beforeset_zero_position() - no user-facing
msparameter for set-zero; core applies fixed20mssettle
- project guard for Damiao set-zero: call
- register APIs:
get/write f32,get/write u32,store_parameters
End-to-End Demo Commands
Notes
id-dumpis a Damiao workflow;id-setsupports Damiao and RobStride;scansupportsdamiao|hexfellow|myactuator|robstride|hightorque|all.- For RobStride
id-set,--new-motor-idchangesdevice_id;--feedback-idremains the host-side ID. - RobStride
motor_id/device_idis validated as1..255;feedback_id/host_idis validated as0..255to prevent silentctypestruncation. - RobStride scan probes each
--feedback-idshost_id exactly through host-id-specific ABI helpers; invalid host IDs are rejected instead of silently falling back. Mode.MITandsend_force_posare not available for MyActuator in ABI wrapper.- Hexfellow supports
MITandPOS_VELthrough ABI wrapper;VELandFORCE_POSreturn unsupported. - Full Damiao tuning reference stays in:
PyPI Auto Publish (GitHub Actions)
This repository includes.github/workflows/pypi-publish.yml.
- Tag publish policy:
- push
vX.Y.Z-> publish the same artifacts to both TestPyPI and PyPI
- push
- Manual publish is still available via workflow
Python Publish:testpypi(only TestPyPI)pypi(only PyPI)
One-time setup (token mode)
- Create API token on PyPI and add repository secret
PYPI_API_TOKEN. - Create API token on TestPyPI and add repository secret
TEST_PYPI_API_TOKEN. - Keep package version unique for every upload (for example
0.1.6,0.1.7).