Metadata-Version: 2.1
Name: libfrankapy
Version: 0.1.1
Summary: Python bindings for libfranka with real-time control
Home-page: https://github.com/libfrankapy/libfrankapy
Author: libfrankapy Team
Author-email: libfrankapy Team <support@libfrankapy.org>
Maintainer-email: libfrankapy Team <support@libfrankapy.org>
License: Apache-2.0
Project-URL: Homepage, https://github.com/libfrankapy/libfrankapy
Project-URL: Documentation, https://libfrankapy.readthedocs.io
Project-URL: Repository, https://github.com/libfrankapy/libfrankapy
Project-URL: Bug Tracker, https://github.com/libfrankapy/libfrankapy/issues
Project-URL: Changelog, https://github.com/libfrankapy/libfrankapy/blob/main/CHANGELOG.md
Keywords: robotics,franka,robot-control,real-time,panda
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: C++
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.19.0
Requires-Dist: pybind11>=2.10.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: sphinx; extra == "dev"
Requires-Dist: sphinx-rtd-theme; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"
Requires-Dist: myst-parser; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
Provides-Extra: examples
Requires-Dist: matplotlib; extra == "examples"
Requires-Dist: scipy; extra == "examples"
Requires-Dist: jupyter; extra == "examples"
Provides-Extra: test
Requires-Dist: pytest>=6.0; extra == "test"
Requires-Dist: pytest-cov>=2.10; extra == "test"
Requires-Dist: pytest-mock>=3.0; extra == "test"
Requires-Dist: coverage[toml]>=6.0; extra == "test"
Provides-Extra: testing
Requires-Dist: pytest>=6.0; extra == "testing"
Requires-Dist: pytest-cov; extra == "testing"
Requires-Dist: pytest-mock; extra == "testing"

# libfrankapy

 [![PyPI version](https://img.shields.io/pypi/v/libfrankapy?color=3776AB)](https://pypi.org/project/libfrankapy/) [![Python 3.9+](https://img.shields.io/badge/python-3.9+-3776AB)](https://www.python.org/downloads/) [![CI](https://img.shields.io/github/actions/workflow/status/han-xudong/libfrankapy/ci.yml?label=CI)](https://github.com/han-xudong/libfrankapy/actions) [![License](https://img.shields.io/badge/License-Apache%202.0-3DA639)](https://opensource.org/licenses/Apache-2.0) [![Documentation](https://img.shields.io/badge/Documentation-newest-5C73E7)](https://han-xudong.github.io/libfrankapy/)

libfrankapy is a Python binding project for the [libfranka](https://github.com/frankarobotics/libfranka) library, designed to provide high-level Python interfaces for Franka robotic arms while maintaining the performance advantages of low-level C++ real-time control.

## ✨ Features

- 🚀 **Real-time Performance Guarantee**: C++ control loop maintains 1kHz real-time performance, Python does not participate in real-time loops
- 🐍 **Python Friendly**: Provides intuitive Python API with complete type hints
- ⚡ **Efficient Communication**: Uses shared memory and atomic operations for Python-C++ data exchange
- 🛡️ **Safety Control**: Complete safety limits, error handling, and emergency stop functionality

## 📋 System Requirements

Hardware Requirements:

- Franka Robotics robotic arm (with FCI functionality)
- Computer with PREEMPT_RT real-time kernel

Software Requirements:

- **Operating System**: Ubuntu 22.04+ with PREEMPT_RT real-time kernel
- **Python**: 3.9+
- **C++ Compiler**: GCC 7+ or Clang 6+
- **CMake**: 3.16+

## 🚀 Installation

Before installing libfrankapy, make sure you have installed libfranka following the [libfranka repository](https://github.com/frankarobotics/libfranka).

### Install from source

First, clone the repository:

```bash
git clone https://github.com/han-xudong/libfrankapy.git
cd libfrankapy
```

It's recommended to create a virtual environment (`venv` or `conda`):

```bash
python -m venv venv
source venv/bin/activate
```

Next, build and install the package:

```bash
pip install -e .
```

### Install from PyPI

```bash
pip install libfrankapy
```

## 🎯 Quick Start

Here is a brief example to get you started:

```python
import libfrankapy as fp
import numpy as np

# Connect to robot
robot = fp.FrankaRobot("192.168.1.100")  # Replace with your robot IP
robot.connect()
robot.start_control()

try:
    # Get current state
    state = robot.get_robot_state()
    print(f"Current joint positions: {state.joint_state.positions}")
    print(f"Current end-effector pose: {state.cartesian_pose.position}")

    # Joint space motion
    target_joints = [0.0, -0.785, 0.0, -2.356, 0.0, 1.571, 0.785]
    robot.move_to_joint(target_joints, speed_factor=0.1)

    # Cartesian space motion
    target_pose = [0.5, 0.0, 0.5, 0.0, 0.0, 0.0, 1.0]  # [x, y, z, qx, qy, qz, qw]
    robot.move_to_pose(target_pose, speed_factor=0.1)

finally:
    # Disconnect
    robot.disconnect()
```

See the `examples/` directory for more usage examples:

- `basic_control.py` - Basic control example
- `trajectory_control.py` - Trajectory control example
- `state_monitoring.py` - Real-time state monitoring example

**Note**: When using this library to control robotic arms, please ensure you follow all safety protocols and test in a controlled environment.

## 🏗️ Architecture Design

libfrankapy adopts a hybrid architecture of C++ real-time environment + Python high-level interface:

```mermaid
graph TD
    A[Python Application Layer] --> B[libfrankapy Python API]
    B --> C[Pybind11 Binding Layer]
    C --> D[C++ Control Manager]
    D --> E[Shared Memory Communication]
    E --> F[Real-time Control Thread]
    F --> G[LibFranka C++ Library]
    G --> H[Franka Robotic Arm Hardware]
    E --> I[Shared Memory Reader]
    I --> B
    J[RealtimeConfig] --> D

    style A fill:#e1f5fe
    style B fill:#f3e5f5
    style C fill:#fff3e0
    style D fill:#e8f5e8
    style E fill:#fff9c4
    style F fill:#ffebee
    style G fill:#f1f8e9
    style H fill:#fce4ec
    style I fill:#e8eaf6
    style J fill:#f3e5f5
```

## 🤝 Contributing

We welcome community contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to participate in project development.

### Development Environment Setup

```bash
# Clone repository
git clone https://github.com/han-xudong/libfrankapy.git
cd libfrankapy

# Create development environment
python3 -m venv venv
source venv/bin/activate

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

# Install pre-commit hooks
pre-commit install
```

## 📄 License

This project is licensed under the [Apache License 2.0](LICENSE).

## 🙏 Acknowledgments

- [Franka Robotics](https://www.franka.de/) for providing excellent robotic arm hardware and the libfranka library
- [pybind11](https://github.com/pybind/pybind11) for providing excellent Python-C++ binding tools
- All developers who have contributed to this project

## 📞 Support

- 📖 [Documentation](https://libfrankapy.readthedocs.io/)
- 🐛 [Issue Tracker](https://github.com/han-xudong/libfrankapy/issues)
- 💬 [Discussions](https://github.com/han-xudong/libfrankapy/discussions)

## 🔗 Related Links

- [libfranka Official Documentation](https://frankarobotics.github.io/docs/)
- [Franka Control Interface (FCI) Documentation](https://frankarobotics.github.io/docs/control_interface.html)
- [Real-time Kernel Installation Guide](https://frankarobotics.github.io/docs/installation_linux.html#setting-up-the-real-time-kernel)
