Skip to main content

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: examples/cpp/README.zh-CN.md

C++ ABI 示例

通道兼容说明(PCAN + slcan + Damiao 串口桥)

  • Linux SocketCAN 直接使用网卡名:can0can1slcan0
  • 串口类 USB-CAN 需先创建并拉起 slcan0sudo slcand -o -c -s8 /dev/ttyUSB0 slcan0 && sudo ip link set slcan0 up
  • 仅 Damiao 可选串口桥链路:--transport dm-serial --serial-port /dev/ttyACM0 --serial-baud 921600
  • Damiao 串口桥完整接口与命令模板见 motor_cli/README.zh-CN.md3.6 节(英文见 motor_cli/README.md)。
  • Linux SocketCAN 下 --channel 不要带 @bitrate(例如 can0@1000000 无效)。
  • Windows(PCAN 后端)中,can0/can1 映射 PCAN_USBBUS1/2,可选 @bitrate 后缀。
这里是基于 motor_abi.h 的 C++ 直接示例。
English version: README.md

文件

  • cpp_abi_demo.cpp: 同时支持 Damiao 和 RobStride 的统一 ABI 示例

构建

cargo build -p motor_abi --release
g++ -std=c++17 examples/cpp/cpp_abi_demo.cpp -I motor_abi/include -L target/release -lmotor_abi -o cpp_abi_demo
LD_LIBRARY_PATH=target/release ./cpp_abi_demo --help

示例

Damiao MIT:
LD_LIBRARY_PATH=target/release ./cpp_abi_demo \
  --vendor damiao --channel can0 --model 4340P --motor-id 0x01 --feedback-id 0x11 \
  --mode mit --pos 0 --vel 0 --kp 20 --kd 1 --tau 0 --loop 50 --dt-ms 20
RobStride ping:
LD_LIBRARY_PATH=target/release ./cpp_abi_demo \
  --vendor robstride --channel can0 --model rs-06 --motor-id 127 --mode ping
RobStride 读参数:
LD_LIBRARY_PATH=target/release ./cpp_abi_demo \
  --vendor robstride --channel can0 --model rs-06 --motor-id 127 \
  --mode read-param --param-id 0x7019 --param-type f32
示例中的 rs-06 只是演示型号。真实交互前请替换成实际 RS00-RS06 型号,因为 RobStride 参数 ID 和类型来自第 4 章通用运行表。