Skip to main content

MotorBridge Python SDK

v0.1.7 Python 3.10+ A unified, high-performance motor control library for Python. Control brushless motors from multiple vendors with a single, consistent API.

Why MotorBridge?

Quick Example

from motorbridge import Controller, Mode

# Open CAN interface
with Controller("can0") as ctrl:
    # Add a Damiao motor
    motor = ctrl.add_damiao_motor(0x01, 0x11, "4340P")
    
    # Enable and configure
    ctrl.enable_all()
    motor.ensure_mode(Mode.MIT, 1000)
    
    # Send control command
    motor.send_mit(pos=0.5, vel=0.0, kp=30.0, kd=1.0, tau=0.0)
    
    # Read state
    state = motor.get_state()
    if state:
        print(f"Position: {state.pos:.3f} rad")

Supported Vendors

VendorModelsMITPOS_VELVELFORCE_POS
Damiao4310, 4340P, 6001
RobStriders-00
MyActuatorX8
HighTorqueHT
Hexfellow*
Hexfellow motors require CAN-FD transport. Use Controller.from_socketcanfd("can0").

Architecture

┌─────────────────────────────────────────────────────────┐
│                     Controller                          │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐    │
│  │   Motor 1   │  │   Motor 2   │  │   Motor N   │    │
│  │  (Damiao)   │  │ (RobStride) │  │(MyActuator) │    │
│  └─────────────┘  └─────────────┘  └─────────────┘    │
│                        │                               │
│              ┌─────────┴─────────┐                    │
│              │    Transport      │                    │
│              │  (CAN/Serial/FD)  │                    │
│              └───────────────────┘                    │
└─────────────────────────────────────────────────────────┘

Core Concepts

ComponentDescription
ControllerManages transport layer and multiple motor handles
MotorPer-device handle for sending commands and reading state
ModeControl mode enum (MIT, POS_VEL, VEL, FORCE_POS)
MotorStateImmutable dataclass containing motor feedback

Documentation Sections

Step-by-step guides for common tasks:

Installation

1

Install Package

pip install motorbridge
2

Configure CAN Interface

sudo ip link set can0 type can bitrate 1000000
sudo ip link set can0 up
3

Run Your First Program

from motorbridge import Controller

with Controller("can0") as ctrl:
    motor = ctrl.add_damiao_motor(0x01, 0x11, "4340P")
    ctrl.enable_all()
    print("Motor ready!")

Getting Help

  • 📖 Read the Tutorials for step-by-step guides
  • 🔍 Check Troubleshooting for common issues
  • 💻 Use motorbridge-cli --help for CLI reference

License

MIT License - see the project repository for details.