franky-control 1.0.1__cp312-cp312-manylinux_2_34_x86_64.whl → 1.1.0__cp312-cp312-manylinux_2_34_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. franky/__init__.py +7 -2
  2. franky/_franky.cpython-312-x86_64-linux-gnu.so +0 -0
  3. franky/_franky.pyi +1 -1
  4. franky/motion.py +8 -3
  5. franky/reaction.py +19 -8
  6. franky/robot_web_session.py +140 -51
  7. {franky_control-1.0.1.dist-info → franky_control-1.1.0.dist-info}/METADATA +129 -18
  8. franky_control-1.1.0.dist-info/RECORD +26 -0
  9. {franky_control-1.0.1.dist-info → franky_control-1.1.0.dist-info}/WHEEL +1 -1
  10. {franky_control-1.0.1.dist-info → franky_control-1.1.0.dist-info}/licenses/LICENSE +1 -1
  11. franky_control.libs/libPocoFoundation-13a5b20e.so.95 +0 -0
  12. franky_control.libs/libPocoNet-8bb0f68b.so.95 +0 -0
  13. franky_control.libs/libboost_filesystem-0bf67256.so.1.75.0 +0 -0
  14. franky_control.libs/libboost_serialization-67da18f6.so.1.75.0 +0 -0
  15. franky_control.libs/libfranka-e5e9247f.so.0.15.0 +0 -0
  16. franky_control.libs/libpinocchio_default-5f84cd5d.so.3.1.0 +0 -0
  17. franky_control.libs/libpinocchio_parsers-a0b97441.so.3.1.0 +0 -0
  18. franky_control-1.0.1.dist-info/RECORD +0 -28
  19. franky_control.libs/libPocoFoundationd-74964157.so.92 +0 -0
  20. franky_control.libs/libPocoNetd-5dd54f10.so.92 +0 -0
  21. franky_control.libs/libboost_atomic-64eba867.so.1.78.0 +0 -0
  22. franky_control.libs/libboost_filesystem-63963750.so.1.78.0 +0 -0
  23. franky_control.libs/libboost_serialization-75ebc722.so.1.78.0 +0 -0
  24. franky_control.libs/libfranka-fb54b5c1.so.0.15.0 +0 -0
  25. franky_control.libs/libpcre2-8-b77f698a.so.0.11.0 +0 -0
  26. franky_control.libs/libpinocchio_default-14a4da3b.so.3.4.0 +0 -0
  27. franky_control.libs/libpinocchio_parsers-9083fe76.so.3.4.0 +0 -0
  28. {franky_control-1.0.1.dist-info → franky_control-1.1.0.dist-info}/top_level.txt +0 -0
franky/__init__.py CHANGED
@@ -1,12 +1,17 @@
1
1
  from .robot import Robot
2
- from .robot_web_session import RobotWebSession
2
+ from .robot_web_session import (
3
+ RobotWebSession,
4
+ RobotWebSessionError,
5
+ FrankaAPIError,
6
+ TakeControlTimeoutError,
7
+ )
3
8
  from .reaction import (
4
9
  Reaction,
5
10
  TorqueReaction,
6
11
  JointVelocityReaction,
7
12
  JointPositionReaction,
8
13
  CartesianVelocityReaction,
9
- CartesianPoseReaction
14
+ CartesianPoseReaction,
10
15
  )
11
16
  from .motion import Motion
12
17
  from ._franky import *
franky/_franky.pyi CHANGED
@@ -1585,7 +1585,7 @@ class VectorDynamicsLimit:
1585
1585
  class _RobotInternal:
1586
1586
  control_rate: typing.ClassVar[float] = 0.001
1587
1587
  degrees_of_freedom: typing.ClassVar[int] = 7
1588
- relative_dynamics_factor: RelativeDynamicsFactor
1588
+ relative_dynamics_factor: RelativeDynamicsFactor | float
1589
1589
  @staticmethod
1590
1590
  def _pybind11_conduit_v1_(*args, **kwargs):
1591
1591
  ...
franky/motion.py CHANGED
@@ -1,12 +1,17 @@
1
1
  from typing import Union
2
2
 
3
- from ._franky import BaseCartesianPoseMotion, BaseCartesianVelocityMotion, BaseJointPositionMotion, \
4
- BaseJointVelocityMotion, BaseTorqueMotion
3
+ from ._franky import (
4
+ BaseCartesianPoseMotion,
5
+ BaseCartesianVelocityMotion,
6
+ BaseJointPositionMotion,
7
+ BaseJointVelocityMotion,
8
+ BaseTorqueMotion,
9
+ )
5
10
 
6
11
  Motion = Union[
7
12
  BaseCartesianPoseMotion,
8
13
  BaseCartesianVelocityMotion,
9
14
  BaseJointPositionMotion,
10
15
  BaseJointVelocityMotion,
11
- BaseTorqueMotion
16
+ BaseTorqueMotion,
12
17
  ]
franky/reaction.py CHANGED
@@ -1,10 +1,16 @@
1
- from ._franky import Condition, BaseCartesianPoseMotion, BaseCartesianVelocityMotion, BaseJointPositionMotion, \
2
- BaseJointVelocityMotion, BaseTorqueMotion, \
3
- CartesianPoseReaction as _CartesianPoseReaction, \
4
- CartesianVelocityReaction as _CartesianVelocityReaction, \
5
- JointPositionReaction as _JointPositionReaction, \
6
- JointVelocityReaction as _JointVelocityReaction, \
7
- TorqueReaction as _TorqueReaction
1
+ from ._franky import (
2
+ Condition,
3
+ BaseCartesianPoseMotion,
4
+ BaseCartesianVelocityMotion,
5
+ BaseJointPositionMotion,
6
+ BaseJointVelocityMotion,
7
+ BaseTorqueMotion,
8
+ CartesianPoseReaction as _CartesianPoseReaction,
9
+ CartesianVelocityReaction as _CartesianVelocityReaction,
10
+ JointPositionReaction as _JointPositionReaction,
11
+ JointVelocityReaction as _JointVelocityReaction,
12
+ TorqueReaction as _TorqueReaction,
13
+ )
8
14
 
9
15
  from .motion import Motion
10
16
 
@@ -40,4 +46,9 @@ class TorqueReaction(_TorqueReaction, Reaction):
40
46
 
41
47
 
42
48
  _REACTION_TYPES = [
43
- CartesianPoseReaction, CartesianVelocityReaction, JointPositionReaction, JointVelocityReaction, TorqueReaction]
49
+ CartesianPoseReaction,
50
+ CartesianVelocityReaction,
51
+ JointPositionReaction,
52
+ JointVelocityReaction,
53
+ TorqueReaction,
54
+ ]
@@ -7,22 +7,37 @@ import time
7
7
  import urllib.parse
8
8
  from http.client import HTTPSConnection, HTTPResponse
9
9
  from typing import Dict, Optional, Any, Literal
10
- from urllib.error import HTTPError
11
10
 
12
11
 
13
- class FrankaAPIError(Exception):
14
- def __init__(self, target: str, http_code: int, http_reason: str, headers: Dict[str, str], message: str):
12
+ class RobotWebSessionError(Exception):
13
+ pass
14
+
15
+
16
+ class FrankaAPIError(RobotWebSessionError):
17
+ def __init__(
18
+ self,
19
+ target: str,
20
+ http_code: int,
21
+ http_reason: str,
22
+ headers: Dict[str, str],
23
+ message: str,
24
+ ):
15
25
  super().__init__(
16
- f"Franka API returned error {http_code} ({http_reason}) when accessing end-point {target}: {message}")
26
+ f"Franka API returned error {http_code} ({http_reason}) when accessing end-point {target}: {message}"
27
+ )
17
28
  self.target = target
18
29
  self.http_code = http_code
19
30
  self.headers = headers
20
31
  self.message = message
21
32
 
22
33
 
34
+ class TakeControlTimeoutError(RobotWebSessionError):
35
+ pass
36
+
37
+
23
38
  class RobotWebSession:
24
- def __init__(self, fci_hostname: str, username: str, password: str):
25
- self.__fci_hostname = fci_hostname
39
+ def __init__(self, hostname: str, username: str, password: str):
40
+ self.__hostname = hostname
26
41
  self.__username = username
27
42
  self.__password = password
28
43
 
@@ -33,24 +48,45 @@ class RobotWebSession:
33
48
 
34
49
  @staticmethod
35
50
  def __encode_password(user: str, password: str) -> str:
36
- bs = ",".join([str(b) for b in hashlib.sha256((password + "#" + user + "@franka").encode("utf-8")).digest()])
51
+ bs = ",".join(
52
+ [
53
+ str(b)
54
+ for b in hashlib.sha256(
55
+ (password + "#" + user + "@franka").encode("utf-8")
56
+ ).digest()
57
+ ]
58
+ )
37
59
  return base64.encodebytes(bs.encode("utf-8")).decode("utf-8")
38
60
 
39
- def _send_api_request(self, target: str, headers: Optional[Dict[str, str]] = None, body: Optional[Any] = None,
40
- method: Literal["GET", "POST", "DELETE"] = "POST"):
41
- _headers = {
42
- "Cookie": f"authorization={self.__token}"
43
- }
61
+ def _send_api_request(
62
+ self,
63
+ target: str,
64
+ headers: Optional[Dict[str, str]] = None,
65
+ body: Optional[Any] = None,
66
+ method: Literal["GET", "POST", "DELETE"] = "POST",
67
+ ):
68
+ _headers = {"Cookie": f"authorization={self.__token}"}
44
69
  if headers is not None:
45
70
  _headers.update(headers)
46
71
  self.__client.request(method, target, headers=_headers, body=body)
47
72
  res: HTTPResponse = self.__client.getresponse()
48
73
  if res.getcode() != 200:
49
- raise FrankaAPIError(target, res.getcode(), res.reason, dict(res.headers), res.read().decode("utf-8"))
74
+ raise FrankaAPIError(
75
+ target,
76
+ res.getcode(),
77
+ res.reason,
78
+ dict(res.headers),
79
+ res.read().decode("utf-8"),
80
+ )
50
81
  return res.read()
51
82
 
52
- def send_api_request(self, target: str, headers: Optional[Dict[str, str]] = None, body: Optional[Any] = None,
53
- method: Literal["GET", "POST", "DELETE"] = "POST"):
83
+ def send_api_request(
84
+ self,
85
+ target: str,
86
+ headers: Optional[Dict[str, str]] = None,
87
+ body: Optional[Any] = None,
88
+ method: Literal["GET", "POST", "DELETE"] = "POST",
89
+ ):
54
90
  last_error = None
55
91
  for i in range(3):
56
92
  try:
@@ -59,28 +95,38 @@ class RobotWebSession:
59
95
  last_error = ex
60
96
  raise last_error
61
97
 
62
- def send_control_api_request(self, target: str, headers: Optional[Dict[str, str]] = None,
63
- body: Optional[Any] = None,
64
- method: Literal["GET", "POST", "DELETE"] = "POST"):
98
+ def send_control_api_request(
99
+ self,
100
+ target: str,
101
+ headers: Optional[Dict[str, str]] = None,
102
+ body: Optional[Any] = None,
103
+ method: Literal["GET", "POST", "DELETE"] = "POST",
104
+ ):
65
105
  if headers is None:
66
106
  headers = {}
67
107
  self.__check_control_token()
68
- _headers = {
69
- "X-Control-Token": self.__control_token
70
- }
108
+ _headers = {"X-Control-Token": self.__control_token}
71
109
  _headers.update(headers)
72
110
  return self.send_api_request(target, headers=_headers, method=method, body=body)
73
111
 
74
- def open(self):
112
+ def open(self, timeout: float = 30.0):
75
113
  if self.is_open:
76
114
  raise RuntimeError("Session is already open.")
77
- self.__client = HTTPSConnection(self.__fci_hostname, timeout=12, context=ssl._create_unverified_context())
115
+ self.__client = HTTPSConnection(
116
+ self.__hostname, timeout=timeout, context=ssl._create_unverified_context()
117
+ )
78
118
  self.__client.connect()
79
119
  payload = json.dumps(
80
- {"login": self.__username, "password": self.__encode_password(self.__username, self.__password)})
120
+ {
121
+ "login": self.__username,
122
+ "password": self.__encode_password(self.__username, self.__password),
123
+ }
124
+ )
81
125
  self.__token = self.send_api_request(
82
- "/admin/api/login", headers={"content-type": "application/json"},
83
- body=payload).decode("utf-8")
126
+ "/admin/api/login",
127
+ headers={"content-type": "application/json"},
128
+ body=payload,
129
+ ).decode("utf-8")
84
130
  return self
85
131
 
86
132
  def close(self):
@@ -92,82 +138,125 @@ class RobotWebSession:
92
138
  self.__client.close()
93
139
 
94
140
  def __enter__(self):
95
- self.open()
141
+ return self.open()
96
142
 
97
143
  def __exit__(self, type, value, traceback):
98
144
  self.close()
99
145
 
100
146
  def __check_control_token(self):
101
147
  if self.__control_token is None:
102
- raise RuntimeError("Client does not have control. Call take_control() first.")
148
+ raise RuntimeError(
149
+ "Client does not have control. Call take_control() first."
150
+ )
103
151
 
104
- def take_control(self, wait_timeout: float = 10.0):
105
- if self.__control_token is None:
152
+ def take_control(self, wait_timeout: float = 30.0, force: bool = False):
153
+ if not self.has_control():
106
154
  res = self.send_api_request(
107
- "/admin/api/control-token/request", headers={"content-type": "application/json"},
108
- body=json.dumps({"requestedBy": self.__username}))
155
+ f"/admin/api/control-token/request{'?force' if force else ''}",
156
+ headers={"content-type": "application/json"},
157
+ body=json.dumps({"requestedBy": self.__username}),
158
+ )
159
+ if force:
160
+ print(
161
+ "Forcibly taking control: "
162
+ f"Please physically take control by pressing the top button on the FR3 within {wait_timeout}s!"
163
+ )
109
164
  response_dict = json.loads(res)
110
165
  self.__control_token = response_dict["token"]
111
166
  self.__control_token_id = response_dict["id"]
112
167
  # One should probably use websockets here but that would introduce another dependency
113
168
  start = time.time()
114
- while time.time() - start < wait_timeout and not self.has_control():
115
- time.sleep(1.0)
116
- return self.has_control()
169
+ has_control = self.has_control()
170
+ while time.time() - start < wait_timeout and not has_control:
171
+ time.sleep(max(0.0, min(1.0, wait_timeout - (time.time() - start))))
172
+ has_control = self.has_control()
173
+ if not has_control:
174
+ raise TakeControlTimeoutError(
175
+ f"Timed out waiting for control to be granted after {wait_timeout}s."
176
+ )
117
177
 
118
178
  def release_control(self):
119
179
  if self.__control_token is not None:
120
180
  self.send_control_api_request(
121
- "/admin/api/control-token", headers={"content-type": "application/json"}, method="DELETE",
122
- body=json.dumps({"token": self.__control_token}))
181
+ "/admin/api/control-token",
182
+ headers={"content-type": "application/json"},
183
+ method="DELETE",
184
+ body=json.dumps({"token": self.__control_token}),
185
+ )
123
186
  self.__control_token = None
124
187
  self.__control_token_id = None
125
188
 
126
189
  def enable_fci(self):
127
190
  self.send_control_api_request(
128
- "/desk/api/system/fci", headers={"content-type": "application/x-www-form-urlencoded"},
129
- body=f"token={urllib.parse.quote(base64.b64encode(self.__control_token.encode('ascii')))}")
191
+ "/desk/api/system/fci",
192
+ headers={"content-type": "application/x-www-form-urlencoded"},
193
+ body=f"token={urllib.parse.quote(base64.b64encode(self.__control_token.encode('ascii')))}",
194
+ )
130
195
 
131
196
  def has_control(self):
132
197
  if self.__control_token_id is not None:
133
198
  status = self.get_system_status()
134
199
  active_token = status["controlToken"]["activeToken"]
135
- return active_token is not None and active_token["id"] == self.__control_token_id
200
+ return (
201
+ active_token is not None
202
+ and active_token["id"] == self.__control_token_id
203
+ )
136
204
  return False
137
205
 
138
206
  def start_task(self, task: str):
139
207
  self.send_api_request(
140
- "/desk/api/execution", headers={"content-type": "application/x-www-form-urlencoded"},
141
- body=f"id={task}")
208
+ "/desk/api/execution",
209
+ headers={"content-type": "application/x-www-form-urlencoded"},
210
+ body=f"id={task}",
211
+ )
142
212
 
143
213
  def unlock_brakes(self):
144
214
  self.send_control_api_request(
145
- "/desk/api/joints/unlock", headers={"content-type": "application/x-www-form-urlencoded"})
215
+ "/desk/api/joints/unlock",
216
+ headers={"content-type": "application/x-www-form-urlencoded"},
217
+ )
146
218
 
147
219
  def lock_brakes(self):
148
220
  self.send_control_api_request(
149
- "/desk/api/joints/lock", headers={"content-type": "application/x-www-form-urlencoded"})
221
+ "/desk/api/joints/lock",
222
+ headers={"content-type": "application/x-www-form-urlencoded"},
223
+ )
150
224
 
151
225
  def set_mode_programming(self):
152
226
  self.send_control_api_request(
153
- "/desk/api/operating-mode/programming", headers={"content-type": "application/x-www-form-urlencoded"})
227
+ "/desk/api/operating-mode/programming",
228
+ headers={"content-type": "application/x-www-form-urlencoded"},
229
+ )
154
230
 
155
231
  def set_mode_execution(self):
156
232
  self.send_control_api_request(
157
- "/desk/api/operating-mode/execution", headers={"content-type": "application/x-www-form-urlencoded"})
233
+ "/desk/api/operating-mode/execution",
234
+ headers={"content-type": "application/x-www-form-urlencoded"},
235
+ )
158
236
 
159
237
  def get_system_status(self):
160
- return json.loads(self.send_api_request("/admin/api/system-status", method="GET").decode("utf-8"))
238
+ return json.loads(
239
+ self.send_api_request("/admin/api/system-status", method="GET").decode(
240
+ "utf-8"
241
+ )
242
+ )
161
243
 
162
244
  def execute_self_test(self):
163
245
  if self.get_system_status()["safety"]["recoverableErrors"]["td2Timeout"]:
164
246
  self.send_control_api_request(
165
- "/admin/api/safety/recoverable-safety-errors/acknowledge?error_id=TD2Timeout")
166
- response = json.loads(self.send_control_api_request(
167
- "/admin/api/safety/td2-tests/execute", headers={"content-type": "application/json"}).decode("utf-8"))
247
+ "/admin/api/safety/recoverable-safety-errors/acknowledge?error_id=TD2Timeout"
248
+ )
249
+ response = json.loads(
250
+ self.send_control_api_request(
251
+ "/admin/api/safety/td2-tests/execute",
252
+ headers={"content-type": "application/json"},
253
+ ).decode("utf-8")
254
+ )
168
255
  assert response["code"] == "SuccessResponse"
169
256
  time.sleep(0.5)
170
- while self.get_system_status()["safety"]["safetyControllerStatus"] == "SelfTest":
257
+ while (
258
+ self.get_system_status()["safety"]["safetyControllerStatus"] == "SelfTest"
259
+ ):
171
260
  time.sleep(0.5)
172
261
 
173
262
  @property
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: franky-control
3
- Version: 1.0.1
3
+ Version: 1.1.0
4
4
  Summary: High-level control library for Franka robots.
5
5
  Home-page: https://github.com/TimSchneider42/franky
6
6
  Author: Tim Schneider
@@ -76,25 +76,25 @@ at [https://timschneider42.github.io/franky/](https://timschneider42.github.io/f
76
76
 
77
77
  ## 🚀 Features
78
78
 
79
- - **Control your Franka robot directly from Python in just a few lines!**
79
+ - **Control your Franka robot directly from Python in just a few lines!**
80
80
  No more endless hours setting up ROS, juggling packages, or untangling dependencies. Just `pip install` — no ROS at all.
81
81
 
82
- - **[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)
82
+ - **[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)
83
83
  Franky uses [Ruckig](https://github.com/pantor/ruckig) to generate smooth, time-optimal trajectories while respecting velocity, acceleration, and jerk limits.
84
84
 
85
85
  - **[Real-time control from Python and C++](#real-time-motions)**
86
86
  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.
87
87
 
88
- - **[Reactive behavior](#-real-time-reactions)**
88
+ - **[Reactive behavior](#-real-time-reactions)**
89
89
  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.
90
90
 
91
- - **[Motion and reaction callbacks](#motion-callbacks)**
91
+ - **[Motion and reaction callbacks](#motion-callbacks)**
92
92
  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.
93
93
 
94
- - **Things are moving too fast? [Tune the robot's dynamics to your needs](#-robot)**
94
+ - **Things are moving too fast? [Tune the robot's dynamics to your needs](#-robot)**
95
95
  Adjust max velocity, acceleration, and jerk to match your setup or task. Fine control for smooth, safe operation.
96
96
 
97
- - **Full Python access to the libfranka API**
97
+ - **Full Python access to the libfranka API**
98
98
  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.
99
99
 
100
100
  ## 📖 Python Quickstart Guide
@@ -244,7 +244,7 @@ To use Franky within Docker we provide a [Dockerfile](docker/run/Dockerfile) and
244
244
  accompanying [docker-compose](docker-compose.yml) file.
245
245
 
246
246
  ```bash
247
- git clone https://github.com/timschneider42/franky.git
247
+ git clone --recurse-submodules https://github.com/timschneider42/franky.git
248
248
  cd franky/
249
249
  docker compose build franky-run
250
250
  ```
@@ -274,6 +274,32 @@ docker compose run --rm franky-build run-tests # To run the tests
274
274
  docker compose run --rm franky-build build-wheels # To build wheels for all supported python versions
275
275
  ```
276
276
 
277
+ ### Can I use CUDA jointly with Franky?
278
+
279
+ Yes. However, you need to set `IGNORE_PREEMPT_RT_PRESENCE=1` during the installation and all subsequent updates of the CUDA drivers on the real-time kernel.
280
+
281
+ First, make sure that you have rebooted your system after installing the real-time kernel.
282
+ Then, add `IGNORE_PREEMPT_RT_PRESENCE=1` to `/etc/environment`, call `export IGNORE_PREEMPT_RT_PRESENCE=1` to also set it in the current session and follow the instructions of Nvidia to install CUDA on your system.
283
+
284
+ If you are on Ubuntu, you can also use [this](tools/install_cuda_realtime.bash) script to install CUDA on your real-time system:
285
+ ```bash
286
+ # Download the script
287
+ wget https://raw.githubusercontent.com/timschneider42/franky/master/tools/install_cuda_realtime.bash
288
+
289
+ # Inspect the script to ensure it does what you expect
290
+
291
+ # Make it executable
292
+ chmod +x install_cuda_realtime.bash
293
+
294
+ # Execute the script
295
+ ./install_cuda_realtime.bash
296
+ ```
297
+
298
+ Alternatively, if you are a cowboy and do not care about security, you can also use this one-liner to directly call the script without checking it:
299
+ ```bash
300
+ bash <(wget -qO- https://raw.githubusercontent.com/timschneider42/franky/master/tools/install_cuda_realtime.bash)
301
+ ```
302
+
277
303
  ## 📚 Tutorial
278
304
 
279
305
  Franky comes with both a C++ and Python API that differ only regarding real-time capability.
@@ -311,6 +337,8 @@ motion = CartesianMotion(Affine([0.2, 0.0, 0.0]), ReferenceType.Relative)
311
337
  robot.move(motion)
312
338
  ```
313
339
 
340
+ Before executing any code, make sure that you have enabled the Franka Control Interface (FCI) in the Franka UI web interface.
341
+
314
342
  Furthermore, we will introduce methods for geometric calculations, for moving the robot according to different motion
315
343
  types, how to implement real-time reactions and changing waypoints in real time as well as controlling the gripper.
316
344
 
@@ -384,7 +412,7 @@ The robot state can be retrieved by accessing the following properties:
384
412
  obtained
385
413
  from [franka::RobotState::O_T_EE](https://frankaemika.github.io/libfranka/structfranka_1_1RobotState.html#a193781d47722b32925e0ea7ac415f442)
386
414
  and [franka::RobotState::O_dP_EE_c](https://frankaemika.github.io/libfranka/structfranka_1_1RobotState.html#a4be112bd1a9a7d777a67aea4a18a8dcc).
387
- * `current_joint_position`: Object of type `franky.JointState`, which contains the joint positions and velocities
415
+ * `current_joint_state`: Object of type `franky.JointState`, which contains the joint positions and velocities
388
416
  obtained
389
417
  from [franka::RobotState::q](https://frankaemika.github.io/libfranka/structfranka_1_1RobotState.html#ade3335d1ac2f6c44741a916d565f7091)
390
418
  and [franka::RobotState::dq](https://frankaemika.github.io/libfranka/structfranka_1_1RobotState.html#a706045af1b176049e9e56df755325bd2).
@@ -430,8 +458,7 @@ and [Model](https://timschneider42.github.io/franky/classfranky_1_1_model.html)
430
458
 
431
459
  ### <a id="motion-types" /> 🏃‍♂️ Motion Types
432
460
 
433
- Franky currently supports four different impedance control modes: **joint position control**, **joint velocity control
434
- **, **cartesian position control**, and **cartesian velocity control**.
461
+ Franky currently supports four different impedance control modes: **joint position control**, **joint velocity control**, **cartesian position control**, and **cartesian velocity control**.
435
462
  Each of these control modes is invoked by passing the robot an appropriate _Motion_ object.
436
463
 
437
464
  In the following, we provide a brief example for each motion type implemented by Franky in Python.
@@ -467,9 +494,9 @@ m_jp3 = JointWaypointMotion([
467
494
  JointWaypoint([0.1, 0.4, 0.3, -1.4, -0.3, 1.7, 0.9])
468
495
  ])
469
496
 
470
- # Stop the robot in joint position control mode. The difference of JointStopMotion to other stop motions such as
471
- # CartesianStopMotion is that # JointStopMotion # stops the robot in joint position control mode while
472
- # CartesianStopMotion stops it in cartesian pose control mode. The difference becomes relevant when asynchronous move
497
+ # Stop the robot in joint position control mode. The difference of JointStopMotion to other stop motions such as
498
+ # CartesianStopMotion is that # JointStopMotion # stops the robot in joint position control mode while
499
+ # CartesianStopMotion stops it in cartesian pose control mode. The difference becomes relevant when asynchronous move
473
500
  # commands are being sent or reactions are being used(see below).
474
501
  m_jp4 = JointStopMotion()
475
502
  ```
@@ -549,7 +576,7 @@ m_cv1 = CartesianVelocityMotion(Twist([0.2, -0.1, 0.1], [0.1, -0.1, 0.2]))
549
576
  m_cv2 = CartesianVelocityMotion(RobotVelocity(Twist([0.2, -0.1, 0.1], [0.1, -0.1, 0.2]), elbow_velocity=-0.2))
550
577
 
551
578
  # Cartesian velocity motions also support multiple waypoints. Unlike in cartesian position control, a cartesian velocity
552
- # waypoint is a target velocity to be reached. This particular example first accelerates the end-effector, holds the
579
+ # waypoint is a target velocity to be reached. This particular example first accelerates the end-effector, holds the
553
580
  # velocity for 1s, then # reverses direction for 2s, reverses direction again for 1s, and finally stops. It is important
554
581
  # not to forget to stop # the robot at the end of such a sequence, as it will otherwise throw an error.
555
582
  m_cv4 = CartesianVelocityWaypointMotion([
@@ -592,7 +619,7 @@ robot.relative_dynamics_factor = RelativeDynamicsFactor(0.05, 0.1, 0.15)
592
619
 
593
620
  robot.move(m_jp1)
594
621
 
595
- # We can also set a relative dynamics factor in the move command. It will be multiplied with the other relative
622
+ # We can also set a relative dynamics factor in the move command. It will be multiplied with the other relative
596
623
  # dynamics factors (robot and motion if present).
597
624
  robot.move(m_jp2, relative_dynamics_factor=0.8)
598
625
  ```
@@ -717,7 +744,7 @@ motion
717
744
  }),
718
745
  [](const franka::RobotState& state, double rel_time, double abs_time) {
719
746
  // Lambda reaction motion generator
720
- // (we are just returning a stop motion, but there could be arbitrary
747
+ // (we are just returning a stop motion, but there could be arbitrary
721
748
  // logic here for generating reaction motions)
722
749
  return StopMotion<franka::CartesianPose>();
723
750
  })
@@ -762,7 +789,7 @@ The next time `Robot.join_motion` or `Robot.move` are called, they will throw th
762
789
  Hence, after an asynchronous motion has finished, make sure to call `Robot.join_motion` to ensure being notified of any
763
790
  exceptions that occurred during the motion.
764
791
 
765
- ### Gripper
792
+ ### <a id="gripper" /> 👌 Gripper
766
793
 
767
794
  In the `franky::Gripper` class, the default gripper force and gripper speed can be set.
768
795
  Then, additionally to the libfranka commands, the following helper methods can be used:
@@ -837,6 +864,80 @@ else:
837
864
  print("Gripper motion timed out.")
838
865
  ```
839
866
 
867
+ ### Accessing the Web Interface API
868
+
869
+ For Franka robots, control happens via the Franka Control Interface (FCI), which has to be enabled through the Franka UI in the robot's web interface.
870
+ The Franka UI also provides methods for locking and unlocking the brakes, setting the execution mode, and executing the safety self-test.
871
+ However, sometimes you may want to access these methods programmatically, e.g. for automatically unlocking the brakes before starting a motion, or automatically executing the self-test after 24h of continuous execution.
872
+
873
+ For that reason, Franky provides a `RobotWebSession` class that allows you to access the web interface API of the robot.
874
+ Note that directly accessing the web interface API is not officially supported and documented by Franka.
875
+ Hence, use this feature at your own risk.
876
+
877
+ A typical automated workflow could look like this:
878
+
879
+ ```python
880
+ import franky
881
+
882
+ with franky.RobotWebSession("172.16.0.2", "username", "password") as robot_web_session:
883
+ # First take control
884
+ try:
885
+ # Try taking control. The session currently holding control has to release it in order for this session to gain
886
+ # control. In the web interface, a notification will show prompting the user to release control. If the other
887
+ # session is another franky.RobotWebSession, then the `release_control` method can be called on the other
888
+ # session to release control.
889
+ robot_web_session.take_control(wait_timeout=10.0)
890
+ except franky.TakeControlTimeoutError:
891
+ # If nothing happens for 10s, we try to take control forcefully. This is particularly useful if the session
892
+ # holding control is dead. Taking control by force requires the user to manually push the blue button close to
893
+ # the robot's wrist.
894
+ robot_web_session.take_control(wait_timeout=30.0, force=True)
895
+
896
+ # Unlock the brakes
897
+ robot_web_session.unlock_brakes()
898
+
899
+ # Enable the FCI
900
+ robot_web_session.enable_fci()
901
+
902
+ # Create a franky.Robot instance and do whatever you want
903
+ ...
904
+
905
+ # Disable the FCI
906
+ robot_web_session.disable_fci()
907
+
908
+ # Lock brakes
909
+ robot_web_session.lock_brakes()
910
+ ```
911
+
912
+ In case you are running the robot for longer than 24h you will have noticed that you have to do a safety self-test every 24h.
913
+ `RobotWebSession` allows to automate this task as well:
914
+
915
+ ```python
916
+ import time
917
+ import franky
918
+
919
+ with franky.RobotWebSession("172.16.0.2", "username", "password") as robot_web_session:
920
+ # Execute self-test if the time until self-test is less than 5 minutes.
921
+ if robot_web_session.get_system_status()["safety"]["timeToTd2"] < 300:
922
+ robot_web_session.disable_fci()
923
+ robot_web_session.lock_brakes()
924
+ time.sleep(1.0)
925
+
926
+ robot_web_session.execute_self_test()
927
+
928
+ robot_web_session.unlock_brakes()
929
+ robot_web_session.enable_fci()
930
+ time.sleep(1.0)
931
+
932
+ # Recreate your franky.Robot instance as the FCI has been disabled and re-enabled
933
+ ...
934
+ ```
935
+
936
+ `robot_web_session.get_system_status()` contains more information than just the time until self-test, such as the current execution mode, whether the brakes are locked, whether the FCI is enabled, and more.
937
+
938
+ If you want to call other API functions, you can use the `RobotWebSession.send_api_request` and `RobotWebSession.send_control_api_request` methods.
939
+ See [robot_web_session.py](franky/robot_web_session.py) for an example of how to use these methods.
940
+
840
941
  ## 🛠️ Development
841
942
 
842
943
  Franky is currently tested against following versions
@@ -844,6 +945,7 @@ Franky is currently tested against following versions
844
945
  - libfranka 0.7.1, 0.8.0, 0.9.2, 0.10.0, 0.11.0, 0.12.1, 0.13.3, 0.14.2, 0.15.0
845
946
  - Eigen 3.4.0
846
947
  - Pybind11 2.13.6
948
+ - POCO 1.12.5p2
847
949
  - Pinocchio 3.4.0
848
950
  - Python 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
849
951
  - Catch2 2.13.8 (for testing only)
@@ -878,3 +980,12 @@ Aside of bug fixes and general performance improvements, Franky provides the fol
878
980
  * Franky supports [joint velocity control](#joint-velocity-control)
879
981
  and [cartesian velocity control](#cartesian-velocity-control)
880
982
  * The dynamics limits are not hard-coded anymore but can be [set for each robot instance](#-robot).
983
+
984
+ ## Contributing
985
+
986
+ If you wish to contribute to this project, you are welcome to create a pull request.
987
+ Please run the [pre-commit](https://pre-commit.com/) hooks before submitting your pull request.
988
+ To install the pre-commit hooks, run:
989
+
990
+ 1. [Install pre-commit](https://pre-commit.com/#install)
991
+ 2. Install the Git hooks by running `pre-commit install` or, alternatively, run `pre-commit run --all-files manually.
@@ -0,0 +1,26 @@
1
+ franky/__init__.py,sha256=57BsmUytdeqMrhHglwvxMS6CgpAEVPw0KJge8_UTzEA,378
2
+ franky/_franky.cpython-312-x86_64-linux-gnu.so,sha256=3B6w3eE39oLT9kalxvQotdMOa-PwxDiBhxQ1yZFiaaQ,3061481
3
+ franky/_franky.pyi,sha256=odBnBaM2qGN4mUa8WvFN5SL9aszPgDTsZj5Jb9UkFHk,60047
4
+ franky/motion.py,sha256=TWsx2Ba9iYG9e-OxpuYZlVn1wdzKS-Zvz6ayHT_HYXQ,354
5
+ franky/reaction.py,sha256=cBuHAMek9yH-9Zmwfa0dzz2t5G_1SQEWXNdW7mhhCI8,1519
6
+ franky/robot.py,sha256=NaTNh4PaJshbz44eibvLCMt6O_Ak7TRVjhUR6AGay9A,236
7
+ franky/robot_web_session.py,sha256=rYpnUe4b8xj5JjCYxNRZ0uYz8lL2qfxKglcImFDw24Y,9070
8
+ franky_control.libs/libPocoFoundation-13a5b20e.so.95,sha256=rxMloAr9p8n7VjzdcsgOc1Gt0_jLczPil9R33w9wsoQ,3269633
9
+ franky_control.libs/libPocoNet-8bb0f68b.so.95,sha256=J3GvO79BxFia9l2UeHvseDIPhJ1660hAz5kY4L2SYJU,2482737
10
+ franky_control.libs/libboost_filesystem-0bf67256.so.1.75.0,sha256=MV-QRMY_pZ0zReU4H4AbcpyZ_sc6yZ6QR6QdDxF84Qc,139961
11
+ franky_control.libs/libboost_serialization-67da18f6.so.1.75.0,sha256=Wjn9rKqoXLrVK29NShhm_evaRsbhTFvvGydi8gwr5hs,319177
12
+ franky_control.libs/libconsole_bridge-acce180d.so.1.0,sha256=-iSKX9xNyLCSSrducf7rDx6hXzdU5v7xQqZDulppIP8,22769
13
+ franky_control.libs/libfmt-677b7a5c.so.8.1.1,sha256=rN3uzEn_limS_u6DV-BxdTEbs2GrhlicD_OjyAlKYpA,140649
14
+ franky_control.libs/libfranka-e5e9247f.so.0.15.0,sha256=gosudHQR1C6GTEsZmAW_YFtr7hBawo6Sgg6aePXKUDw,973497
15
+ franky_control.libs/libpinocchio_default-5f84cd5d.so.3.1.0,sha256=GcnCciSRaTTx7nUBv40Ba6HpxLtCHYnEw91hdjm_dps,9668545
16
+ franky_control.libs/libpinocchio_parsers-a0b97441.so.3.1.0,sha256=Y5XBw0UOgT1xkvBk-v-QHYGwsk9UQDkPd377uN-W5AE,707441
17
+ franky_control.libs/libtinyxml-69e5f0dd.so.0.2.6.2,sha256=V45jOzaljaUrtOAYBS20QBFHn0qPFHTEcWxdcOBoJNA,118121
18
+ franky_control.libs/liburdfdom_model-9ec0392f.so.1.0,sha256=Kwlq8DuENLdEX5URKcwUC06sl9rxUYoRjGx3EI-uRiY,146081
19
+ franky_control.libs/liburdfdom_model_state-01125232.so.1.0,sha256=LNMEG27nv_6BYvelpjXjr0YsBl-6IsGQfg3uG0DvTQQ,20857
20
+ franky_control.libs/liburdfdom_sensor-011819fa.so.1.0,sha256=LzFH_sfeyWcV042TmgSEXTQL1c0teyYg3veA8sTn_EM,20857
21
+ franky_control.libs/liburdfdom_world-4d53bc81.so.1.0,sha256=IziPhPYdFfZTgKDOnUMGLYSCsZRxYfC1rEKWjvzrpb4,146081
22
+ franky_control-1.1.0.dist-info/METADATA,sha256=O0HKEVVI_VNuEOVFEocwKNl_9oUXK3EssjRIdvLxnHM,40320
23
+ franky_control-1.1.0.dist-info/WHEEL,sha256=SxL211n2O6CqwiuQznlhcuGradE6jYmAhgPdjp3Yx3o,113
24
+ franky_control-1.1.0.dist-info/top_level.txt,sha256=LdDKRvHTODs6ll6Ow5b-gmWqt4NJffHxL83MRTCv_Ag,22
25
+ franky_control-1.1.0.dist-info/RECORD,,
26
+ franky_control-1.1.0.dist-info/licenses/LICENSE,sha256=2n6rt7r999OuXp8iOqW9we7ORaxWncIbOwN1ILRGR2g,7651
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp312-cp312-manylinux_2_34_x86_64
5
5
 
@@ -162,4 +162,4 @@ General Public License ever published by the Free Software Foundation.
162
162
  whether future versions of the GNU Lesser General Public License shall
163
163
  apply, that proxy's public statement of acceptance of any version is
164
164
  permanent authorization for you to choose that version for the
165
- Library.
165
+ Library.
@@ -1,28 +0,0 @@
1
- franky/__init__.py,sha256=lmRG8cc4eX-0gZgCkxxVCOrmuUEGJsppWl7DDURib-Y,293
2
- franky/_franky.cpython-312-x86_64-linux-gnu.so,sha256=-AzAyBMBEKnxbQhSEG51jWfbPDZimPupLke75YtMlmU,3053289
3
- franky/_franky.pyi,sha256=ocNP_RzseT7pe5tdwKkBn7hcG3EKXxQ1RDmhNbawIAQ,60039
4
- franky/motion.py,sha256=EZmZPvu2r4YBhcokV1PFh8s8NmiwOUERvct3Zz629C8,334
5
- franky/reaction.py,sha256=gDD7kVc_7Et2NwMmCB4Hcd12aK0eygJVqXzZ9Dzw0_M,1488
6
- franky/robot.py,sha256=NaTNh4PaJshbz44eibvLCMt6O_Ak7TRVjhUR6AGay9A,236
7
- franky/robot_web_session.py,sha256=zOTAqDF4PbZLqJFr3RcuBwfWRSEMiw0Eag1stk3GWKE,7622
8
- franky_control.libs/libPocoFoundationd-74964157.so.92,sha256=BHLfMLcmdIPPcSI8dAkqtFlclnh_y2BtbFNKyF-p3EA,2420809
9
- franky_control.libs/libPocoNetd-5dd54f10.so.92,sha256=OFNDrRm1dpHiAzz5VZppU2O9TU0lkQj_GOMiPKQ0UWo,1907953
10
- franky_control.libs/libboost_atomic-64eba867.so.1.78.0,sha256=CVPFDX4hj4v1t5SuvprkQP6OLyeNY8JwZcxpAVi0kzI,18161
11
- franky_control.libs/libboost_filesystem-63963750.so.1.78.0,sha256=PlaCrBtuzsgfIQlZisEPVw3DDwBDz1jur1Yk6swfEok,167769
12
- franky_control.libs/libboost_serialization-75ebc722.so.1.78.0,sha256=2287N4aM0rCR-iuEDyvMjrx5hefLHyhKBLSCCn3ofRs,319177
13
- franky_control.libs/libconsole_bridge-acce180d.so.1.0,sha256=-iSKX9xNyLCSSrducf7rDx6hXzdU5v7xQqZDulppIP8,22769
14
- franky_control.libs/libfmt-677b7a5c.so.8.1.1,sha256=rN3uzEn_limS_u6DV-BxdTEbs2GrhlicD_OjyAlKYpA,140649
15
- franky_control.libs/libfranka-fb54b5c1.so.0.15.0,sha256=_32_SS3EebthvOxPb5ajzCdQ1VC4w3l2b3dxy3UM1cI,973625
16
- franky_control.libs/libpcre2-8-b77f698a.so.0.11.0,sha256=hQ2wPgk-6gm4ZYWGy6wPDCt46HtNTpYIRBUyH9Fq-9U,642033
17
- franky_control.libs/libpinocchio_default-14a4da3b.so.3.4.0,sha256=-2BBoUEpCtCaA9t9u6D79NGBW-f_jJVOTHoFYb3Pljw,6489713
18
- franky_control.libs/libpinocchio_parsers-9083fe76.so.3.4.0,sha256=CUcLmKVCVW1YCgVL73Zd0XMHAawOBITPUFIUdR3MnHM,593433
19
- franky_control.libs/libtinyxml-69e5f0dd.so.0.2.6.2,sha256=V45jOzaljaUrtOAYBS20QBFHn0qPFHTEcWxdcOBoJNA,118121
20
- franky_control.libs/liburdfdom_model-9ec0392f.so.1.0,sha256=Kwlq8DuENLdEX5URKcwUC06sl9rxUYoRjGx3EI-uRiY,146081
21
- franky_control.libs/liburdfdom_model_state-01125232.so.1.0,sha256=LNMEG27nv_6BYvelpjXjr0YsBl-6IsGQfg3uG0DvTQQ,20857
22
- franky_control.libs/liburdfdom_sensor-011819fa.so.1.0,sha256=LzFH_sfeyWcV042TmgSEXTQL1c0teyYg3veA8sTn_EM,20857
23
- franky_control.libs/liburdfdom_world-4d53bc81.so.1.0,sha256=IziPhPYdFfZTgKDOnUMGLYSCsZRxYfC1rEKWjvzrpb4,146081
24
- franky_control-1.0.1.dist-info/METADATA,sha256=_bCEyfQyvtGBmDvrA85-Z_NV8mWb4so0lQ_sSaanuRs,35098
25
- franky_control-1.0.1.dist-info/WHEEL,sha256=bAqX2RgHd4uHCEuE-DKJ3TSF0n6bOZZ9W1kvGf0k-5Q,113
26
- franky_control-1.0.1.dist-info/top_level.txt,sha256=LdDKRvHTODs6ll6Ow5b-gmWqt4NJffHxL83MRTCv_Ag,22
27
- franky_control-1.0.1.dist-info/RECORD,,
28
- franky_control-1.0.1.dist-info/licenses/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650