A motor control library developed based on the High Torque Motor SDK protocol table, supporting implementations in Python, C++, Rust, and Arduino.
๐ Languages: English | ไธญๆ | Espaรฑol
๐ Official SDK: https://github.com/HighTorque-Robotics/livelybot_hardware_sdk
# Install CAN tools sudo apt-get install can-utils # Configure CAN interface sudo ip link set can0 type can bitrate 1000000 sudo ip link set up can0cd python pip install -r requirements.txt # Scan motors python3 can_motor_scanner.py --channel can0 # Velocity control python3 velocity_acceleration_control.py --motor_id 1 --mode interactive # Angle control python3 angle_stream_control.py --motor_id 1 --mode interactivecd cpp make # Scan motors ./can_motor_scanner 1 5 # Velocity control ./velocity_acceleration_control 1 # Angle control ./angle_stream_control 1 interactivecd rust cargo build --release # Scan motors ./target/release/can_motor_scanner --start-id 1 --end-id 5 # Velocity control ./target/release/velocity_acceleration_control --motor-id 1 # Angle control ./target/release/angle_stream_control --motor-id 1 interactiveCUS_02/ โโโ python/ # Python implementation โ โโโ can_motor_scanner.py # Motor scanning tool โ โโโ velocity_acceleration_control.py # Velocity + Acceleration control โ โโโ angle_stream_control.py # Angle stream control โ โโโ requirements.txt # Python dependencies โโโ cpp/ # C++ implementation โ โโโ can_motor_scanner.cpp # Motor scanning tool โ โโโ velocity_acceleration_control.cpp # Velocity + Acceleration control โ โโโ angle_stream_control.cpp # Angle stream control โ โโโ Makefile # Build system โ โโโ README.md # C++ documentation โโโ rust/ # Rust implementation โ โโโ src/ โ โ โโโ lib.rs โ โ โโโ bin/ โ โ โโโ can_motor_scanner.rs โ โ โโโ velocity_acceleration_control.rs โ โ โโโ angle_stream_control.rs โ โโโ Cargo.toml โ โโโ Makefile โ โโโ README.md โ โโโ target/release/ # Compiled executables โโโ arduino/ # Arduino implementation โ โโโ libraries/ โโโ scripts/ # Build and configuration scripts - โ CAN bus motor scanning
- โ Intelligent emergency stop velocity control
- โ 0x90 stream command angle control
- โ MIT style impedance control
- โ Sine wave/step/ramp testing
- โ High-performance real-time control (200Hz control loop)
- โ Native SocketCAN interface
- โ Multi-threaded control architecture
- โ Intelligent emergency stop with maximum deceleration
- โ MIT-style impedance control (0x90 stream commands)
- โ Interactive and automated control modes
- โ Sine wave, step, and multi-position testing
- โ Memory safety guarantee (zero-cost abstractions)
- โ Type-safe protocol handling
- โ High-performance async control architecture
- โ Cross-platform support (Linux native CAN)
- โ Ownership and thread safety
- โ Compile-time optimizations
- โณ ESP32/Arduino support
- โณ Low power operation
- โณ Real-time feedback
Based on High Torque Motor SDK protocol table:
| Motor Model | Torque | Max Speed | Reduction | Protocol Support |
|---|---|---|---|---|
| 5046_20 | 17 Nm | 50 rad/s | 20:1 | โ |
| 4538_19 | 17 Nm | 44 rad/s | 19:1 | โ |
| 5047_36 | 60 Nm | 50 rad/s | 36:1 | โ |
| 5047_09 | 17 Nm | 33 rad/s | 9:1 | โ |
- Master: Direct control via CAN interface
- Motor: Support for multi-motor stream control
- Baud Rate: 1Mbps (standard)
- Frame Format: Extended frame (29-bit ID)
# CAN ID: 0x8000 | motor_id # Data: [0x11, 0x00, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50]# CAN ID: 0x00AD # Data: [PosL, PosH, VelL, VelH, AccL, AccH, 0x50, 0x50]# CAN ID: 0x0090 # Data: [PosL, PosH, VelL, VelH, TqeL, TqeH, 0x50, 0x50]from python.can_motor_scanner import LivelyMotorScanner scanner = LivelyMotorScanner('can0') if scanner.connect(): motors = scanner.scan_range(1, 14) print(f"Found motors: {motors}")from python.velocity_acceleration_control import MotorVelAccController controller = MotorVelAccController('can0', motor_id=1) controller.enable_sequence() controller.start_control() controller.set_velocity(5.0) # 5 rad/sfrom python.angle_stream_control import MotorAngleStreamController controller = MotorAngleStreamController('can0', motor_id=1) controller.connect() controller.enable_motor() controller.set_angle(90.0) # 90 degrees- Torque Limiting: Configurable maximum output torque
- Position Limiting: Software position limits
- Intelligent Emergency Stop: Automatic maximum deceleration at zero speed
- Communication Monitoring: Real-time CAN communication status
- Exception Handling: Comprehensive error handling and recovery
| Language | Control Frequency | Latency | Memory Usage | Status | Target Platform |
|---|---|---|---|---|---|
| Python | 100 Hz | 5ms | 50MB | โ Complete | Linux Development |
| C++ | 200 Hz | 1ms | 10MB | โ Complete | Linux Production |
| Rust | 150 Hz | 2ms | 8MB | โ Complete | Linux Production |
| Arduino | 50-200Hz | 2-20ms | 10-50KB | โณ TODO | ESP32/MCU |
# Check interface status ip link show can0 # Reconfigure interface sudo ip link set can0 down sudo ip link set can0 up type can bitrate 1000000 restart-ms 100# Add user to dialout group sudo usermod -a -G dialout $USER # Or run with sudo sudo python3 can_motor_scanner.py- Confirm 120ฮฉ terminal resistor
- Check CAN-H and CAN-L wiring
- Verify motor power supply is normal
- Confirm baud rate settings match
- ๐ High Torque Motor SDK Protocol Table - Complete protocol specification
- ๐ Official SDK - Official SDK repository
- ๐ Python Documentation - Python implementation details
- โ C++ Documentation - C++ implementation details (Complete)
- โ Rust Documentation - Rust implementation details (Complete)
- โณ Arduino Documentation - Arduino implementation details (To be implemented)
- Python CAN protocol implementation
- C++ high-performance implementation (200Hz control loop)
- Rust memory-safe implementation (150Hz control loop)
- Motor scanning tool (Python & C++ & Rust)
- Velocity + acceleration control with intelligent emergency stop (Python & C++ & Rust)
- Angle stream control (0x90 command) (Python & C++ & Rust)
- MIT style impedance control (Python & C++ & Rust)
- Multiple testing modes (interactive, sine wave, step, multi-position)
- SocketCAN native interface support
- Multi-threaded control architecture (C++ & async Rust)
- Type-safe protocol handling (Rust)
- Zero-cost abstractions (Rust)
- Arduino/ESP32 implementation
- GUI control interface
- Simulation test platform
- Automatic calibration tools
- Automatic motor parameter identification
- Batch motor management
- Real-time data visualization
- Remote control interface
- Fault diagnosis tools
Issues and Pull Requests are welcome!
- Fork this repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add some AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
MIT License - See LICENSE file for details
- High Torque Robotics Official SDK - Protocol reference
- RobStride Control - Related project: RobStride & XIAOMI motor control
Developed based on High Torque Motor SDK protocol table, providing high-performance solutions for robot control