Skip to content

Commit c7d17d0

Browse files
Added pre-commit config
1 parent 708c932 commit c7d17d0

File tree

107 files changed

+1639
-1489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1639
-1489
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ AllowAllArgumentsOnNextLine: true
44
BinPackArguments: false
55
AllowAllParametersOfDeclarationOnNextLine: true
66
AlignAfterOpenBracket: AlwaysBreak
7-
ColumnLimit: 120
7+
ColumnLimit: 120

.github/workflows/documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13-
13+
1414
- name: dependencies
1515
env:
1616
dependency_packages: doxygen

.github/workflows/publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: |
4040
# find unique versions
4141
versions=$(
42-
cd artifacts &&
42+
cd artifacts &&
4343
ls -1d wheels___*___* 2>/dev/null \
4444
| sed -E 's/wheels___([^_]+)___.*/\1/' \
4545
| sort -u
@@ -49,12 +49,12 @@ jobs:
4949
echo "No wheel archives found, skipping."
5050
exit 0
5151
fi
52-
52+
5353
for version in $versions; do
5454
out="libfranka_${version//\./-}_wheels.zip"
5555
out_full=$(realpath "output/$out")
5656
echo "Creating $out from all wheels___${version}___*.zip"
57-
57+
5858
tmp=$(mktemp -d)
5959
mkdir "$tmp/dist"
6060
# unpack each matching zip into the temp dir
@@ -65,13 +65,13 @@ jobs:
6565
mv $tmp2/dist/* "$tmp/dist/"
6666
rm -rf "$tmp2"
6767
done
68-
68+
6969
# re-combine into a single zip
7070
(
7171
cd "$tmp"
7272
zip -qr "$out_full" .
7373
)
74-
74+
7575
# clean up
7676
rm -rf "$tmp"
7777
echo "$out done."

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/psf/black
9+
rev: 25.1.0
10+
hooks:
11+
- id: black
12+
- repo: https://github.com/tcort/markdown-link-check
13+
rev: v3.13.6
14+
hooks:
15+
- id: markdown-link-check
16+
args: [-q]
17+
- repo: https://github.com/pre-commit/mirrors-clang-format
18+
rev: v20.1.6
19+
hooks:
20+
- id: clang-format
21+
args: ['--style=file']

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
cmake_minimum_required(VERSION 3.11)
22

33
file(READ "VERSION" version)
4-
project(franky VERSION ${version} LANGUAGES CXX)
4+
string(STRIP "${version}" version)
5+
project(franky VERSION "${version}" LANGUAGES CXX)
56
set(CMAKE_CXX_STANDARD 17)
67
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
78

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@ General Public License ever published by the Free Software Foundation.
162162
whether future versions of the GNU Lesser General Public License shall
163163
apply, that proxy's public statement of acceptance of any version is
164164
permanent authorization for you to choose that version for the
165-
Library.
165+
Library.

README.md

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,25 @@ at [https://timschneider42.github.io/franky/](https://timschneider42.github.io/f
4646

4747
## 🚀 Features
4848

49-
- **Control your Franka robot directly from Python in just a few lines!**
49+
- **Control your Franka robot directly from Python in just a few lines!**
5050
No more endless hours setting up ROS, juggling packages, or untangling dependencies. Just `pip install` — no ROS at all.
5151

52-
- **[Four control modes](#motion-types)**: [Cartesian position](#cartesian-position-control), [Cartesian velocity](#cartesian-velocity-control), [Joint position](#joint-position-control), [Joint velocity](#joint-velocity-control)
52+
- **[Four control modes](#motion-types)**: [Cartesian position](#cartesian-position-control), [Cartesian velocity](#cartesian-velocity-control), [Joint position](#joint-position-control), [Joint velocity](#joint-velocity-control)
5353
Franky uses [Ruckig](https://github.com/pantor/ruckig) to generate smooth, time-optimal trajectories while respecting velocity, acceleration, and jerk limits.
5454

5555
- **[Real-time control from Python and C++](#real-time-motions)**
5656
Need to change the target while the robot’s moving? No problem. Franky re-plans trajectories on the fly so that you can preempt motions anytime.
5757

58-
- **[Reactive behavior](#-real-time-reactions)**
58+
- **[Reactive behavior](#-real-time-reactions)**
5959
Robots don’t always go according to plan. Franky lets you define reactions to unexpected events—like contact with the environment — so you can change course in real-time.
6060

61-
- **[Motion and reaction callbacks](#motion-callbacks)**
61+
- **[Motion and reaction callbacks](#motion-callbacks)**
6262
Want to monitor what’s happening under the hood? Add callbacks to your motions and reactions. They won’t block the control thread and are super handy for debugging or logging.
6363

64-
- **Things are moving too fast? [Tune the robot's dynamics to your needs](#-robot)**
64+
- **Things are moving too fast? [Tune the robot's dynamics to your needs](#-robot)**
6565
Adjust max velocity, acceleration, and jerk to match your setup or task. Fine control for smooth, safe operation.
6666

67-
- **Full Python access to the libfranka API**
67+
- **Full Python access to the libfranka API**
6868
Want to tweak impedance, read the robot state, set force thresholds, or mess with the Jacobian? Go for it. If libfranka supports it, chances are Franky does, too.
6969

7070
## 📖 Python Quickstart Guide
@@ -464,9 +464,9 @@ m_jp3 = JointWaypointMotion([
464464
JointWaypoint([0.1, 0.4, 0.3, -1.4, -0.3, 1.7, 0.9])
465465
])
466466

467-
# Stop the robot in joint position control mode. The difference of JointStopMotion to other stop motions such as
468-
# CartesianStopMotion is that # JointStopMotion # stops the robot in joint position control mode while
469-
# CartesianStopMotion stops it in cartesian pose control mode. The difference becomes relevant when asynchronous move
467+
# Stop the robot in joint position control mode. The difference of JointStopMotion to other stop motions such as
468+
# CartesianStopMotion is that # JointStopMotion # stops the robot in joint position control mode while
469+
# CartesianStopMotion stops it in cartesian pose control mode. The difference becomes relevant when asynchronous move
470470
# commands are being sent or reactions are being used(see below).
471471
m_jp4 = JointStopMotion()
472472
```
@@ -546,7 +546,7 @@ m_cv1 = CartesianVelocityMotion(Twist([0.2, -0.1, 0.1], [0.1, -0.1, 0.2]))
546546
m_cv2 = CartesianVelocityMotion(RobotVelocity(Twist([0.2, -0.1, 0.1], [0.1, -0.1, 0.2]), elbow_velocity=-0.2))
547547

548548
# Cartesian velocity motions also support multiple waypoints. Unlike in cartesian position control, a cartesian velocity
549-
# waypoint is a target velocity to be reached. This particular example first accelerates the end-effector, holds the
549+
# waypoint is a target velocity to be reached. This particular example first accelerates the end-effector, holds the
550550
# velocity for 1s, then # reverses direction for 2s, reverses direction again for 1s, and finally stops. It is important
551551
# not to forget to stop # the robot at the end of such a sequence, as it will otherwise throw an error.
552552
m_cv4 = CartesianVelocityWaypointMotion([
@@ -589,7 +589,7 @@ robot.relative_dynamics_factor = RelativeDynamicsFactor(0.05, 0.1, 0.15)
589589

590590
robot.move(m_jp1)
591591

592-
# We can also set a relative dynamics factor in the move command. It will be multiplied with the other relative
592+
# We can also set a relative dynamics factor in the move command. It will be multiplied with the other relative
593593
# dynamics factors (robot and motion if present).
594594
robot.move(m_jp2, relative_dynamics_factor=0.8)
595595
```
@@ -714,7 +714,7 @@ motion
714714
}),
715715
[](const franka::RobotState& state, double rel_time, double abs_time) {
716716
// Lambda reaction motion generator
717-
// (we are just returning a stop motion, but there could be arbitrary
717+
// (we are just returning a stop motion, but there could be arbitrary
718718
// logic here for generating reaction motions)
719719
return StopMotion<franka::CartesianPose>();
720720
})
@@ -852,19 +852,19 @@ import franky
852852
with franky.RobotWebSession("172.16.0.2", "username", "password") as robot_web_session:
853853
# First take control, in case some other web session is currently running
854854
assert robot_web_session.take_control(), "Control not granted"
855-
855+
856856
# Unlock the brakes
857857
robot_web_session.unlock_brakes()
858-
858+
859859
# Enable the FCI
860860
robot_web_session.enable_fci()
861-
861+
862862
# Create a franky.Robot instance and do whatever you want
863863
...
864-
864+
865865
# Disable the FCI
866866
robot_web_session.disable_fci()
867-
867+
868868
# Lock brakes
869869
robot_web_session.lock_brakes()
870870
```
@@ -882,13 +882,13 @@ with franky.RobotWebSession("172.16.0.2", "username", "password") as robot_web_s
882882
robot_web_session.disable_fci()
883883
robot_web_session.lock_brakes()
884884
time.sleep(1.0)
885-
885+
886886
robot_web_session.execute_self_test()
887-
887+
888888
robot_web_session.unlock_brakes()
889889
robot_web_session.enable_fci()
890890
time.sleep(1.0)
891-
891+
892892
# Recreate your franky.Robot instance as the FCI has been disabled and re-enabled
893893
...
894894
```
@@ -940,3 +940,12 @@ Aside of bug fixes and general performance improvements, Franky provides the fol
940940
* Franky supports [joint velocity control](#joint-velocity-control)
941941
and [cartesian velocity control](#cartesian-velocity-control)
942942
* The dynamics limits are not hard-coded anymore but can be [set for each robot instance](#-robot).
943+
944+
## Contributing
945+
946+
If you wish to contribute to this project, you are welcome to create a pull request.
947+
Please run the [pre-commit](https://pre-commit.com/) hooks before submitting your pull request.
948+
To install the pre-commit hooks, run:
949+
950+
1. [Install pre-commit](https://pre-commit.com/#install)
951+
2. Install the Git hooks by running `pre-commit install` or, alternatively, run `pre-commit run --all-files manually.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.2
1+
1.0.2

custom_stubgen.py

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,65 @@
44
from typing import Dict, Optional, Iterable
55
from collections import defaultdict
66

7-
from pybind11_stubgen import Writer, QualifiedName, Printer, arg_parser, stub_parser_from_args, to_output_and_subdir, \
8-
run
7+
from pybind11_stubgen import (
8+
Writer,
9+
QualifiedName,
10+
Printer,
11+
arg_parser,
12+
stub_parser_from_args,
13+
to_output_and_subdir,
14+
run,
15+
)
916
from pybind11_stubgen.structs import Function, ResolvedType, Module
1017

1118

1219
class CustomWriter(Writer):
13-
def __init__(self, alternative_types: Dict[str, Iterable[str]], stub_ext: str = "pyi"):
20+
def __init__(
21+
self, alternative_types: Dict[str, Iterable[str]], stub_ext: str = "pyi"
22+
):
1423
super().__init__(stub_ext=stub_ext)
1524
self.alternative_types = {
16-
QualifiedName.from_str(k): tuple(QualifiedName.from_str(e) for e in v) for k, v in alternative_types.items()
25+
QualifiedName.from_str(k): tuple(QualifiedName.from_str(e) for e in v)
26+
for k, v in alternative_types.items()
1727
}
1828

1929
def _patch_function(self, function: Function):
2030
for argument in function.args:
21-
if argument.annotation is not None and argument.annotation.name in self.alternative_types:
22-
converted_types = [ResolvedType(e) for e in self.alternative_types[argument.annotation.name]]
31+
if (
32+
argument.annotation is not None
33+
and argument.annotation.name in self.alternative_types
34+
):
35+
converted_types = [
36+
ResolvedType(e)
37+
for e in self.alternative_types[argument.annotation.name]
38+
]
2339
argument.annotation = ResolvedType(
24-
QualifiedName.from_str("typing.Union"), [argument.annotation] + converted_types)
40+
QualifiedName.from_str("typing.Union"),
41+
[argument.annotation] + converted_types,
42+
)
2543

26-
def write_module(self, module: Module, printer: Printer, to: Path, sub_dir: Optional[Path] = None):
44+
def write_module(
45+
self, module: Module, printer: Printer, to: Path, sub_dir: Optional[Path] = None
46+
):
2747
for cls in module.classes:
2848
for method in cls.methods:
2949
self._patch_function(method.function)
3050
for prop in cls.properties:
3151
if prop.setter is not None:
3252
self._patch_function(prop.setter)
3353
for field in cls.fields:
34-
if field.attribute.annotation is not None and field.attribute.annotation.name in self.alternative_types:
35-
converted_types = [ResolvedType(e) for e in self.alternative_types[field.attribute.annotation.name]]
54+
if (
55+
field.attribute.annotation is not None
56+
and field.attribute.annotation.name in self.alternative_types
57+
):
58+
converted_types = [
59+
ResolvedType(e)
60+
for e in self.alternative_types[field.attribute.annotation.name]
61+
]
3662
field.attribute.annotation = ResolvedType(
37-
QualifiedName.from_str("typing.Union"), [field.attribute.annotation] + converted_types)
63+
QualifiedName.from_str("typing.Union"),
64+
[field.attribute.annotation] + converted_types,
65+
)
3866
super().write_module(module, printer, to, sub_dir=sub_dir)
3967

4068

@@ -46,7 +74,7 @@ def write_module(self, module: Module, printer: Printer, to: Path, sub_dir: Opti
4674
("RobotPose", "CartesianState"),
4775
("Affine", "CartesianState"),
4876
("list[float]", "JointState"),
49-
("np.ndarray", "JointState")
77+
("np.ndarray", "JointState"),
5078
]
5179

5280
alternatives = defaultdict(list)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
google-site-verification: google934cbd3b5469daff.html
1+
google-site-verification: google934cbd3b5469daff.html

0 commit comments

Comments
 (0)