# Pmini SDK Python
Python SDK for Pmini quadcopter with gRPC support and auto-generated wrapper classes.
## Features
- **MAVLink Integration**: Direct communication with Pmini quadcopter via MAVLink protocol
- **gRPC Support**: Modern gRPC API with auto-generated Python classes
- **Type Safety**: Full type hints and IDE support for all generated classes
- **MAVSDK-Style API**: Familiar API design with comprehensive documentation
- **Poetry Package Management**: Modern Python packaging and dependency management
## Quick Start
### Option 1: Development Setup (Recommended)
```bash
# Clone the repository
git clone <repository-url>
cd pmini_sdk_python
# Setup development environment (installs Poetry if needed)
./setup_dev.sh
# Activate Poetry shell
poetry shell
```
### Option 2: Manual Setup
```bash
# Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 -
# Install dependencies
poetry install
# Generate gRPC classes
./tools/run_grpc_protoc.sh
```
### Option 3: Package Installation
```bash
# Build the package
./build_package.sh
# Install the built package
pip install ./dist/pmini-*.whl
```
## Generated Classes
The SDK automatically generates type-safe Python classes from protobuf definitions:
### Basic Usage
```python
from pmini_sdk_python.generated import (
TakeoffRequest,
Position,
DroneService,
CommandResponse
)
# Create requests with type safety
takeoff_request = TakeoffRequest(altitude=10.0)
position = Position(x=1.0, y=2.0, z=3.0)
# Use with gRPC service
import grpc
channel = grpc.insecure_channel('localhost:50051')
drone_service = DroneService(channel)
response = drone_service.takeoff(takeoff_request)
print(f"Takeoff success: {response.success}")
```
### Available Classes
- **Request Classes**: `TakeoffRequest`, `LandRequest`, `ArmRequest`, `DisarmRequest`, `SetModeRequest`
- **Response Classes**: `CommandResponse`, `StatusResponse`, `PositionResponse`
- **Data Classes**: `TelemetryData`, `Position`, `Velocity`, `Attitude`
- **Service Classes**: `DroneService` (gRPC service wrapper)
### Class Features
- **Type Safety**: All fields have proper type hints
- **Documentation**: MAVSDK-style docstrings with parameter descriptions
- **Constructors**: Explicit constructors with parameter validation
- **Conversion Methods**: `to_proto()` and `from_proto()` for gRPC interop
## Examples
### MAVLink Examples
```bash
cd examples
python3 takeoff.py # MAVLink-based takeoff example
```
### gRPC Examples
```bash
cd examples
python3 generated_classes_example.py # Generated classes usage
python3 constructor_examples.py # Constructor demonstrations
python3 improved_documentation_example.py # Documentation examples
```
## Development
### Regenerating Classes
When you modify `proto/drone.proto`, regenerate the wrapper classes:
```bash
./tools/run_grpc_protoc.sh
```
### Building the Package
```bash
./build_package.sh
```
### Project Structure
```
pmini_sdk_python/
├── proto/ # Protocol buffer definitions
│ └── drone.proto
├── pmini_sdk_python/ # Main package
│ ├── generated/ # Auto-generated gRPC classes
│ ├── mavlink_client.py # MAVLink implementation
│ └── pmini.py # Main SDK class
├── tools/ # Code generation tools
│ ├── templates/ # Jinja2 templates for class generation
│ ├── generate_classes.py # Class generator script
│ └── run_grpc_protoc.sh # Build script
├── examples/ # Usage examples
├── test/ # Integration tests
└── docs/ # Documentation
```
### Dependencies
- **Runtime**: `grpcio`, `pymavlink`, `plotly`, `dash`
- **Development**: `grpcio-tools`, `jinja2`, `poetry`
- **Testing**: `pytest`, `pytest-cov`
# Integration Tests for Pmini SDK
This directory contains integration tests for the Pmini SDK Python library.
## Test Structure
- `conftest.py` - Pytest configuration and fixtures
- `test_basic.py` - Basic tests that don't require simulation
- `test_connection.py` - Connection tests that require simulation
- `run_integration_tests.py` - Test runner script
## Prerequisites
1. Install dependencies:
```bash
pip install pytest pytest-cov
```
2. Install the SDK:
```bash
pip install -e .
```
## Running Tests
### Note
For the integration testing, autopilot simulation is required.
You can use this repository to start the simulation: https://gitlab.com/regislab/pathfindermini/pf_mini_gazebo
```bash
git clone git@gitlab.com:regislab/pathfindermini/pf_mini_gazebo.git && cd pf_mini_gazebo
```
Launch the simulation with the following command
```bash
make run
```
### Basic Tests (No Simulation Required)
```bash
# Run basic tests only
python -m pytest test/test_basic.py -v
# Or use the test runner
python test/run_integration_tests.py --test-path test/test_basic.py
```
### Connection Tests (Requires Simulation)
```bash
# Start your simulation container first, then:
python -m pytest test/test_connection.py -v
```
### All Tests
```bash
# Run all tests
python -m pytest test/ -v
```
### With Markers
```bash
# Run only integration tests
python -m pytest test/ -m integration
# Run only connection tests
python -m pytest test/ -m connection
# Exclude slow tests
python -m pytest test/ -m "not slow"
```
## Test Configuration
The tests are configured to connect to a simulation running on:
- Host: `192.168.4.1`
- Port: `8080`
- Protocol: `UDP`
You can modify the connection settings in `conftest.py` if your simulation uses different parameters.
## Test Categories
### Basic Tests (`test_basic.py`)
- SDK import verification
- Configuration object creation
- Enum availability
- Logging setup
### Connection Tests (`test_connection.py`)
- Connection establishment
- Connection stability
- MAVLink client functionality
- Optical flow data availability
- Connection timeout handling
- Connection recovery
## Adding New Tests
1. Create a new test file: `test_<feature>.py`
2. Use the existing fixtures from `conftest.py`
3. Add appropriate markers to your tests
4. Follow the existing test patterns
Example:
```python
import pytest
import logging
class TestNewFeature:
@pytest.mark.integration
def test_new_feature(self, pmini_instance, wait_for_connection):
logger = logging.getLogger(__name__)
logger.info("Testing new feature")
# Your test logic here
assert True
logger.info("✅ New feature test passed")
```
## Troubleshooting
### Connection Timeout
If tests fail with connection timeout:
1. Ensure your simulation container is running
2. Check that the simulation is listening on the correct port
3. Verify network connectivity between test environment and simulation
### Import Errors
If you get import errors:
1. Make sure the SDK is installed: `pip install -e .`
2. Check that all dependencies are installed: `pip install -r requirements.txt`
### Test Failures
- Check the logs for detailed error messages
- Use `-v` flag for verbose output
- Use `-s` flag to see print statements
Raw data
{
"_id": null,
"home_page": "https://github.com/RegisLab/pmini-sdk",
"name": "pmini_sdk",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "drone, quadcopter, mavlink, sdk",
"author": "RegisLab",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/ae/fc/1853667bf1e6b3c9a2e0e1e4120fac65cdf6b06e1b1eb687649fa78d0772/pmini_sdk-1.0.0.tar.gz",
"platform": null,
"description": "# Pmini SDK Python\n\nPython SDK for Pmini quadcopter with gRPC support and auto-generated wrapper classes.\n\n## Features\n\n- **MAVLink Integration**: Direct communication with Pmini quadcopter via MAVLink protocol\n- **gRPC Support**: Modern gRPC API with auto-generated Python classes\n- **Type Safety**: Full type hints and IDE support for all generated classes\n- **MAVSDK-Style API**: Familiar API design with comprehensive documentation\n- **Poetry Package Management**: Modern Python packaging and dependency management\n\n## Quick Start\n\n### Option 1: Development Setup (Recommended)\n\n```bash\n# Clone the repository\ngit clone <repository-url>\ncd pmini_sdk_python\n\n# Setup development environment (installs Poetry if needed)\n./setup_dev.sh\n\n# Activate Poetry shell\npoetry shell\n```\n\n### Option 2: Manual Setup\n\n```bash\n# Install Poetry (if not already installed)\ncurl -sSL https://install.python-poetry.org | python3 -\n\n# Install dependencies\npoetry install\n\n# Generate gRPC classes\n./tools/run_grpc_protoc.sh\n```\n\n### Option 3: Package Installation\n\n```bash\n# Build the package\n./build_package.sh\n\n# Install the built package\npip install ./dist/pmini-*.whl\n```\n\n## Generated Classes\n\nThe SDK automatically generates type-safe Python classes from protobuf definitions:\n\n### Basic Usage\n\n```python\nfrom pmini_sdk_python.generated import (\n TakeoffRequest, \n Position, \n DroneService,\n CommandResponse\n)\n\n# Create requests with type safety\ntakeoff_request = TakeoffRequest(altitude=10.0)\nposition = Position(x=1.0, y=2.0, z=3.0)\n\n# Use with gRPC service\nimport grpc\nchannel = grpc.insecure_channel('localhost:50051')\ndrone_service = DroneService(channel)\n\nresponse = drone_service.takeoff(takeoff_request)\nprint(f\"Takeoff success: {response.success}\")\n```\n\n### Available Classes\n\n- **Request Classes**: `TakeoffRequest`, `LandRequest`, `ArmRequest`, `DisarmRequest`, `SetModeRequest`\n- **Response Classes**: `CommandResponse`, `StatusResponse`, `PositionResponse`\n- **Data Classes**: `TelemetryData`, `Position`, `Velocity`, `Attitude`\n- **Service Classes**: `DroneService` (gRPC service wrapper)\n\n### Class Features\n\n- **Type Safety**: All fields have proper type hints\n- **Documentation**: MAVSDK-style docstrings with parameter descriptions\n- **Constructors**: Explicit constructors with parameter validation\n- **Conversion Methods**: `to_proto()` and `from_proto()` for gRPC interop\n\n## Examples\n\n### MAVLink Examples\n\n```bash\ncd examples\npython3 takeoff.py # MAVLink-based takeoff example\n```\n\n### gRPC Examples\n\n```bash\ncd examples\npython3 generated_classes_example.py # Generated classes usage\npython3 constructor_examples.py # Constructor demonstrations\npython3 improved_documentation_example.py # Documentation examples\n```\n\n## Development\n\n### Regenerating Classes\n\nWhen you modify `proto/drone.proto`, regenerate the wrapper classes:\n\n```bash\n./tools/run_grpc_protoc.sh\n```\n\n### Building the Package\n\n```bash\n./build_package.sh\n```\n\n### Project Structure\n\n```\npmini_sdk_python/\n\u251c\u2500\u2500 proto/ # Protocol buffer definitions\n\u2502 \u2514\u2500\u2500 drone.proto\n\u251c\u2500\u2500 pmini_sdk_python/ # Main package\n\u2502 \u251c\u2500\u2500 generated/ # Auto-generated gRPC classes\n\u2502 \u251c\u2500\u2500 mavlink_client.py # MAVLink implementation\n\u2502 \u2514\u2500\u2500 pmini.py # Main SDK class\n\u251c\u2500\u2500 tools/ # Code generation tools\n\u2502 \u251c\u2500\u2500 templates/ # Jinja2 templates for class generation\n\u2502 \u251c\u2500\u2500 generate_classes.py # Class generator script\n\u2502 \u2514\u2500\u2500 run_grpc_protoc.sh # Build script\n\u251c\u2500\u2500 examples/ # Usage examples\n\u251c\u2500\u2500 test/ # Integration tests\n\u2514\u2500\u2500 docs/ # Documentation\n```\n\n### Dependencies\n\n- **Runtime**: `grpcio`, `pymavlink`, `plotly`, `dash`\n- **Development**: `grpcio-tools`, `jinja2`, `poetry`\n- **Testing**: `pytest`, `pytest-cov`\n\n# Integration Tests for Pmini SDK\n\nThis directory contains integration tests for the Pmini SDK Python library.\n\n## Test Structure\n\n- `conftest.py` - Pytest configuration and fixtures\n- `test_basic.py` - Basic tests that don't require simulation\n- `test_connection.py` - Connection tests that require simulation\n- `run_integration_tests.py` - Test runner script\n\n## Prerequisites\n\n1. Install dependencies:\n\n```bash\npip install pytest pytest-cov\n```\n\n2. Install the SDK:\n```bash\npip install -e .\n```\n\n## Running Tests\n\n### Note \n\nFor the integration testing, autopilot simulation is required.\nYou can use this repository to start the simulation: https://gitlab.com/regislab/pathfindermini/pf_mini_gazebo\n\n```bash\ngit clone git@gitlab.com:regislab/pathfindermini/pf_mini_gazebo.git && cd pf_mini_gazebo\n```\n\nLaunch the simulation with the following command\n\n```bash\nmake run\n```\n\n### Basic Tests (No Simulation Required)\n```bash\n# Run basic tests only\npython -m pytest test/test_basic.py -v\n\n# Or use the test runner\npython test/run_integration_tests.py --test-path test/test_basic.py\n```\n\n### Connection Tests (Requires Simulation)\n```bash\n# Start your simulation container first, then:\npython -m pytest test/test_connection.py -v\n\n```\n\n### All Tests\n```bash\n# Run all tests\npython -m pytest test/ -v\n```\n\n### With Markers\n```bash\n# Run only integration tests\npython -m pytest test/ -m integration\n\n# Run only connection tests\npython -m pytest test/ -m connection\n\n# Exclude slow tests\npython -m pytest test/ -m \"not slow\"\n```\n\n## Test Configuration\n\nThe tests are configured to connect to a simulation running on:\n- Host: `192.168.4.1`\n- Port: `8080`\n- Protocol: `UDP`\n\nYou can modify the connection settings in `conftest.py` if your simulation uses different parameters.\n\n## Test Categories\n\n### Basic Tests (`test_basic.py`)\n- SDK import verification\n- Configuration object creation\n- Enum availability\n- Logging setup\n\n### Connection Tests (`test_connection.py`)\n- Connection establishment\n- Connection stability\n- MAVLink client functionality\n- Optical flow data availability\n- Connection timeout handling\n- Connection recovery\n\n## Adding New Tests\n\n1. Create a new test file: `test_<feature>.py`\n2. Use the existing fixtures from `conftest.py`\n3. Add appropriate markers to your tests\n4. Follow the existing test patterns\n\nExample:\n```python\nimport pytest\nimport logging\n\nclass TestNewFeature:\n @pytest.mark.integration\n def test_new_feature(self, pmini_instance, wait_for_connection):\n logger = logging.getLogger(__name__)\n logger.info(\"Testing new feature\")\n \n # Your test logic here\n assert True\n logger.info(\"\u2705 New feature test passed\")\n```\n\n## Troubleshooting\n\n### Connection Timeout\nIf tests fail with connection timeout:\n1. Ensure your simulation container is running\n2. Check that the simulation is listening on the correct port\n3. Verify network connectivity between test environment and simulation\n\n### Import Errors\nIf you get import errors:\n1. Make sure the SDK is installed: `pip install -e .`\n2. Check that all dependencies are installed: `pip install -r requirements.txt`\n\n### Test Failures\n- Check the logs for detailed error messages\n- Use `-v` flag for verbose output\n- Use `-s` flag to see print statements \n",
"bugtrack_url": null,
"license": "Proprietary",
"summary": "Python SDK for Pmini quadcopter",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/RegisLab/pmini-sdk",
"Repository": "https://github.com/RegisLab/pmini-sdk"
},
"split_keywords": [
"drone",
" quadcopter",
" mavlink",
" sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "63dd7aed706900d42ed53c331d847f39a25a4f7e7ed769e83513831e55b46866",
"md5": "bffa003391b618d18714c9832699a26a",
"sha256": "d446f6dcc41e3646d83a79ea85aadf18bc0fda537cd85c75ba3a18257e3f877c"
},
"downloads": -1,
"filename": "pmini_sdk-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bffa003391b618d18714c9832699a26a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 61667,
"upload_time": "2025-08-28T15:26:51",
"upload_time_iso_8601": "2025-08-28T15:26:51.973730Z",
"url": "https://files.pythonhosted.org/packages/63/dd/7aed706900d42ed53c331d847f39a25a4f7e7ed769e83513831e55b46866/pmini_sdk-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aefc1853667bf1e6b3c9a2e0e1e4120fac65cdf6b06e1b1eb687649fa78d0772",
"md5": "79adf7223c9ece6ec45f2a532f50341c",
"sha256": "b32f0cecb3d0c9866cbfdca297de490c20956d6d70464f849b779a02e67f8fbe"
},
"downloads": -1,
"filename": "pmini_sdk-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "79adf7223c9ece6ec45f2a532f50341c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 44152,
"upload_time": "2025-08-28T15:26:53",
"upload_time_iso_8601": "2025-08-28T15:26:53.611226Z",
"url": "https://files.pythonhosted.org/packages/ae/fc/1853667bf1e6b3c9a2e0e1e4120fac65cdf6b06e1b1eb687649fa78d0772/pmini_sdk-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-28 15:26:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "RegisLab",
"github_project": "pmini-sdk",
"github_not_found": true,
"lcname": "pmini_sdk"
}