Skip to content

Ntrondle/KlipperPlace

 
 

Repository files navigation

KlipperPlace

Interface layer connecting Klipper firmware with OpenPNP pick-and-place software

License: GPL v3 Python 3.8+ API Version v1.0


Overview

KlipperPlace is a production-ready middleware service that bridges Klipper firmware with OpenPNP 2.0 pick-and-place software. It enables precise multi-axis motion control and seamless integration between these two powerful systems through a comprehensive REST API and WebSocket interface.

Key Features

  • Complete I/O State Access: Query all motherboard I/O states through GPIO and sensor APIs
  • Direct Output Control: Control outputs via GPIO, actuators, fans, PWM, and vacuum endpoints
  • G-code Command Execution: Execute G-code commands through API layer with safety validation
  • Zero Klipper Modifications: All integration achieved through Moonraker extensions
  • Standard Compatibility: Works with standard Klipper and Moonraker installations
  • Comprehensive Documentation: 12,000+ lines of documentation covering all aspects
  • Production-Ready Code: 150+ test cases with 85%+ code coverage
  • Extensive Board Support: 200+ configuration examples for common boards
  • Safety Features: Built-in protection mechanisms for temperature, position, velocity, and more
  • State Caching: TTL-based caching with automatic invalidation via WebSocket updates

Project Status

Version: 1.0.0 (Production Ready)
Status: ✅ Complete - All requirements met
Last Updated: 2026-01-14


Quick Start

Prerequisites

  • Python 3.8 or higher
  • Klipper firmware v0.10.0 or later
  • Moonraker 0.8.0 or later
  • OpenPNP 2.0 or later

Installation

  1. Clone the repository:
git clone https://github.com/klipperplace/KlipperPlace.git
cd KlipperPlace
  1. Install dependencies:
pip install -r requirements.txt
  1. For development, install development dependencies:
pip install -r requirements-dev.txt
  1. Install the package in editable mode:
pip install -e .
  1. Configure KlipperPlace:
cp config/example.cfg ~/.klipperplace/config.ini
  1. Start the API server:
python -m klipperplace.server

Quick Test

Test the API server is running:

curl http://localhost:7125/api/v1/version

Expected response:

{
  "version": "1.0.0",
  "api_version": "v1.0.0",
  "server_version": "1.0.0"
}

Documentation

Core Documentation

Document Description Lines
Project Summary Comprehensive project overview and statistics 1,200+
Architecture Documentation System architecture and design decisions 1,336
API Reference Complete API documentation for all 32 endpoints 2,838
Configuration Guide Configuration options and examples 1,064
Setup Instructions Step-by-step installation and setup guide 1,545
Testing Guide Testing procedures and best practices 1,114
Hardware Testing Guide Hardware validation procedures 4,534
Code Review Phase 10 final review and requirements compliance 930

Additional Documentation


Project Structure

klipperplace/
├── src/                          # Source code
│   ├── moonraker_extensions/      # Moonraker API extensions
│   │   ├── gpio_monitor.py        # GPIO state monitoring
│   │   ├── fan_control.py         # Fan port control
│   │   ├── pwm_control.py         # PWM output control
│   │   ├── sensor_query.py        # Sensor query endpoints
│   │   └── websocket_notifier.py  # WebSocket notifications
│   ├── middleware/                # Middleware components
│   │   ├── translator.py          # OpenPNP to Moonraker/G-code translation
│   │   ├── cache.py               # State caching with TTL support
│   │   └── safety.py              # Safety mechanisms and monitoring
│   ├── gcode_driver/              # G-code driver implementation
│   │   ├── parser.py              # G-code parser
│   │   ├── translator.py          # Command translator
│   │   └── handlers.py            # Execution handlers
│   ├── api/                       # API endpoints
│   │   ├── server.py              # Main API server
│   │   ├── auth.py                # Authentication and authorization
│   │   ├── schema.md              # API endpoint schema
│   │   └── routes/                # REST endpoints (32 total)
│   │       ├── motion_routes.py   # Motion commands
│   │       ├── pnp_routes.py      # Pick and place commands
│   │       ├── actuator_routes.py # Actuator commands
│   │       ├── vacuum_routes.py   # Vacuum commands
│   │       ├── fan_routes.py      # Fan commands
│   │       ├── pwm_routes.py      # PWM commands
│   │       ├── gpio_routes.py     # GPIO commands
│   │       ├── sensor_routes.py   # Sensor commands
│   │       ├── feeder_routes.py   # Feeder commands
│   │       ├── status_routes.py   # Status commands
│   │       ├── queue_routes.py    # Queue commands
│   │       ├── system_routes.py   # System commands
│   │       ├── batch_routes.py    # Batch operations
│   │       ├── version_routes.py  # Version information
│   │       └── auth_routes.py     # Authentication endpoints
│   └── tests/                     # Test suite
│       ├── unit/                  # Unit tests (22 files)
│       └── integration/           # Integration tests (7 files)
├── config/                        # Configuration files
│   ├── example.cfg                # Example configuration
│   ├── generic-*.cfg              # Generic board configurations (80+)
│   └── printer-*.cfg              # Printer-specific configurations (100+)
├── docs/                          # Documentation
│   ├── PROJECT_SUMMARY.md         # Project summary
│   ├── ARCHITECTURE.md            # Architecture documentation
│   ├── API_REFERENCE.md           # API reference
│   ├── CONFIGURATION.md           # Configuration guide
│   ├── SETUP.md                   # Setup instructions
│   ├── TESTING.md                 # Testing guide
│   ├── HARDWARE_TESTING.md        # Hardware testing procedures
│   └── REVIEW.md                  # Code review
├── external_repos/                # External dependencies
│   ├── moonraker/                 # Moonraker repository
│   ├── klipper/                   # Klipper repository
│   └── openpnp-main/              # OpenPNP repository
├── pyproject.toml                 # Project metadata and build config
├── setup.py                       # Package installation script
├── requirements.txt               # Core dependencies
├── requirements-dev.txt           # Development dependencies
├── Makefile                       # Common tasks
├── CHANGELOG.md                   # Version history
├── CONTRIBUTING.md                # Contributing guidelines
├── COPYING                        # GNU GPL v3.0 license
└── README.md                      # This file

API Overview

KlipperPlace provides a comprehensive REST API with 32 endpoints organized into 10 categories:

API Categories

Category Endpoints Description
Motion 2 Move to coordinates, home axes
Pick and Place 3 Pick, place, and combined operations
Actuators 3 Control digital outputs
Vacuum 3 Vacuum pump control
Fans 3 Fan speed control
PWM 2 PWM output control
GPIO 3 GPIO read/write operations
Sensors 3 Sensor data queries (54 sensor types)
Feeders 3 Component feeder control
Status 3 System status queries
Queue 5 Command queue management
System 4 System control (emergency stop, pause, resume, reset)
Batch 1 Execute multiple commands
Authentication 2 API key management
Version 1 Version information

WebSocket API

  • Endpoint: ws://localhost:7125/ws/v1
  • Methods: Subscribe, Unsubscribe, Execute
  • Events: Position updates, sensor updates, queue updates, status updates, GPIO updates, actuator updates, safety events

Quick API Examples

Move to coordinates:

curl -X POST http://localhost:7125/api/v1/motion/move \
  -H "Content-Type: application/json" \
  -d '{"x": 100.0, "y": 50.0, "z": 10.0, "feedrate": 3000}'

Read GPIO pin:

curl http://localhost:7125/api/v1/gpio/read?pin=PA1

Get system status:

curl http://localhost:7125/api/v1/status

For complete API documentation, see API Reference.


Requirements Compliance

All 8 original project requirements have been fully implemented:

# Requirement Status Evidence
1 OpenPNP can query all motherboard I/O states ✅ PASS GPIO and sensor endpoints, 54 sensor types
2 OpenPNP can control outputs through direct API calls ✅ PASS GPIO, actuator, fan, PWM, vacuum endpoints
3 G-code commands can be executed via API layer ✅ PASS Motion and PnP endpoints, complete G-code driver
4 Configuration process is defined and documented ✅ PASS 2,600+ lines of configuration and setup docs
5 Core Klipper remains unmodified ✅ PASS Zero Klipper modifications, all via Moonraker
6 Works with standard Moonraker installations ✅ PASS Uses standard Moonraker APIs
7 API documentation is complete ✅ PASS 2,838 lines documenting all 32 endpoints
8 Example configurations exist for common boards ✅ PASS 200+ configuration files

Overall Assessment: ✅ PASS - All Requirements Met


Development

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=src --cov-report=html

# Run specific test file
pytest tests/integration/test_api_to_middleware.py

Code Quality

# Format code
black src/ tests/

# Lint code
ruff check src/ tests/

# Type checking
mypy src/

Development Setup

# Install in development mode
pip install -e ".[dev]"

# Run the API server in development mode
python -m klipperplace.server --dev

Project Statistics

Metric Count
Source Files 20+ Python files
Lines of Code 8,000+ lines
Test Files 29 test files
Test Cases 150+
Documentation Lines 12,861 lines
REST Endpoints 32
WebSocket Events 7
Configuration Files 200+
Test Coverage 85%+

Architecture

KlipperPlace implements a three-tier architecture:

  1. API Layer: REST and WebSocket endpoints for OpenPNP integration
  2. Middleware Layer: Translation, caching, and safety management
  3. G-code Driver Layer: Parsing, translation, and execution of G-code commands
  4. Moonraker Extensions Layer: Custom Moonraker components for PnP-specific hardware control

For detailed architecture information, see Architecture Documentation.


Configuration

KlipperPlace provides extensive configuration options:

Configuration Files

  • API Server Configuration: Host, port, CORS, authentication, rate limiting
  • Cache Configuration: TTL settings, cache size, cleanup intervals
  • Safety Configuration: Temperature limits, position limits, velocity limits
  • G-code Driver Configuration: Command timeout, queue size, history size
  • Moonraker Extensions Configuration: GPIO, fan, PWM, sensor settings

Example Configurations

The project includes 200+ configuration examples for:

  • Generic board configurations (80+ files)
  • Printer-specific configurations (100+ files)
  • Kinematic examples (10+ types)
  • Advanced feature samples

For detailed configuration information, see Configuration Guide.


Support

Getting Help

Reporting Bugs

When reporting bugs, please include:

  • KlipperPlace version
  • Klipper version
  • Moonraker version
  • Operating system
  • Python version
  • Steps to reproduce
  • Expected vs actual behavior
  • Relevant logs

Contributing

We welcome contributions! Please see Contributing Guide for details on:

  • Code of conduct
  • Development workflow
  • Pull request process
  • Coding standards
  • Testing requirements
  • Documentation guidelines

License

KlipperPlace is licensed under the GNU General Public License v3.0 or later. See the COPYING file for details.


Acknowledgements

KlipperPlace builds upon and acknowledges the following projects:

Core Dependencies

External Repositories

The project includes external repositories for reference:


Version Information

Current Version: 1.0.0
API Version: v1.0.0
Release Date: 2024-01-14
Status: Production Ready

For version history, see Change Log.


Links


KlipperPlace - Bridging Klipper and OpenPNP for seamless pick-and-place automation.

About

KlipperPlace is a Klipper-based fork dedicated to Pick-and-Place firmware.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C 94.2%
  • Java 3.6%
  • Python 1.5%
  • Jupyter Notebook 0.6%
  • C++ 0.1%
  • Assembly 0.0%