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