Skip to content

Commit

Permalink
clean-up (#14, #15)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhubii committed Sep 7, 2024
1 parent 871c568 commit d837b98
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 106 deletions.
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, windows-latest]
fri_version: [1.11, 1.14, 1.15, 1.16, 2.5, 2.7]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10
- name: Export FRI_CLIENT_VERSION
run: export FRI_CLIENT_VERSION=${{ matrix.fri_version }}
- name: Test installation
run: pip3 install .
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(FRI_BUILD_EXAMPLES OFF)

# set the FRI version
set(FRI_VERSION_MAJOR 1 CACHE STRING "The FRI major version." FORCE)
set(FRI_VERSION_MINOR 15 CACHE STRING "The FRI minor version." FORCE)
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_VERSION_MAJOR}.${FRI_VERSION_MINOR}
GIT_TAG fri-${FRI_CLIENT_VERSION_MAJOR}.${FRI_CLIENT_VERSION_MINOR}
)

FetchContent_MakeAvailable(FRI)

# fri configure file
configure_file(fri_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/pyFRI/src/fri_config.h)

add_subdirectory(pybind)

pybind11_add_module(_pyFRI ${CMAKE_CURRENT_SOURCE_DIR}/pyFRI/src/wrapper.cpp)
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 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++.
The interface has been designed to be as similar as possible to the documentation provided by KUKA.
Expand Down Expand Up @@ -52,11 +55,18 @@ If you have a different version, please consider [forking](https://github.com/lb
# Install

1. Clone repository (make sure you include `--recursive`):
- (ssh) `$ git clone --recursive [email protected]:lbr-stack/pyFRI.git`
- (https) `$ git clone --recursive https://github.com/lbr-stack/pyFRI.git`
2. Change directory: `$ cd pyFRI`
3. Modify `fri_config.py`: uncomment the line corresponding to your version of FRI.
4. Install: `$ pip install .`
```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

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
10 changes: 0 additions & 10 deletions fri_config.h.in

This file was deleted.

3 changes: 0 additions & 3 deletions fri_config.py

This file was deleted.

10 changes: 0 additions & 10 deletions pyFRI/src/fri_config.h

This file was deleted.

20 changes: 10 additions & 10 deletions pyFRI/src/wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
// KUKA FRI-Client-SDK_Cpp (using version hosted at:
// https://github.com/cmower/FRI-Client-SDK_Cpp)
#include "friClientApplication.h"
#include "friClientVersion.h"
#include "friLBRClient.h"
#include "friUdpConnection.h"
#include "fri_config.h"

// Function for returning the current time
long long getCurrentTimeInNanoseconds() {
Expand Down Expand Up @@ -206,10 +206,10 @@ PYBIND11_MODULE(_pyFRI, m) {
m.doc() = "Python bindings for the KUKA FRI Client SDK. THIS IS NOT A KUKA "
"PRODUCT.";

m.attr("FRI_VERSION_MAJOR") = FRI_VERSION_MAJOR;
m.attr("FRI_VERSION_MINOR") = FRI_VERSION_MINOR;
m.attr("FRI_VERSION") = std::to_string(FRI_VERSION_MAJOR) + "." +
std::to_string(FRI_VERSION_MINOR);
m.attr("FRI_CLIENT_VERSION_MAJOR") = FRI_CLIENT_VERSION_MAJOR;
m.attr("FRI_CLIENT_VERSION_MINOR") = FRI_CLIENT_VERSION_MINOR;
m.attr("FRI_CLIENT_VERSION") = std::to_string(FRI_CLIENT_VERSION_MAJOR) +
"." + std::to_string(FRI_CLIENT_VERSION_MINOR);

py::enum_<KUKA::FRI::ESessionState>(m, "ESessionState")
.value("IDLE", KUKA::FRI::ESessionState::IDLE)
Expand Down Expand Up @@ -262,9 +262,9 @@ PYBIND11_MODULE(_pyFRI, m) {
.value("NO_COMMAND_MODE", KUKA::FRI::EClientCommandMode::NO_COMMAND_MODE)
.value("WRENCH", KUKA::FRI::EClientCommandMode::WRENCH)
.value("TORQUE", KUKA::FRI::EClientCommandMode::TORQUE)
#if FRI_VERSION_MAJOR == 1
#if FRI_CLIENT_VERSION_MAJOR == 1
.value("POSITION", KUKA::FRI::EClientCommandMode::POSITION)
#elif FRI_VERSION_MAJOR == 2
#elif FRI_CLIENT_VERSION_MAJOR == 2
.value("JOINT_POSITION", KUKA::FRI::EClientCommandMode::JOINT_POSITION)
.value("CARTESIAN_POSE", KUKA::FRI::EClientCommandMode::CARTESIAN_POSE)
#endif
Expand All @@ -276,7 +276,7 @@ PYBIND11_MODULE(_pyFRI, m) {
.value("CARTESIAN", KUKA::FRI::EOverlayType::CARTESIAN)
.export_values();

#if FRI_VERSION_MAJOR == 2
#if FRI_CLIENT_VERSION_MAJOR == 2
py::enum_<KUKA::FRI::ERedundancyStrategy>(m, "ERedundancyStrategy")
.value("E1", KUKA::FRI::ERedundancyStrategy::E1)
.value("NO_STRATEGY", KUKA::FRI::ERedundancyStrategy::NO_STRATEGY)
Expand Down Expand Up @@ -392,7 +392,7 @@ PYBIND11_MODULE(_pyFRI, m) {
.def("getBooleanIOValue", &KUKA::FRI::LBRState::getBooleanIOValue)
.def("getDigitalIOValue", &KUKA::FRI::LBRState::getDigitalIOValue)
.def("getAnalogIOValue", &KUKA::FRI::LBRState::getAnalogIOValue)
#if FRI_VERSION_MAJOR == 1
#if FRI_CLIENT_VERSION_MAJOR == 1
.def("getCommandedJointPosition",
[](const KUKA::FRI::LBRState &self) {
// Declare variables
Expand All @@ -410,7 +410,7 @@ PYBIND11_MODULE(_pyFRI, m) {
return py::array_t<float>({KUKA::FRI::LBRState::NUMBER_OF_JOINTS},
dataf);
})
#elif FRI_VERSION_MAJOR == 2
#elif FRI_CLIENT_VERSION_MAJOR == 2
.def("getMeasuredCartesianPose",
[](const KUKA::FRI::LBRState &self) {

Expand Down
Loading

0 comments on commit d837b98

Please sign in to comment.