Skip to main content

Channel Compatibility (PCAN + slcan + Damiao Serial Bridge)

  • Linux SocketCAN uses interface names directly: can0, can1, slcan0.
  • For USB-serial CAN adapters, bring up slcan0 first: sudo slcand -o -c -s8 /dev/ttyUSB0 slcan0 && sudo ip link set slcan0 up.
  • 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 (section 3.6 in motor_cli/README.zh-CN.md).
  • On Linux SocketCAN, do not append bitrate in --channel (for example can0@1000000 is invalid).
  • On Windows (PCAN backend), can0/can1 map to PCAN_USBBUS1/2; optional @bitrate suffix is supported.
High-performance Rust WebSocket gateway (V1: JSON over WS).

Status

Core WS API is implemented. The bundled web HMI (tools/ws_test_client.html) is still under active development.

Transport

  • Protocol: WebSocket
  • V1 payload: JSON text frames
  • Periodic state push on each --dt-ms tick

Unified Mode Mapping (Draft)

Goal: application layer uses one unified operation set first; vendor-specific ops remain available but are not recommended as default.

Unified Control Modes (app-facing, fixed baseline)

If a vendor does not support one of these four baseline modes, gateway returns unsupported.

Vendor Mapping Table (unified mode -> vendor-native)

Unified Core Ops Support Matrix

Parameter Notes by Mode

  • mit: same unified fields, but vendor scaling differs internally (gateway adapter handles conversion). HighTorque detail: kp/kd are currently ignored by protocol path.
  • pos_vel: only valid where vendor has equivalent mode.
  • vel: sign/scale conversion is vendor-specific internally.
  • force_pos: Damiao native; HighTorque maps to pos+vel+tqe; others unsupported.

WS capabilities Response (Draft)

Recommended: client calls {"op":"capabilities"} on connect and adapts UI/flows by returned support matrix.

Example response

Multi-Joint State & Auth Notes

  • damiao_state_many: refresh every discovered Damiao joint in one logical request over dm-serial. State snapshots include motor_id, feedback_id, and model, so browser HMIs can merge whole-arm telemetry by joint instead of treating all feedback as the active target. State reads request fresh feedback with a bounded timeout before returning.
  • Token auth: browser clients may send MOTORBRIDGE_WS_TOKEN in the WebSocket URL query as ?motorbridge_ws_token=... (header-based auth and non-loopback token requirements are unchanged).
  • Single-motor command scoping: one-motor operations no longer fan out across multiple discovered motors; they are scoped to the explicit requested target.
  • RobStride scans: probe each requested host/feedback ID exactly and sequentially (Windows PCAN-safe). Already-discovered IDs are skipped in later passes.
  • param_stream enabled=false: disabling the stream no longer opens or reopens hardware sessions.

Build

Run

Security note:
  • 127.0.0.1:9002 is the default and recommended bind for local use.
  • If you bind to non-loopback addresses (for example 0.0.0.0:9002), you must set MOTORBRIDGE_WS_TOKEN.
  • WebSocket clients must provide this token via header x-motorbridge-token: <token> or Authorization: Bearer <token>.

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 can0@1000000 as the channel value on Windows:
Quick Windows motor validation commands:

Inbound command examples

Outbound frames

Success response:
Error response:
State stream frame:

Notes

  • --vendor damiao|robstride|hexfellow|myactuator|hightorque controls default target vendor.
  • set_target can switch vendor/transport/channel/serial/model/id on the fly per session.
  • continuous=true keeps sending that control command every tick.
  • stop clears continuous control.
  • set_id is vendor-aware:
    • Damiao: write MST_ID first, then ESC_ID.
    • RobStride: device ID update via SET_DEVICE_ID.
  • Damiao-only ops: write/get_register_* and dm-serial transport.
  • RobStride-only ops: robstride_ping, robstride_read_param, robstride_write_param.
  • MyActuator-native ops: current, pos, version, mode-query.
  • HighTorque-native op: read.
  • V2 plan can switch to binary frames while preserving operation semantics.

Simple HMI (for quick testing)

  • File: integrations/ws_gateway/tools/ws_test_client.html
  • Dedicated 4-motor sync example: examples/web/ws_quad_sync_hmi.html
  • Open directly in browser (double-click or xdg-open), then connect to ws://127.0.0.1:9002.
  • Current status: in development (UI/flow may change quickly).
  • For stable validation, prefer sending JSON commands directly (wscat/websocat/custom client).
  • Built-in dynamic device workflow:
    • scan Damiao and RobStride in one page
    • scan hits are shown in a device table (vendor + motor_id + feedback_id + model)
    • pick any scanned motor as current target and run enable/disable/vel/mit
    • checkbox batch ops: batch enable/stop/disable and batch MIT sync-to-position
  • For the 4-motor same-angle slider workflow, start a local static server:
    • python3 -m http.server 18080
    • open http://127.0.0.1:18080/examples/web/ws_quad_sync_hmi.html