Skip to content

Seeed-Projects/HighTorque_Control

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

LivelyBot High Torque Motor Control Library

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

๐Ÿš€ Quick Start

Environment Setup

# 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 can0

Python Implementation

cd 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 interactive

C++ Implementation โœ…

cd cpp make # Scan motors ./can_motor_scanner 1 5 # Velocity control ./velocity_acceleration_control 1 # Angle control ./angle_stream_control 1 interactive

Rust Implementation โœ…

cd 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 interactive

๐Ÿ“ Project Structure

CUS_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 

๐Ÿ”ง Features

Python Implementation (100Hz, 5ms latency) โœ…

  • โœ… CAN bus motor scanning
  • โœ… Intelligent emergency stop velocity control
  • โœ… 0x90 stream command angle control
  • โœ… MIT style impedance control
  • โœ… Sine wave/step/ramp testing

C++ Implementation (200Hz, 1ms latency) โœ…

  • โœ… 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

Rust Implementation (150Hz, 2ms latency) โœ…

  • โœ… 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

Arduino Implementation (50-200Hz, 2-20ms latency) โณ TODO

  • โณ ESP32/Arduino support
  • โณ Low power operation
  • โณ Real-time feedback

๐Ÿ“Š Supported Motors

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 โœ…

๐Ÿ”Œ CAN Protocol

Communication Architecture

  • Master: Direct control via CAN interface
  • Motor: Support for multi-motor stream control
  • Baud Rate: 1Mbps (standard)
  • Frame Format: Extended frame (29-bit ID)

Key Protocols

1. Motor Scanning (Ping)

# CAN ID: 0x8000 | motor_id # Data: [0x11, 0x00, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50]

2. Velocity + Acceleration Control (0xAD)

# CAN ID: 0x00AD # Data: [PosL, PosH, VelL, VelH, AccL, AccH, 0x50, 0x50]

3. Angle Stream Control (0x90)

# CAN ID: 0x0090 # Data: [PosL, PosH, VelL, VelH, TqeL, TqeH, 0x50, 0x50]

๐ŸŽฏ Usage Examples

Python Motor Scanning

from python.can_motor_scanner import LivelyMotorScanner scanner = LivelyMotorScanner('can0') if scanner.connect(): motors = scanner.scan_range(1, 14) print(f"Found motors: {motors}")

Python Velocity Control

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/s

Python Angle Control

from python.angle_stream_control import MotorAngleStreamController controller = MotorAngleStreamController('can0', motor_id=1) controller.connect() controller.enable_motor() controller.set_angle(90.0) # 90 degrees

๐Ÿ›ก๏ธ Safety Features

  • 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

๐Ÿ“ˆ Performance Comparison

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

๐Ÿ” Troubleshooting

CAN Interface Issues

# 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

Permission Issues

# Add user to dialout group sudo usermod -a -G dialout $USER # Or run with sudo sudo python3 can_motor_scanner.py

Hardware Connection

  • Confirm 120ฮฉ terminal resistor
  • Check CAN-H and CAN-L wiring
  • Verify motor power supply is normal
  • Confirm baud rate settings match

๐Ÿ“š Documentation

๐Ÿ—บ๏ธ Development Roadmap

โœ… Completed

  • 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)

โณ To Implement

  • Arduino/ESP32 implementation
  • GUI control interface
  • Simulation test platform
  • Automatic calibration tools

๐Ÿš€ Future Plans

  • Automatic motor parameter identification
  • Batch motor management
  • Real-time data visualization
  • Remote control interface
  • Fault diagnosis tools

๐Ÿค Contributing

Issues and Pull Requests are welcome!

How to Contribute

  1. Fork this repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add some AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

๐Ÿ“„ License

MIT License - See LICENSE file for details

Related Links


Developed based on High Torque Motor SDK protocol table, providing high-performance solutions for robot control

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 27.2%
  • C++ 27.0%
  • Rust 21.7%
  • Shell 14.0%
  • Makefile 10.1%