Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FRI source via FetchContent #10

Merged
merged 17 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/black.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
27 changes: 27 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build

on:
pull_request:
branches:
- main
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, ubuntu-22.04]
fri_version: [1.11, 1.14, 1.15, 1.16, 2.5, 2.7]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Test installation
run: export FRI_CLIENT_VERSION=${{ matrix.fri_version }} && pip3 install --verbose .
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "FRI-Client-SDK_Cpp"]
path = FRI-Client-SDK_Cpp
url = [email protected]:cmower/FRI-Client-SDK_Cpp.git
[submodule "pybind"]
path = pybind
url = [email protected]:pybind/pybind11.git
22 changes: 21 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,32 @@ cmake_minimum_required(VERSION 3.16.3)

project(_pyFRI)

include(FetchContent)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(FRI_BUILD_EXAMPLES OFF)

# set the FRI version
set(FRI_CLIENT_VERSION_MAJOR 1 CACHE STRING "The FRI client major version." FORCE)
set(FRI_CLIENT_VERSION_MINOR 15 CACHE STRING "The FRI client minor version." FORCE)

# fetch the fri depending on the version
FetchContent_Declare(
FRI
GIT_REPOSITORY https://github.com/lbr-stack/fri
GIT_TAG fri-${FRI_CLIENT_VERSION_MAJOR}.${FRI_CLIENT_VERSION_MINOR}
)

FetchContent_MakeAvailable(FRI)

add_subdirectory(pybind)
add_subdirectory(FRI-Client-SDK_Cpp)

pybind11_add_module(_pyFRI ${CMAKE_CURRENT_SOURCE_DIR}/pyFRI/src/wrapper.cpp)

target_include_directories(
_pyFRI
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/pyFRI/src
)

target_link_libraries(_pyFRI PRIVATE FRIClient)
1 change: 0 additions & 1 deletion FRI-Client-SDK_Cpp
Submodule FRI-Client-SDK_Cpp deleted from c2a710
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# FRI-Client-SDK_Python
# pyFRI

[![License](https://img.shields.io/github/license/lbr-stack/pyFRI)](https://github.com/lbr-stack/pyFRI/tree/main?tab=Apache-2.0-1-ov-file#readme)
[![Code Style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

KUKA Fast Robot Interface Python SDK.
The code in this repository, provides Python bindings for the FRI Client SDK C++.
Expand Down Expand Up @@ -36,7 +39,7 @@ See the [examples](examples/).

**THIS IS NOT A KUKA PRODUCT.**

[@cmower](https://github.com/cmower) is not affiliated with KUKA.
[@cmower](https://github.com/cmower) and [@mhubii](https://github.com/mhubii) are not affiliated with KUKA.

# Support

Expand All @@ -47,26 +50,30 @@ The following versions of FRI are currently supported:
Note, whilst FRI version 2.5 is supported some functionality is not.
Currently, FRI Cartesian Overlay is not supported by FRI-Client-SDK_Python.

If you have a different version, please consider [forking](https://github.com/cmower/FRI-Client-SDK_Cpp/fork) and [submitting a pull request](https://github.com/cmower/FRI-Client-SDK_Cpp/pulls).
If you have a different version, please consider [forking](https://github.com/lbr-stack/pyFRI/fork) and [submitting a pull request](https://github.com/lbr-stack/pyFRI/pulls).

# Install

1. Clone repository: `$ git clone --recursive [email protected]:cmower/FRI-Client-SDK_Python.git` (make sure you include `--recursive`)
2. Change directory: `$ cd FRI-Client-SDK_Python`
3. Modify `fri_config.py`: uncomment the line corresponding to your version of FRI.
4. Install: `$ pip install .`
1. Clone repository (make sure you include `--recursive`):
```shell
git clone --recursive https://github.com/lbr-stack/pyFRI.git
```
2. Change directory:
```shell
cd pyFRI
```
3. Install:
```shell
export FRI_CLIENT_VERSION=1.15
pip3 install .
```

## Upgrading/switching between FRI Versions

If you upgrade your FRI version or want to switch between them, you need to manually remove the `FRI-Client-SDK_Python/build` directory before running `pip install`.
If you upgrade your FRI version or want to switch between them, you need to manually remove the `build/` directory before running `pip install`.

# Usage

## Java application

A flexible Java application is provided [here](https://github.com/cmower/LBR-Java-app).
This must be installed on the KUKA Sunrise controller.

## Data types

You can pass NumPy arrays to the "set" methods (e.g. `setJointPosition`) in order to command the robot.
Expand Down
10 changes: 6 additions & 4 deletions examples/LBRJointSineOverlay.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import sys
import math
import argparse
import math
import sys

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

import pyFRI as fri


Expand Down Expand Up @@ -110,7 +112,7 @@ def cvt_joint_mask(value):


def main():
print("Running FRI Version:", fri.FRI_VERSION)
print("Running FRI Version:", fri.FRI_CLIENT_VERSION)

args = get_arguments()
client = LBRJointSineOverlayClient(
Expand Down
13 changes: 8 additions & 5 deletions examples/LBRTorqueSineOverlay.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import sys
import math
import argparse
import pyFRI as fri
import math
import sys

import numpy as np

import pyFRI as fri


class LBRTorqueSineOverlayClient(fri.LBRClient):
def __init__(self, joint_mask, freq_hz, torque_amplitude):
Expand Down Expand Up @@ -98,10 +99,12 @@ def cvt_joint_mask(value):


def main():
print("Running FRI Version:", fri.FRI_VERSION)
print("Running FRI Version:", fri.FRI_CLIENT_VERSION)

args = get_arguments()
client = LBRTorqueSineOverlayClient(args.joint_mask, args.freq_hz, args.torque_amplitude)
client = LBRTorqueSineOverlayClient(
args.joint_mask, args.freq_hz, args.torque_amplitude
)
app = fri.ClientApplication(client)
success = app.connect(args.port, args.hostname)

Expand Down
9 changes: 5 additions & 4 deletions examples/LBRWrenchSineOverlay.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import sys
import math
import argparse
import pyFRI as fri
import math
import sys

import numpy as np

import pyFRI as fri


class LBRWrenchSineOverlayClient(fri.LBRClient):
def __init__(self, frequencyX, frequencyY, amplitudeX, amplitudeY):
Expand Down Expand Up @@ -104,7 +105,7 @@ def get_arguments():


def main():
print("Running FRI Version:", fri.FRI_VERSION)
print("Running FRI Version:", fri.FRI_CLIENT_VERSION)

args = get_arguments()
print(args)
Expand Down
3 changes: 1 addition & 2 deletions examples/admittance.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import numpy as np
import optas
from robot import load_robot

import numpy as np


class AdmittanceController:
def __init__(self, lbr_med_num):
Expand Down
22 changes: 10 additions & 12 deletions examples/hand_guide.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import sys
import math
import argparse
import sys

import numpy as np
from admittance import AdmittanceController

import pyFRI as fri
from pyFRI.tools.filters import ExponentialStateFilter
from pyFRI.tools.state_estimators import (
JointStateEstimator,
FRIExternalTorqueEstimator,
JointStateEstimator,
WrenchEstimatorTaskOffset,
)
from pyFRI.tools.filters import ExponentialStateFilter


from admittance import AdmittanceController

import numpy as np

if fri.FRI_VERSION_MAJOR == 1:
if fri.FRI_CLIENT_VERSION_MAJOR == 1:
POSITION = fri.EClientCommandMode.POSITION
elif fri.FRI_VERSION_MAJOR == 2:
elif fri.FRI_CLIENT_VERSION_MAJOR == 2:
POSITION = fri.EClientCommandMode.JOINT_POSITION


Expand Down Expand Up @@ -103,7 +101,7 @@ def get_arguments():


def main():
print("Running FRI Version:", fri.FRI_VERSION)
print("Running FRI Version:", fri.FRI_CLIENT_VERSION)

args = get_arguments()
client = HandGuideClient(args.lbr_ver)
Expand Down
1 change: 0 additions & 1 deletion examples/ik.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class IK:

"""

This class solves the following problem
Expand Down
8 changes: 4 additions & 4 deletions examples/joint_teleop.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import sys

# FRI Client: https://github.com/cmower/FRI-Client-SDK_Python
import pyFRI as fri

# PyGame: https://www.pygame.org/news
import pygame

# FRI Client: https://github.com/cmower/FRI-Client-SDK_Python
import pyFRI as fri

pygame.init()

# NumPy: https://numpy.org/
Expand Down Expand Up @@ -138,7 +138,7 @@ def get_arguments():


def main():
print("Running FRI Version:", fri.FRI_VERSION)
print("Running FRI Version:", fri.FRI_CLIENT_VERSION)

args = get_arguments()
keyboard = Keyboard()
Expand Down
10 changes: 5 additions & 5 deletions examples/task_teleop.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import sys
import argparse
import sys
from collections import OrderedDict

# FRI Client: https://github.com/cmower/FRI-Client-SDK_Python
import pyFRI as fri

# PyGame: https://www.pygame.org/news
import pygame

# FRI Client: https://github.com/cmower/FRI-Client-SDK_Python
import pyFRI as fri

pygame.init()

# NumPy: https://numpy.org/
Expand Down Expand Up @@ -157,7 +157,7 @@ def get_arguments():


def main():
print("Running FRI Version:", fri.FRI_VERSION)
print("Running FRI Version:", fri.FRI_CLIENT_VERSION)

args = get_arguments()
ik = IK(args.lbr_ver)
Expand Down
3 changes: 0 additions & 3 deletions fri_config.py

This file was deleted.

Loading
Loading