A comprehensive Python-based controller for a humanoid robot using the PCA9685 servo controller. This project provides both hardware control and a modern web interface for robot operation, making it perfect for robotics enthusiasts, educators, and developers.
-
Full Humanoid Control
- 13 servo control with precise positioning
- Smooth movement sequences
- Pre-programmed movements and dances
- Safety features and servo limits
-
Modern Web Interface
- Real-time servo control with intuitive sliders
- Pre-programmed movement sequences
- Responsive design for all devices
-
Development Tools
- Mock controller for testing without hardware
- Comprehensive calibration tools
- Detailed logging and debugging
- Extensive test suite
- Python 3.8 or higher
- Raspberry Pi (recommended) or compatible hardware
- Adafruit PCA9685 board
- Standard servos (compatible with 50Hz PWM)
-
Clone the repository:
git clone https://github.com/yourusername/robot-controller.git cd robot-controller -
Run the installation script:
./install.sh
This will:
- Create and activate a virtual environment
- Install all required dependencies
- Set up pre-commit hooks
- Create necessary configuration files
Alternatively, you can install manually:
# Create and activate virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install the package with all dependencies pip install -e ".[dev]" # Set up pre-commit hooks pre-commit install
-
Configure your hardware:
- Follow the hardware setup guide
- Run the calibration tool:
python -m robot.calibration - The calibration settings will be saved in
servo_calibration.json
robot-controller/
├── src/ # Source code
├── docs/ # Documentation
├── venv/ # Virtual environment
├── servo_calibration.json # Servo calibration settings
├── start.py # Main entry point
├── install.sh # Installation script
├── pyproject.toml # Project configuration
├── setup.py # Package setup
├── MANIFEST.in # Package manifest
└── .pre-commit-config.yaml # Pre-commit hooks
| Channel | Component | Description |
|---|---|---|
| 0 | Head | Controls head movement |
| 1 | Right Shoulder | Controls right arm movement |
| 2 | Left Shoulder | Controls left arm movement |
| 3 | Right Elbow | Controls right elbow movement |
| 4 | Left Elbow | Controls left elbow movement |
| 5 | Right Hip | Controls right leg movement |
| 6 | Left Hip | Controls left leg movement |
| 7 | Right Knee | Controls right knee movement |
| 8 | Left Knee | Controls left knee movement |
| 9 | Right Ankle | Controls right foot movement |
| 10 | Left Ankle | Controls left foot movement |
| 11 | Right Wrist | Controls right hand movement |
| 12 | Left Wrist | Controls left hand movement |
python start.pyThis launches the main menu with options to:
- Start Web Interface
- Start Command Line Controller
- Run Calibration Tool
- Check and Install Dependencies
- Exit
from robot_controller import RobotController
# Initialize the robot
robot = RobotController()
robot.initialize_robot()
# Basic movements
robot.stand_up()
robot.step_forward()
robot.dance()
# Advanced movements
robot.wave_hand("right")
robot.look_around()
robot.perform_sequence("greeting")
# Shutdown
robot.shutdown()Access the web interface at http://localhost:5000 after starting the web server.
- Real-time servo control with sliders
- Pre-programmed movements
- Robot status display
- Movement sequence programming
| Endpoint | Method | Description |
|---|---|---|
/api/init |
POST | Initialize the robot |
/api/servo |
POST | Move a specific servo |
/api/servo/<index> |
GET | Get servo position |
/api/stand |
POST | Make robot stand up |
/api/walk |
POST | Make robot walk forward |
/api/shutdown |
POST | Shutdown the robot |
/api/robot_info |
GET | Get robot state information |
/api/dance |
POST | Start dance routine |
-
Module Import Errors
# Set PYTHONPATH export PYTHONPATH=$PYTHONPATH:$(pwd)/src
-
Servo Jittering
- Check power supply voltage
- Ensure proper grounding
- Verify servo connections
Enable debug logging:
import logging
logging.basicConfig(level=logging.DEBUG)We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
-
Install development dependencies:
pip install -e ".[dev]" -
Run tests:
python -m pytest tests/
-
Check code style:
pre-commit run --all-files
For detailed documentation, visit the docs directory in this repository.
This project is licensed under the MIT License - see the LICENSE file for details.
- Adafruit for the PCA9685 library
- Open source robotics community
- Contributors and maintainers
Made with ❤️ by the Robot Controller Team