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/examples/README.mdPython Practical Demos
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. - Hexfellow examples require CAN-FD path (
Controller.from_socketcanfd(...)/ CLI--transport socketcanfd). - 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.
Chinese version (examples): READMEzh_cn.md Chinese version (Python binding overview): ../README.zh-CN.md
Start Here (Simplest 2 Examples)
If you installed from pip and want a cleaner onboarding path, start with:../get_started/README.md(English)../get_started/README.zh-CN.md(Chinese)
simple_01_motor_control.py: single-motor minimal template (default Damiao, other vendors as commented snippets).simple_02_quad_motor_control.py: minimal 4-motor multi-vendor swing demo (2 Damiao + 1 MyActuator + 1 RobStride).
- Run
simple_01_motor_control.pyto verify your CAN channel and one motor first. - Then run
simple_02_quad_motor_control.pyto verify multi-controller / multi-vendor behavior.
Parameter Cheat Sheet (for the two simplest scripts)
simple_01_motor_control.py
--channel: CAN interface name, e.g.can0,can1,slcan0.--loop: number of control iterations.--dt-ms: control period (ms). Start with20; if bus is busy, use30/50.--pos: target position (radians).--vlim: speed limit for POS_VEL.
simple_02_quad_motor_control.py
--channel: CAN interface name.--loop: total loop count.--dt-ms: control period (ms), same tuning rule as above.--pos: swing amplitude (radians), used as+pos/-pos.--swing-loop: switch sign every N loops.--rs-dir-sign:-1means RobStride direction opposite to others;+1means same.--dm-vlim: Damiao speed limit in POS_VEL.--my-vlim: MyActuator speed limit in POS_VEL.--rs-kp/--rs-kd: RobStride MIT gains.
What to Read Next (recommended order)
- ../README.zh-CN.md or ../README.md Start here for Python binding installation and base API concepts.
- /zh/source/rust-cli/overview or /source/rust-cli/overview Use this for vendor scan commands and ID confirmation.
- /zh/source/examples/overview or /source/examples/overview Broader demo index (web/WS/other integration examples).
WS Demo Quick Guide (quad_vendor_binding_ws_demo.py)
This demo is a Python WS bridge for 4 motors (dm1, dm2, my, rs) with a matching web UI.
Backend start:
http://127.0.0.1:8080/quad_vendor_binding_ws_demo.html- WS URL:
ws://127.0.0.1:9010
Key Points Beginners Must Know
- One
Controllerinstance cannot mix vendors; use separate controllers for mixed-vendor control. os error 105usually means send rate is too high or another process is also writing to CAN.- Streaming control needs periodic sends; single-shot command is often not enough for stable holding.
- Confirm motor IDs/feedback IDs with scan before running these demos.
Files
simple_01_motor_control.py: simplest single-motor template (default Damiao; includes commented vendor switch snippets)simple_02_quad_motor_control.py: simplest 4-motor multi-vendor demo with fixed-rate loop and swing targetpython_wrapper_demo.py: minimal Damiao MIT loopdamiao_maintenance_demo.py: Damiao maintenance flow (clear_error/set_zero_position/set_can_timeout_ms/request_feedback)damiao_register_rw_demo.py: Damiao register read/write (f32+u32+ optionalstore_parameters)damiao_dm_serial_demo.py: Damiao serial-bridge transport demo (Controller.from_dm_serial)dm_serial_01_calibration_demo.py: SOP-01 dm-serial maintenance/calibration flowdm_serial_02_control_modes_demo.py: SOP-02 dm-serial normal control loop (4 modes, no calibration/config writes)dm_serial_03_status_demo.py: SOP-03 dm-serial status-only monitordm_serial_04_enable_setzero_no_delay_demo.py: SOP-04 dm-serial stress repro (set_zerothen immediate control)dm_serial_05_setzero_timing_ab_test.py: SOP-05 dm-serial set-zero settle-time A/B testdm_serial_06_recover_no_reboot_demo.py: SOP-06 dm-serial software recovery (no host reboot)dm_serial_07_enable_setzero_enable_rotate_demo.py: SOP-07 dm-serial robust sequence (disable -> set_zero -> enable -> control)dm_serial_08_negative_enable_setzero_guard_demo.py: SOP-08 dm-serial negative test (enablestateset_zeroshould be rejected by core guard)dm_serial_leader_monitor_demo.py: Damiao dm-serial leader monitor (enable-all + selected-ID full state stream)robstride_wrapper_demo.py: RobStride ping / read-param / mit / vel demoquad_vendor_pos_binding_demo.py: 4-motor sync position demo via Python binding (no ws_gateway)quad_vendor_binding_ws_demo.py: Python binding WS bridge backend (for web UI control)quad_vendor_binding_ws_demo.html: simple web UI forquad_vendor_binding_ws_demo.pyhexfellow_canfd_demo.py: Hexfellow CAN-FD demo (mit/pos-velonly)full_modes_demo.py: Damiao full-mode demopid_register_tune_demo.py: Damiao register tuningscan_ids_demo.py: Damiao fast scan (legacy helper)pos_ctrl_demo.py: Damiao one-shot target positionmulti_motor_ctrl_demo.py: Damiao multi-motor control with-id/-posone-to-one mappingmit_pos_switch_demo.py: two-phase mode switch demo (MIT then POS_VEL) for multi-motor targetspos_repl_demo.py: Damiao interactive position console
Quick Run
Damiao:enable then set_zero, expect guard reject):
dm-serial Timing Notes (Set-Zero Sequence)
- Observed issue: running
set_zero_position()and immediately callingensure_mode(...)can triggerregister 10 not receivedtimeouts. - Root cause pattern: this is typically a dm-serial timing window (bridge latency + motor internal state switch), not a normal control-mode logic bug.
- Core guard rule:
set_zero_position()is accepted only afterdisable(). - Core settle rule: after
set_zero_position(), a fixed20 mssettle is applied in core (not exposed as Python argument). - Recommended sequence for robust control:
disable(ordisable_all)set_zero_positionenable(orenable_all)ensure_mode- run control loop
- If the timeout state is triggered, try software recovery first (
disable -> clear_error -> enable -> retry) before rebooting host/device.
pos-vel (example: motor 4 and 7, positions mapped by order):
4 and 7, target -3):
Damiao Coverage Note
Damiao examples now cover the full high-level SDK usage surface:- Control modes:
mit/pos-vel/vel/force-pos - Transport paths:
Controller(channel)+Controller.from_dm_serial(...) - Maintenance ops:
clear_error,set_zero_position,set_can_timeout_ms,request_feedback - Register APIs:
get/write f32,get/write u32,store_parameters - Scan helper and tuning workflows
Scope Notes
- Recent multi-motor demo updates are mainly in
examples/*and WS bridge scripts. motor_corebehavior was not changed in this batch; WS-related tuning is done inintegrations/ws_gateway.