Skip to main content

API: motorbridge-cli

Installation

The CLI is installed automatically with the Python package:
pip install motorbridge
motorbridge-cli --help

Global Options

motorbridge-cli [OPTIONS] COMMAND [ARGS]
OptionDescription
--helpShow help message and exit
--versionShow version and exit

Commands Overview

CommandDescription
runSend control commands to a motor
scanScan CAN bus for active motors
id-dumpRead Damiao ID/mode registers
id-setWrite Damiao ID registers
robstride-read-paramRead RobStride parameter
robstride-write-paramWrite RobStride parameter

run

Run motor control commands in a loop.

Usage

motorbridge-cli run [OPTIONS]

Options

OptionDefaultDescription
--vendordamiaoMotor vendor: damiao, myactuator, robstride, hightorque, hexfellow
--channelcan0CAN interface name
--transportautoTransport: auto, socketcan, socketcanfd, dm-serial
--serial-port/dev/ttyACM0Serial port (for dm-serial transport)
--serial-baud921600Serial baud rate
--model4340Motor model string
--motor-id0x01Motor CAN ID (hex supported)
--feedback-id0x11Feedback CAN ID (hex supported)
--modemitControl mode: enable, disable, mit, pos-vel, vel, force-pos, ping
--loop100Number of control iterations
--dt-ms20Control period in milliseconds
--ensure-mode1Whether to ensure mode before control
--ensure-strict0Fail if mode switch fails
--ensure-timeout-ms1000Mode switch timeout
--print-state1Print state each iteration
--pos0.0Target position (rad)
--vel0.0Target velocity (rad/s)
--kp30.0Position stiffness (MIT mode)
--kd1.0Velocity damping (MIT mode)
--tau0.0Feedforward torque (Nm)
--vlim1.0Velocity limit (rad/s)
--ratio0.3Force ratio (force-pos mode)

Examples

Enable Motor Only

motorbridge-cli run --vendor damiao --channel can0 --motor-id 0x01 --mode enable --loop 1

Disable Motor

motorbridge-cli run --vendor damiao --channel can0 --motor-id 0x01 --mode disable --loop 1

MIT Mode Control

motorbridge-cli run \
    --vendor damiao \
    --channel can0 \
    --model 4340P \
    --motor-id 0x01 \
    --feedback-id 0x11 \
    --mode mit \
    --loop 100 \
    --dt-ms 20 \
    --pos 1.0 \
    --kp 30.0 \
    --kd 1.0

Position-Velocity Mode

motorbridge-cli run \
    --vendor damiao \
    --channel can0 \
    --model 4340P \
    --motor-id 0x01 \
    --feedback-id 0x11 \
    --mode pos-vel \
    --loop 200 \
    --pos 2.0 \
    --vlim 1.5

RobStride Motor

motorbridge-cli run \
    --vendor robstride \
    --channel can0 \
    --model rs-00 \
    --motor-id 127 \
    --feedback-id 0xFE \
    --mode mit \
    --loop 100 \
    --pos 0.5 \
    --kp 2.0 \
    --kd 0.1

Using Serial Transport

motorbridge-cli run \
    --vendor damiao \
    --transport dm-serial \
    --serial-port /dev/ttyACM0 \
    --serial-baud 921600 \
    --model 4340P \
    --motor-id 0x01 \
    --feedback-id 0x11 \
    --mode mit \
    --loop 50

scan

Scan CAN bus for active motors.

Usage

motorbridge-cli scan [OPTIONS]

Options

OptionDefaultDescription
--vendordamiaoVendor to scan: damiao, myactuator, robstride, hightorque, hexfellow, all
--channelcan0CAN interface
--transportautoTransport type
--serial-port/dev/ttyACM0Serial port
--serial-baud921600Serial baud rate
--model4340Motor model
--start-id0x01Start ID for scan
--end-id0x10End ID for scan
--feedback-ids0xFF,0xFE,0x00,0xAARobStride feedback IDs to try
--feedback-base0x10Damiao feedback ID base
--timeout-ms80Per-ID timeout
--param-id0x7019RobStride parameter ID for probe
--param-timeout-ms120RobStride parameter timeout

Examples

Scan All Vendors

motorbridge-cli scan --vendor all --channel can0 --start-id 1 --end-id 255

Scan Damiao Only

motorbridge-cli scan --vendor damiao --channel can0 --start-id 0x01 --end-id 0x20

Scan RobStride

motorbridge-cli scan --vendor robstride --channel can0 --start-id 1 --end-id 127

Scan MyActuator

motorbridge-cli scan --vendor myactuator --channel can0 --start-id 1 --end-id 32

Scan via Serial

motorbridge-cli scan \
    --vendor damiao \
    --transport dm-serial \
    --serial-port /dev/ttyACM0 \
    --start-id 1 \
    --end-id 32

Output Format

command=scan vendor=damiao transport=auto channel=can0 model=4340 id_range=[0x1,0x20] timeout_ms=80
[scan:damiao] channel=can0 model=4340 id_range=[0x1,0x20] timeout_ms=80
[hit] vendor=damiao probe=0x01 esc_id=0x1 mst_id=0x11
[hit] vendor=damiao probe=0x02 esc_id=0x2 mst_id=0x12
[.. ] vendor=damiao probe=0x03 no reply
scan done: 2 motor(s) found
  probe=0x01 vendor=damiao esc_id=0x1 mst_id=0x11
  probe=0x02 vendor=damiao esc_id=0x2 mst_id=0x12

id-dump

Read key ID and configuration registers from Damiao motors.

Usage

motorbridge-cli id-dump [OPTIONS]

Options

OptionDefaultDescription
--vendordamiaoMust be damiao
--channelcan0CAN interface
--transportautoTransport type
--model4340Motor model
--motor-id0x01Motor ID
--feedback-id0x11Feedback ID
--timeout-ms500Register read timeout
--rids7,8,9,10,21,22,23Register IDs to read

Register IDs

RIDNameDescription
7MST_IDFeedback ID
8ESC_IDMotor ID
9TIMEOUTCommunication timeout
10CTRL_MODEControl mode
21PMAXPosition mapping range
22VMAXVelocity mapping range
23TMAXTorque mapping range

Example

motorbridge-cli id-dump \
    --vendor damiao \
    --channel can0 \
    --motor-id 0x01 \
    --feedback-id 0x11 \
    --rids 7,8,9,10,21,22,23

Output

command=id-dump transport=auto channel=can0 model=4340 motor_id=0x1 feedback_id=0x11
rid=  7 (u32) = 17 (0x11)
rid=  8 (u32) = 1 (0x1)
rid=  9 (u32) = 5000 (0x1388)
rid= 10 (u32) = 1 (0x1)
rid= 21 (f32) = 12.566371
rid= 22 (f32) = 30.000000
rid= 23 (f32) = 10.000000

id-set

Write ID registers to Damiao motors and optionally store to flash.

Usage

motorbridge-cli id-set [OPTIONS]

Options

OptionDefaultDescription
--vendordamiaoMust be damiao
--channelcan0CAN interface
--transportautoTransport type
--model4340Motor model
--motor-id0x01Current motor ID
--feedback-id0x11Current feedback ID
--new-motor-id(same)New motor ID to set
--new-feedback-id(same)New feedback ID to set
--store1Store to flash after write
--verify1Verify after write
--timeout-ms800Verify timeout

Example

# Change motor ID from 0x01 to 0x05
motorbridge-cli id-set \
    --vendor damiao \
    --channel can0 \
    --motor-id 0x01 \
    --feedback-id 0x11 \
    --new-motor-id 0x05 \
    --new-feedback-id 0x15 \
    --store 1 \
    --verify 1

Output

command=id-set transport=auto channel=can0 model=4340 old_motor_id=0x1 old_feedback_id=0x11 new_motor_id=0x5 new_feedback_id=0x15
write rid=7 (MST_ID) <= 0x15
write rid=8 (ESC_ID) <= 0x5
store_parameters sent
verify rid=8 (ESC_ID): 0x5
verify rid=7 (MST_ID): 0x15
verify ok

robstride-read-param

Read a parameter from RobStride motor.

Usage

motorbridge-cli robstride-read-param [OPTIONS]

Options

OptionDefaultDescription
--channelcan0CAN interface
--modelrs-00Motor model
--motor-id127Motor ID
--param-id(required)Parameter ID to read
--type(required)Data type: i8, u8, u16, u32, f32
--timeout-ms500Read timeout

Example

motorbridge-cli robstride-read-param \
    --channel can0 \
    --motor-id 127 \
    --param-id 0x7019 \
    --type f32

Output

command=robstride-read-param channel=can0 model=rs-00 motor_id=0x7F param_id=0x7019 type=f32 value=1.5

robstride-write-param

Write a parameter to RobStride motor.

Usage

motorbridge-cli robstride-write-param [OPTIONS]

Options

OptionDefaultDescription
--channelcan0CAN interface
--modelrs-00Motor model
--motor-id127Motor ID
--param-id(required)Parameter ID to write
--type(required)Data type: i8, u8, u16, u32, f32
--value(required)Value to write
--verify1Read back and verify
--timeout-ms500Verify timeout

Example

motorbridge-cli robstride-write-param \
    --channel can0 \
    --motor-id 127 \
    --param-id 0x7019 \
    --type f32 \
    --value 2.0 \
    --verify 1

Output

command=robstride-write-param channel=can0 model=rs-00 motor_id=0x7F param_id=0x7019 type=f32 value=2.0 verify=2.0

Common Workflows

Initial Setup

# 1. Scan for motors
motorbridge-cli scan --vendor all --channel can0 --start-id 1 --end-id 255

# 2. Read motor configuration
motorbridge-cli id-dump --vendor damiao --motor-id 0x01 --feedback-id 0x11

# 3. Test motor control
motorbridge-cli run --vendor damiao --motor-id 0x01 --mode enable --loop 1
motorbridge-cli run --vendor damiao --motor-id 0x01 --mode mit --loop 50 --pos 0.5

Changing Motor ID

# 1. Verify current ID works
motorbridge-cli id-dump --motor-id 0x01 --feedback-id 0x11

# 2. Set new ID
motorbridge-cli id-set \
    --motor-id 0x01 \
    --feedback-id 0x11 \
    --new-motor-id 0x05 \
    --new-feedback-id 0x15 \
    --store 1 \
    --verify 1

# 3. Verify with new ID
motorbridge-cli id-dump --motor-id 0x05 --feedback-id 0x15

RobStride Parameter Tuning

# Read current parameter
motorbridge-cli robstride-read-param --motor-id 127 --param-id 0x7019 --type f32

# Write new value
motorbridge-cli robstride-write-param --motor-id 127 --param-id 0x7019 --type f32 --value 2.5

# Verify
motorbridge-cli robstride-read-param --motor-id 127 --param-id 0x7019 --type f32

Exit Codes

CodeMeaning
0Success
1General error
2Invalid arguments

See Also