Python bindings for libfranka with real-time control
Project description
libfrankapy
libfrankapy is a Python binding project for the 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.
Install from source
First, clone the repository:
git clone https://github.com/han-xudong/libfrankapy.git
cd libfrankapy
It's recommended to create a virtual environment (venv or conda):
python -m venv venv
source venv/bin/activate
Next, build and install the package:
pip install -e .
Install from PyPI
pip install libfrankapy
🎯 Quick Start
Here is a brief example to get you started:
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 exampletrajectory_control.py- Trajectory control examplestate_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:
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 for details on how to participate in project development.
Development Environment Setup
# 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.
🙏 Acknowledgments
- Franka Robotics for providing excellent robotic arm hardware and the libfranka library
- pybind11 for providing excellent Python-C++ binding tools
- All developers who have contributed to this project
📞 Support
🔗 Related Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file libfrankapy-0.1.1.tar.gz.
File metadata
- Download URL: libfrankapy-0.1.1.tar.gz
- Upload date:
- Size: 119.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbcb502f30451aecd32ecc0a2bb6d9949e1c9fa778af2e2b091fc0a0aa5c8eed
|
|
| MD5 |
4d318e4e0cb74fd17fb033e951a0c7b2
|
|
| BLAKE2b-256 |
b1423ead3a957f50ca06d0b357c3bcce9b051f7ca72bf333411951468c10fb33
|
Provenance
The following attestation bundles were made for libfrankapy-0.1.1.tar.gz:
Publisher:
release.yml on han-xudong/libfrankapy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libfrankapy-0.1.1.tar.gz -
Subject digest:
cbcb502f30451aecd32ecc0a2bb6d9949e1c9fa778af2e2b091fc0a0aa5c8eed - Sigstore transparency entry: 438767068
- Sigstore integration time:
-
Permalink:
han-xudong/libfrankapy@07a6b18d529144911321de23a24fef6a2673033b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/han-xudong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@07a6b18d529144911321de23a24fef6a2673033b -
Trigger Event:
push
-
Statement type:
File details
Details for the file libfrankapy-0.1.1-cp311-cp311-manylinux1_x86_64.whl.
File metadata
- Download URL: libfrankapy-0.1.1-cp311-cp311-manylinux1_x86_64.whl
- Upload date:
- Size: 180.2 kB
- Tags: CPython 3.11
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95366504e13341b66999b81a4b0ef1c7462954594161ea25f91dd772383a072a
|
|
| MD5 |
903b694decbc44bfb2627f6a7fa6a9ff
|
|
| BLAKE2b-256 |
08652cc9efaf8fdb30547c3fa5dd1e01b7bfb381abf7440eb2fbc834d98d5ec1
|
Provenance
The following attestation bundles were made for libfrankapy-0.1.1-cp311-cp311-manylinux1_x86_64.whl:
Publisher:
release.yml on han-xudong/libfrankapy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libfrankapy-0.1.1-cp311-cp311-manylinux1_x86_64.whl -
Subject digest:
95366504e13341b66999b81a4b0ef1c7462954594161ea25f91dd772383a072a - Sigstore transparency entry: 438767097
- Sigstore integration time:
-
Permalink:
han-xudong/libfrankapy@07a6b18d529144911321de23a24fef6a2673033b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/han-xudong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@07a6b18d529144911321de23a24fef6a2673033b -
Trigger Event:
push
-
Statement type:
File details
Details for the file libfrankapy-0.1.1-cp310-cp310-manylinux1_x86_64.whl.
File metadata
- Download URL: libfrankapy-0.1.1-cp310-cp310-manylinux1_x86_64.whl
- Upload date:
- Size: 178.6 kB
- Tags: CPython 3.10
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d500773d889dd0ffe7f0375f6654c63e8c4d6795c36980f8c2273e25f6f3447c
|
|
| MD5 |
62e8aaaa647cc00608530a084c5e3d5e
|
|
| BLAKE2b-256 |
f654695904c7eac596c7da9c6a6b1c20f2d0e4467c5a098a5fb1089919b91124
|
Provenance
The following attestation bundles were made for libfrankapy-0.1.1-cp310-cp310-manylinux1_x86_64.whl:
Publisher:
release.yml on han-xudong/libfrankapy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libfrankapy-0.1.1-cp310-cp310-manylinux1_x86_64.whl -
Subject digest:
d500773d889dd0ffe7f0375f6654c63e8c4d6795c36980f8c2273e25f6f3447c - Sigstore transparency entry: 438767128
- Sigstore integration time:
-
Permalink:
han-xudong/libfrankapy@07a6b18d529144911321de23a24fef6a2673033b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/han-xudong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@07a6b18d529144911321de23a24fef6a2673033b -
Trigger Event:
push
-
Statement type:
File details
Details for the file libfrankapy-0.1.1-cp39-cp39-manylinux1_x86_64.whl.
File metadata
- Download URL: libfrankapy-0.1.1-cp39-cp39-manylinux1_x86_64.whl
- Upload date:
- Size: 182.3 kB
- Tags: CPython 3.9
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a18ad6b5ded74c8e9241ae9412a897f0d7a6981f5ad5bf192b522711f9c08c1
|
|
| MD5 |
437036d593af4f6ba75f95e6b9a9e703
|
|
| BLAKE2b-256 |
652c44ba46104d0adc852cae12384ca4bf2833587edc300ea7bb5c8bbad13d81
|
Provenance
The following attestation bundles were made for libfrankapy-0.1.1-cp39-cp39-manylinux1_x86_64.whl:
Publisher:
release.yml on han-xudong/libfrankapy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libfrankapy-0.1.1-cp39-cp39-manylinux1_x86_64.whl -
Subject digest:
0a18ad6b5ded74c8e9241ae9412a897f0d7a6981f5ad5bf192b522711f9c08c1 - Sigstore transparency entry: 438767114
- Sigstore integration time:
-
Permalink:
han-xudong/libfrankapy@07a6b18d529144911321de23a24fef6a2673033b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/han-xudong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@07a6b18d529144911321de23a24fef6a2673033b -
Trigger Event:
push
-
Statement type: