franky-control 1.0.2__cp38-cp38-manylinux_2_28_x86_64.whl → 1.1.0__cp38-cp38-manylinux_2_28_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.
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/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
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: franky-control
3
- Version: 1.0.2
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
@@ -64,25 +64,25 @@ at [https://timschneider42.github.io/franky/](https://timschneider42.github.io/f
64
64
 
65
65
  ## 🚀 Features
66
66
 
67
- - **Control your Franka robot directly from Python in just a few lines!**
67
+ - **Control your Franka robot directly from Python in just a few lines!**
68
68
  No more endless hours setting up ROS, juggling packages, or untangling dependencies. Just `pip install` — no ROS at all.
69
69
 
70
- - **[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)
70
+ - **[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)
71
71
  Franky uses [Ruckig](https://github.com/pantor/ruckig) to generate smooth, time-optimal trajectories while respecting velocity, acceleration, and jerk limits.
72
72
 
73
73
  - **[Real-time control from Python and C++](#real-time-motions)**
74
74
  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.
75
75
 
76
- - **[Reactive behavior](#-real-time-reactions)**
76
+ - **[Reactive behavior](#-real-time-reactions)**
77
77
  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.
78
78
 
79
- - **[Motion and reaction callbacks](#motion-callbacks)**
79
+ - **[Motion and reaction callbacks](#motion-callbacks)**
80
80
  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.
81
81
 
82
- - **Things are moving too fast? [Tune the robot's dynamics to your needs](#-robot)**
82
+ - **Things are moving too fast? [Tune the robot's dynamics to your needs](#-robot)**
83
83
  Adjust max velocity, acceleration, and jerk to match your setup or task. Fine control for smooth, safe operation.
84
84
 
85
- - **Full Python access to the libfranka API**
85
+ - **Full Python access to the libfranka API**
86
86
  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.
87
87
 
88
88
  ## 📖 Python Quickstart Guide
@@ -262,6 +262,32 @@ docker compose run --rm franky-build run-tests # To run the tests
262
262
  docker compose run --rm franky-build build-wheels # To build wheels for all supported python versions
263
263
  ```
264
264
 
265
+ ### Can I use CUDA jointly with Franky?
266
+
267
+ 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.
268
+
269
+ First, make sure that you have rebooted your system after installing the real-time kernel.
270
+ 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.
271
+
272
+ If you are on Ubuntu, you can also use [this](tools/install_cuda_realtime.bash) script to install CUDA on your real-time system:
273
+ ```bash
274
+ # Download the script
275
+ wget https://raw.githubusercontent.com/timschneider42/franky/master/tools/install_cuda_realtime.bash
276
+
277
+ # Inspect the script to ensure it does what you expect
278
+
279
+ # Make it executable
280
+ chmod +x install_cuda_realtime.bash
281
+
282
+ # Execute the script
283
+ ./install_cuda_realtime.bash
284
+ ```
285
+
286
+ 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:
287
+ ```bash
288
+ bash <(wget -qO- https://raw.githubusercontent.com/timschneider42/franky/master/tools/install_cuda_realtime.bash)
289
+ ```
290
+
265
291
  ## 📚 Tutorial
266
292
 
267
293
  Franky comes with both a C++ and Python API that differ only regarding real-time capability.
@@ -299,6 +325,8 @@ motion = CartesianMotion(Affine([0.2, 0.0, 0.0]), ReferenceType.Relative)
299
325
  robot.move(motion)
300
326
  ```
301
327
 
328
+ Before executing any code, make sure that you have enabled the Franka Control Interface (FCI) in the Franka UI web interface.
329
+
302
330
  Furthermore, we will introduce methods for geometric calculations, for moving the robot according to different motion
303
331
  types, how to implement real-time reactions and changing waypoints in real time as well as controlling the gripper.
304
332
 
@@ -372,7 +400,7 @@ The robot state can be retrieved by accessing the following properties:
372
400
  obtained
373
401
  from [franka::RobotState::O_T_EE](https://frankaemika.github.io/libfranka/structfranka_1_1RobotState.html#a193781d47722b32925e0ea7ac415f442)
374
402
  and [franka::RobotState::O_dP_EE_c](https://frankaemika.github.io/libfranka/structfranka_1_1RobotState.html#a4be112bd1a9a7d777a67aea4a18a8dcc).
375
- * `current_joint_position`: Object of type `franky.JointState`, which contains the joint positions and velocities
403
+ * `current_joint_state`: Object of type `franky.JointState`, which contains the joint positions and velocities
376
404
  obtained
377
405
  from [franka::RobotState::q](https://frankaemika.github.io/libfranka/structfranka_1_1RobotState.html#ade3335d1ac2f6c44741a916d565f7091)
378
406
  and [franka::RobotState::dq](https://frankaemika.github.io/libfranka/structfranka_1_1RobotState.html#a706045af1b176049e9e56df755325bd2).
@@ -418,8 +446,7 @@ and [Model](https://timschneider42.github.io/franky/classfranky_1_1_model.html)
418
446
 
419
447
  ### <a id="motion-types" /> 🏃‍♂️ Motion Types
420
448
 
421
- Franky currently supports four different impedance control modes: **joint position control**, **joint velocity control
422
- **, **cartesian position control**, and **cartesian velocity control**.
449
+ Franky currently supports four different impedance control modes: **joint position control**, **joint velocity control**, **cartesian position control**, and **cartesian velocity control**.
423
450
  Each of these control modes is invoked by passing the robot an appropriate _Motion_ object.
424
451
 
425
452
  In the following, we provide a brief example for each motion type implemented by Franky in Python.
@@ -455,9 +482,9 @@ m_jp3 = JointWaypointMotion([
455
482
  JointWaypoint([0.1, 0.4, 0.3, -1.4, -0.3, 1.7, 0.9])
456
483
  ])
457
484
 
458
- # Stop the robot in joint position control mode. The difference of JointStopMotion to other stop motions such as
459
- # CartesianStopMotion is that # JointStopMotion # stops the robot in joint position control mode while
460
- # CartesianStopMotion stops it in cartesian pose control mode. The difference becomes relevant when asynchronous move
485
+ # Stop the robot in joint position control mode. The difference of JointStopMotion to other stop motions such as
486
+ # CartesianStopMotion is that # JointStopMotion # stops the robot in joint position control mode while
487
+ # CartesianStopMotion stops it in cartesian pose control mode. The difference becomes relevant when asynchronous move
461
488
  # commands are being sent or reactions are being used(see below).
462
489
  m_jp4 = JointStopMotion()
463
490
  ```
@@ -537,7 +564,7 @@ m_cv1 = CartesianVelocityMotion(Twist([0.2, -0.1, 0.1], [0.1, -0.1, 0.2]))
537
564
  m_cv2 = CartesianVelocityMotion(RobotVelocity(Twist([0.2, -0.1, 0.1], [0.1, -0.1, 0.2]), elbow_velocity=-0.2))
538
565
 
539
566
  # Cartesian velocity motions also support multiple waypoints. Unlike in cartesian position control, a cartesian velocity
540
- # waypoint is a target velocity to be reached. This particular example first accelerates the end-effector, holds the
567
+ # waypoint is a target velocity to be reached. This particular example first accelerates the end-effector, holds the
541
568
  # velocity for 1s, then # reverses direction for 2s, reverses direction again for 1s, and finally stops. It is important
542
569
  # not to forget to stop # the robot at the end of such a sequence, as it will otherwise throw an error.
543
570
  m_cv4 = CartesianVelocityWaypointMotion([
@@ -580,7 +607,7 @@ robot.relative_dynamics_factor = RelativeDynamicsFactor(0.05, 0.1, 0.15)
580
607
 
581
608
  robot.move(m_jp1)
582
609
 
583
- # We can also set a relative dynamics factor in the move command. It will be multiplied with the other relative
610
+ # We can also set a relative dynamics factor in the move command. It will be multiplied with the other relative
584
611
  # dynamics factors (robot and motion if present).
585
612
  robot.move(m_jp2, relative_dynamics_factor=0.8)
586
613
  ```
@@ -705,7 +732,7 @@ motion
705
732
  }),
706
733
  [](const franka::RobotState& state, double rel_time, double abs_time) {
707
734
  // Lambda reaction motion generator
708
- // (we are just returning a stop motion, but there could be arbitrary
735
+ // (we are just returning a stop motion, but there could be arbitrary
709
736
  // logic here for generating reaction motions)
710
737
  return StopMotion<franka::CartesianPose>();
711
738
  })
@@ -750,7 +777,7 @@ The next time `Robot.join_motion` or `Robot.move` are called, they will throw th
750
777
  Hence, after an asynchronous motion has finished, make sure to call `Robot.join_motion` to ensure being notified of any
751
778
  exceptions that occurred during the motion.
752
779
 
753
- ### Gripper
780
+ ### <a id="gripper" /> 👌 Gripper
754
781
 
755
782
  In the `franky::Gripper` class, the default gripper force and gripper speed can be set.
756
783
  Then, additionally to the libfranka commands, the following helper methods can be used:
@@ -825,6 +852,80 @@ else:
825
852
  print("Gripper motion timed out.")
826
853
  ```
827
854
 
855
+ ### Accessing the Web Interface API
856
+
857
+ 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.
858
+ The Franka UI also provides methods for locking and unlocking the brakes, setting the execution mode, and executing the safety self-test.
859
+ 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.
860
+
861
+ For that reason, Franky provides a `RobotWebSession` class that allows you to access the web interface API of the robot.
862
+ Note that directly accessing the web interface API is not officially supported and documented by Franka.
863
+ Hence, use this feature at your own risk.
864
+
865
+ A typical automated workflow could look like this:
866
+
867
+ ```python
868
+ import franky
869
+
870
+ with franky.RobotWebSession("172.16.0.2", "username", "password") as robot_web_session:
871
+ # First take control
872
+ try:
873
+ # Try taking control. The session currently holding control has to release it in order for this session to gain
874
+ # control. In the web interface, a notification will show prompting the user to release control. If the other
875
+ # session is another franky.RobotWebSession, then the `release_control` method can be called on the other
876
+ # session to release control.
877
+ robot_web_session.take_control(wait_timeout=10.0)
878
+ except franky.TakeControlTimeoutError:
879
+ # If nothing happens for 10s, we try to take control forcefully. This is particularly useful if the session
880
+ # holding control is dead. Taking control by force requires the user to manually push the blue button close to
881
+ # the robot's wrist.
882
+ robot_web_session.take_control(wait_timeout=30.0, force=True)
883
+
884
+ # Unlock the brakes
885
+ robot_web_session.unlock_brakes()
886
+
887
+ # Enable the FCI
888
+ robot_web_session.enable_fci()
889
+
890
+ # Create a franky.Robot instance and do whatever you want
891
+ ...
892
+
893
+ # Disable the FCI
894
+ robot_web_session.disable_fci()
895
+
896
+ # Lock brakes
897
+ robot_web_session.lock_brakes()
898
+ ```
899
+
900
+ 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.
901
+ `RobotWebSession` allows to automate this task as well:
902
+
903
+ ```python
904
+ import time
905
+ import franky
906
+
907
+ with franky.RobotWebSession("172.16.0.2", "username", "password") as robot_web_session:
908
+ # Execute self-test if the time until self-test is less than 5 minutes.
909
+ if robot_web_session.get_system_status()["safety"]["timeToTd2"] < 300:
910
+ robot_web_session.disable_fci()
911
+ robot_web_session.lock_brakes()
912
+ time.sleep(1.0)
913
+
914
+ robot_web_session.execute_self_test()
915
+
916
+ robot_web_session.unlock_brakes()
917
+ robot_web_session.enable_fci()
918
+ time.sleep(1.0)
919
+
920
+ # Recreate your franky.Robot instance as the FCI has been disabled and re-enabled
921
+ ...
922
+ ```
923
+
924
+ `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.
925
+
926
+ If you want to call other API functions, you can use the `RobotWebSession.send_api_request` and `RobotWebSession.send_control_api_request` methods.
927
+ See [robot_web_session.py](franky/robot_web_session.py) for an example of how to use these methods.
928
+
828
929
  ## 🛠️ Development
829
930
 
830
931
  Franky is currently tested against following versions
@@ -867,3 +968,12 @@ Aside of bug fixes and general performance improvements, Franky provides the fol
867
968
  * Franky supports [joint velocity control](#joint-velocity-control)
868
969
  and [cartesian velocity control](#cartesian-velocity-control)
869
970
  * The dynamics limits are not hard-coded anymore but can be [set for each robot instance](#-robot).
971
+
972
+ ## Contributing
973
+
974
+ If you wish to contribute to this project, you are welcome to create a pull request.
975
+ Please run the [pre-commit](https://pre-commit.com/) hooks before submitting your pull request.
976
+ To install the pre-commit hooks, run:
977
+
978
+ 1. [Install pre-commit](https://pre-commit.com/#install)
979
+ 2. Install the Git hooks by running `pre-commit install` or, alternatively, run `pre-commit run --all-files manually.
@@ -0,0 +1,27 @@
1
+ franky/__init__.py,sha256=57BsmUytdeqMrhHglwvxMS6CgpAEVPw0KJge8_UTzEA,378
2
+ franky/_franky.cpython-38-x86_64-linux-gnu.so,sha256=tXot0qHR2SFT86v8m40olQ4uAUSfWkPxftaR_e1BdTc,3075809
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-91a48101.so.95,sha256=ayW6qwws-4x4I7Ee3WK4LRRAyaQuTvbGuEBTkjZy7CU,3273833
9
+ franky_control.libs/libPocoNet-9e586dc9.so.95,sha256=KQ6mL1nO9NlXzpp7NcBAKLxC9vjzNd_l9Jy8ldXlotU,2504833
10
+ franky_control.libs/libboost_filesystem-38deced9.so.1.66.0,sha256=-thu-LYmEDUKnOhQw3njV9C58dVZV12pn_6-KoqDCeI,145241
11
+ franky_control.libs/libboost_serialization-3aa46b41.so.1.66.0,sha256=KpSA9K4iakzd-Mvv5JvPSqxJyMYsVkcIXrUbSlAkiIo,316673
12
+ franky_control.libs/libboost_system-69a6c43e.so.1.66.0,sha256=sd_lA0coUWXm-bluxkOkNrzrxFSAXYDphjPDwBekik8,22905
13
+ franky_control.libs/libconsole_bridge-def124d9.so.0.3,sha256=Eg1wJzVIRG5GQhyr59_qdYgnmhto0orU0j8HW2A0JIg,27297
14
+ franky_control.libs/libfmt-8375f6bf.so.6.2.1,sha256=Z8D_NYG4rsuwMIYP3KfNB95w7vnsPaV5XLm2EnWd9Fk,327441
15
+ franky_control.libs/libfranka-92ddaf43.so.0.15.0,sha256=pVavBW1460_MHqwSDTbwkE5vUfGTOi2PnZjSVQRvwOY,1145681
16
+ franky_control.libs/libpinocchio_default-53a889f9.so.3.1.0,sha256=1us8TU8dwRDiCeB-sUnSx2w_Czcr7E-QC21VVO_ht0g,9255841
17
+ franky_control.libs/libpinocchio_parsers-a0902fb5.so.3.1.0,sha256=hsF6GO3VBJu034O1PxRlQSTyGmFKaEdO1_lN7Z3bbgM,713129
18
+ franky_control.libs/libtinyxml-435d1f53.so.0.2.6.2,sha256=BGSkG-zXEYTuGquHhydNow2ufOetDZpEP7MbBZyf6hA,120209
19
+ franky_control.libs/liburdfdom_model-9e7b5a88.so.1.0,sha256=c4cAZ09SHlu-dpMZmwsxC8Ydklm8RzEANxvdJHeh4Ho,187561
20
+ franky_control.libs/liburdfdom_model_state-741cbb83.so.1.0,sha256=NvqLfm2u-YlCihr5GRoUGL6iJMLRHm-RFEmR0he5csM,59105
21
+ franky_control.libs/liburdfdom_sensor-5dbb5bb4.so.1.0,sha256=udrHZ0oYFTf9qwr8hm8rSrBKZDkd1L5yy5tyh10D018,51777
22
+ franky_control.libs/liburdfdom_world-bd943329.so.1.0,sha256=ja9WE45nXtAGUoLpg1T1Hte8BZLldj_WNf9cL3H1RPk,187561
23
+ franky_control-1.1.0.dist-info/LICENSE,sha256=2n6rt7r999OuXp8iOqW9we7ORaxWncIbOwN1ILRGR2g,7651
24
+ franky_control-1.1.0.dist-info/METADATA,sha256=tY2cwf3m5RF0BLL6f5MlP4GC-huOPAImMbvIP4NU0wg,40066
25
+ franky_control-1.1.0.dist-info/WHEEL,sha256=4bDjsNqNiwr2G2bLNR18ftAr5l4l03O656kYhb6U22c,111
26
+ franky_control-1.1.0.dist-info/top_level.txt,sha256=LdDKRvHTODs6ll6Ow5b-gmWqt4NJffHxL83MRTCv_Ag,22
27
+ franky_control-1.1.0.dist-info/RECORD,,
@@ -1,27 +0,0 @@
1
- franky/__init__.py,sha256=lmRG8cc4eX-0gZgCkxxVCOrmuUEGJsppWl7DDURib-Y,293
2
- franky/_franky.cpython-38-x86_64-linux-gnu.so,sha256=N4Suzx4a9DnK4LqFYHqw9UuzbVhoqS6OqPzyMvL1n8Y,3075809
3
- franky/_franky.pyi,sha256=odBnBaM2qGN4mUa8WvFN5SL9aszPgDTsZj5Jb9UkFHk,60047
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/libPocoFoundation-7333b9fc.so.95,sha256=uWvz8wEhtptpIfCJH1nPOe5YC8I-ErEPjDn1uLJO6jo,3273833
9
- franky_control.libs/libPocoNet-007a41b7.so.95,sha256=ID59zS7O1bSBlCF9MZOHyy6n0AcfbLgfHJbSn5QZB60,2504833
10
- franky_control.libs/libboost_filesystem-38deced9.so.1.66.0,sha256=-thu-LYmEDUKnOhQw3njV9C58dVZV12pn_6-KoqDCeI,145241
11
- franky_control.libs/libboost_serialization-3aa46b41.so.1.66.0,sha256=KpSA9K4iakzd-Mvv5JvPSqxJyMYsVkcIXrUbSlAkiIo,316673
12
- franky_control.libs/libboost_system-69a6c43e.so.1.66.0,sha256=sd_lA0coUWXm-bluxkOkNrzrxFSAXYDphjPDwBekik8,22905
13
- franky_control.libs/libconsole_bridge-def124d9.so.0.3,sha256=Eg1wJzVIRG5GQhyr59_qdYgnmhto0orU0j8HW2A0JIg,27297
14
- franky_control.libs/libfmt-8375f6bf.so.6.2.1,sha256=Z8D_NYG4rsuwMIYP3KfNB95w7vnsPaV5XLm2EnWd9Fk,327441
15
- franky_control.libs/libfranka-92ddaf43.so.0.15.0,sha256=lGXhCXAtQnDYzJpz2Jf6tOhBN-0CSaTmVxs9I1p7afo,1145681
16
- franky_control.libs/libpinocchio_default-7b0164b0.so.3.1.0,sha256=vHyDT_5YG6YigVJsdaSnC6FApzePbWbRn2gji5rwZtM,9255841
17
- franky_control.libs/libpinocchio_parsers-50abb87c.so.3.1.0,sha256=46UjCQRT010QVmWFwfddGHr3knuBw3Xcsc09Bw5aLIM,713129
18
- franky_control.libs/libtinyxml-435d1f53.so.0.2.6.2,sha256=BGSkG-zXEYTuGquHhydNow2ufOetDZpEP7MbBZyf6hA,120209
19
- franky_control.libs/liburdfdom_model-9e7b5a88.so.1.0,sha256=c4cAZ09SHlu-dpMZmwsxC8Ydklm8RzEANxvdJHeh4Ho,187561
20
- franky_control.libs/liburdfdom_model_state-741cbb83.so.1.0,sha256=NvqLfm2u-YlCihr5GRoUGL6iJMLRHm-RFEmR0he5csM,59105
21
- franky_control.libs/liburdfdom_sensor-5dbb5bb4.so.1.0,sha256=udrHZ0oYFTf9qwr8hm8rSrBKZDkd1L5yy5tyh10D018,51777
22
- franky_control.libs/liburdfdom_world-bd943329.so.1.0,sha256=ja9WE45nXtAGUoLpg1T1Hte8BZLldj_WNf9cL3H1RPk,187561
23
- franky_control-1.0.2.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
24
- franky_control-1.0.2.dist-info/METADATA,sha256=8w7ITX99ftSyZ4TTdgcZ8fxgYC0_UsNfzcbgatWPK-4,34881
25
- franky_control-1.0.2.dist-info/WHEEL,sha256=4bDjsNqNiwr2G2bLNR18ftAr5l4l03O656kYhb6U22c,111
26
- franky_control-1.0.2.dist-info/top_level.txt,sha256=LdDKRvHTODs6ll6Ow5b-gmWqt4NJffHxL83MRTCv_Ag,22
27
- franky_control-1.0.2.dist-info/RECORD,,