litegrip-python 1.2.0__tar.gz → 1.2.1__tar.gz
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.
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/PKG-INFO +25 -4
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/README.md +24 -3
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/pyproject.toml +1 -1
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/actions.py +125 -16
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/gripper.py +6 -1
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip_python.egg-info/PKG-INFO +25 -4
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_actions.py +120 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/LICENSE +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/setup.cfg +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/__init__.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/calibration_normal.json +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/calibration_reverse.json +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/can/__init__.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/can/controller.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/can/motor.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/can/protocol.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/can/transport.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/constants.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/exceptions.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/factory_calibration.json +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/models.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/protocols/__init__.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/protocols/can_bus.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/py.typed +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/teleop.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/trajectory.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip/zenoh_link.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip_python.egg-info/SOURCES.txt +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip_python.egg-info/dependency_links.txt +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip_python.egg-info/requires.txt +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip_python.egg-info/top_level.txt +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_bus_limits.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_calibration.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_can_stream_silence.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_enable.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_example_hold_force.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_example_teleop.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_examples_bootstrap.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_iface_mtu.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_protocol.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_send_failure_reports_its_cause.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_state_staleness.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_teleop.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_trajectory.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_transport_send.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_version.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_write_zero.py +0 -0
- {litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_zenoh_link.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: litegrip-python
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: Python SDK for the LiteGrip lightweight robotic gripper series
|
|
5
5
|
Author: NEXFORM ROBOTICS
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -202,7 +202,7 @@ young. Ask both when the difference matters.
|
|
|
202
202
|
| `open(speed_mm_s=None, *, progress=None)` → `MoveResult` | Ramps toward the calibrated open-side stop. With `GripperConfig.work_stroke_mm` set it stops at that opening instead — the shipped calibration sets `80.0` against the unit's 85 mm of travel, so a plain `open()` ends 5 mm short of the open end. |
|
|
203
203
|
| `close(speed_mm_s=None, *, progress=None)` → `MoveResult` | The same, toward the closed side. `work_stroke_mm` is an open-side number and does not change where a close ends. |
|
|
204
204
|
| `home()` → `MoveResult` | Ramps to the calibrated closed position. |
|
|
205
|
-
| `grasp(force_n=None, hold_s=0.0, *, progress=None)` → `GraspResult` | Closes onto the object — or onto the closed-side calibrated stop if there is nothing there — then ramps to and holds `force_n` N. The closing leg carries `force_n` as its torque budget, so meeting the object presses no harder than the setpoint. The hold takes over only once the jaw is stopped: it is `stalled=True` (something is between the jaws) or `reached=True` (the jaws closed empty). `hold_s=0` holds until a fault, the runaway watch, Ctrl+C, or a `release()` / `request_release()` from another thread — which ends the grasp with `released=True`. `force_n=None` uses `MotionConfig.force_n` (20 N). |
|
|
205
|
+
| `grasp(force_n=None, hold_s=0.0, *, progress=None)` → `GraspResult` | Closes onto the object — or onto the closed-side calibrated stop if there is nothing there — then ramps to and holds `force_n` N. The closing leg carries `force_n` as its torque budget, so meeting the object presses no harder than the setpoint. The hold takes over only once the jaw is stopped: it is `stalled=True` (something is between the jaws) or `reached=True` (the jaws closed empty). A stop that came **without the jaw ever moving from where the approach began**, with a budget below `MotionConfig.breakaway_nm`, is not treated as contact — the budget simply cannot break static friction — so the call releases in place and returns `no_bite=True` instead of handing over the hold. `hold_s=0` holds until a fault, the runaway watch, Ctrl+C, or a `release()` / `request_release()` from another thread — which ends the grasp with `released=True`. `force_n=None` uses `MotionConfig.force_n` (20 N). |
|
|
206
206
|
| `release(clearance_mm=10.0, *, abort=False, timeout_s=None)` → `ReleaseResult` | Ends an in-progress `grasp()` and opens the jaws from the pose where the grip was declared, by `clearance_mm` more, clamped to the calibrated open stop. Safe to call from any thread while `grasp(hold_s=0)` is blocked in another: it queues the request, the grasp thread performs the opening, and the call returns that outcome. With no grasp running it opens from the current position in the calling thread. `abort=True` is the E-stop form: torque off, no opening move, `ok=False`. A second call during the same grasp joins the first. |
|
|
207
207
|
| `request_release(clearance_mm=10.0, *, abort=False)` → `bool` | Non-blocking form of `release()`: records the request if a grasp is running and returns `True`, else `False`. Never sends a frame, so it is safe for a UI thread, a signal handler or an E-stop callback. The grasp thread acts on it before its next frame (within 5 ms). |
|
|
208
208
|
| `goto(position_mm, kp=None, kd=None, duration=0.5)` → `MoveResult` | Ramp to a position in millimetres. |
|
|
@@ -387,8 +387,8 @@ What it *means*, and what to check, is per action:
|
|
|
387
387
|
|
|
388
388
|
| Type | Fields | `bool()` is |
|
|
389
389
|
| --- | --- | --- |
|
|
390
|
-
| `MoveResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `limit_rad`, `final_cmd_rad`, `steps`, `protected`, `released` | `ok` |
|
|
391
|
-
| `GraspResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `force_n`, `cycles`, `travel_guard`, `released` | `ok` |
|
|
390
|
+
| `MoveResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `limit_rad`, `final_cmd_rad`, `steps`, `protected`, `released`, `no_bite` | `ok` |
|
|
391
|
+
| `GraspResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `force_n`, `cycles`, `travel_guard`, `released`, `no_bite` | `ok` |
|
|
392
392
|
| `ReleaseResult` | `ok`, `state`, `opened_mm`, `target_rad`, `aborted` | `ok` |
|
|
393
393
|
| `EnableResult` | `ok`, `state`, `tries` | `ok` |
|
|
394
394
|
|
|
@@ -414,6 +414,25 @@ A fourth combination is a failure, and new in this version:
|
|
|
414
414
|
`cycles=0`. Nothing was gripped. If you see this, the closing leg is being starved — a stale
|
|
415
415
|
state read, or friction the mechanism's own budget cannot overcome.
|
|
416
416
|
|
|
417
|
+
A fifth is a refusal:
|
|
418
|
+
|
|
419
|
+
- **`grasp()` with `ok=False, no_bite=True`** means the approach carried its force but never moved
|
|
420
|
+
the jaws: it stopped within `MotionConfig.no_bite_mm` (0.5 mm) of where it started *and* its
|
|
421
|
+
budget (`force_n × 0.1 × press_safety`) was below `MotionConfig.breakaway_nm` (0.2 N·m on this
|
|
422
|
+
unit, so setpoints up to 2.2 N). That is not contact — it is a budget that cannot break static
|
|
423
|
+
friction — and it is exactly the case where handing over the hold would send a jaw with a free
|
|
424
|
+
stroke ahead of it into the torque-only frames and let it accelerate. So the hold is never
|
|
425
|
+
entered, the call releases in place, and `cycles` is 0. `stalled` and `reached` are both `False`
|
|
426
|
+
on this path. The remedy is a setpoint above the breakaway (~2.5 N here), not a longer hold.
|
|
427
|
+
Above the breakaway a zero-displacement stop *is* contact and is held normally: a part already
|
|
428
|
+
against the open jaw, or a re-grasp in place after `release(abort=True)`, still grips.
|
|
429
|
+
|
|
430
|
+
Two edges worth knowing. An approach that starts within `reach_tol` (0.9 mm) of the closed stop
|
|
431
|
+
gets no stall verdict at all — it reports `reached` instead, and the hold has nothing to run
|
|
432
|
+
because the jaws are already on the end stop. And the refusal is about the budget, not the part:
|
|
433
|
+
if a grippy part sits at the start pose *and* the setpoint is below the breakaway, the grasp is
|
|
434
|
+
refused rather than risked.
|
|
435
|
+
|
|
417
436
|
- **`grasp()` ended by a release** returns `released=True`: `ok=True` when the opening completed,
|
|
418
437
|
`ok=False` when it was an E-stop (`release(abort=True)`), which sends no opening move. `reached`
|
|
419
438
|
and `stalled` still describe the closing leg; `state` is the pose after the release.
|
|
@@ -475,6 +494,8 @@ with LiteGrip("can0") as gripper:
|
|
|
475
494
|
| `max_lead_mm` | `4.0` | cap on how far the command may lead the measured position, on moves that carry no force setpoint |
|
|
476
495
|
| `stop_lead_mm` | `0.7` | the same cap on the approach to a stop, so the pressing torque stays bounded |
|
|
477
496
|
| `press_safety` | `0.9` | fraction of the setpoint a force-carrying approach may spend |
|
|
497
|
+
| `no_bite_mm` | `0.5` | a force-carrying approach that stops this close to its start pose is refused, not read as contact (see `grasp()` above) |
|
|
498
|
+
| `breakaway_nm` | `0.2` | measured static-friction breakaway; only a budget below it makes a zero-displacement stop a refusal rather than contact |
|
|
478
499
|
| `reach_tol` | `0.02` | position tolerance for `reached`, radians |
|
|
479
500
|
| `stop_tol` | `0.03` | how close to the calibrated stop the jaw must park to count as pressed home |
|
|
480
501
|
| `settle_s` | `0.3` | time spent holding the target after the ramp |
|
|
@@ -174,7 +174,7 @@ young. Ask both when the difference matters.
|
|
|
174
174
|
| `open(speed_mm_s=None, *, progress=None)` → `MoveResult` | Ramps toward the calibrated open-side stop. With `GripperConfig.work_stroke_mm` set it stops at that opening instead — the shipped calibration sets `80.0` against the unit's 85 mm of travel, so a plain `open()` ends 5 mm short of the open end. |
|
|
175
175
|
| `close(speed_mm_s=None, *, progress=None)` → `MoveResult` | The same, toward the closed side. `work_stroke_mm` is an open-side number and does not change where a close ends. |
|
|
176
176
|
| `home()` → `MoveResult` | Ramps to the calibrated closed position. |
|
|
177
|
-
| `grasp(force_n=None, hold_s=0.0, *, progress=None)` → `GraspResult` | Closes onto the object — or onto the closed-side calibrated stop if there is nothing there — then ramps to and holds `force_n` N. The closing leg carries `force_n` as its torque budget, so meeting the object presses no harder than the setpoint. The hold takes over only once the jaw is stopped: it is `stalled=True` (something is between the jaws) or `reached=True` (the jaws closed empty). `hold_s=0` holds until a fault, the runaway watch, Ctrl+C, or a `release()` / `request_release()` from another thread — which ends the grasp with `released=True`. `force_n=None` uses `MotionConfig.force_n` (20 N). |
|
|
177
|
+
| `grasp(force_n=None, hold_s=0.0, *, progress=None)` → `GraspResult` | Closes onto the object — or onto the closed-side calibrated stop if there is nothing there — then ramps to and holds `force_n` N. The closing leg carries `force_n` as its torque budget, so meeting the object presses no harder than the setpoint. The hold takes over only once the jaw is stopped: it is `stalled=True` (something is between the jaws) or `reached=True` (the jaws closed empty). A stop that came **without the jaw ever moving from where the approach began**, with a budget below `MotionConfig.breakaway_nm`, is not treated as contact — the budget simply cannot break static friction — so the call releases in place and returns `no_bite=True` instead of handing over the hold. `hold_s=0` holds until a fault, the runaway watch, Ctrl+C, or a `release()` / `request_release()` from another thread — which ends the grasp with `released=True`. `force_n=None` uses `MotionConfig.force_n` (20 N). |
|
|
178
178
|
| `release(clearance_mm=10.0, *, abort=False, timeout_s=None)` → `ReleaseResult` | Ends an in-progress `grasp()` and opens the jaws from the pose where the grip was declared, by `clearance_mm` more, clamped to the calibrated open stop. Safe to call from any thread while `grasp(hold_s=0)` is blocked in another: it queues the request, the grasp thread performs the opening, and the call returns that outcome. With no grasp running it opens from the current position in the calling thread. `abort=True` is the E-stop form: torque off, no opening move, `ok=False`. A second call during the same grasp joins the first. |
|
|
179
179
|
| `request_release(clearance_mm=10.0, *, abort=False)` → `bool` | Non-blocking form of `release()`: records the request if a grasp is running and returns `True`, else `False`. Never sends a frame, so it is safe for a UI thread, a signal handler or an E-stop callback. The grasp thread acts on it before its next frame (within 5 ms). |
|
|
180
180
|
| `goto(position_mm, kp=None, kd=None, duration=0.5)` → `MoveResult` | Ramp to a position in millimetres. |
|
|
@@ -359,8 +359,8 @@ What it *means*, and what to check, is per action:
|
|
|
359
359
|
|
|
360
360
|
| Type | Fields | `bool()` is |
|
|
361
361
|
| --- | --- | --- |
|
|
362
|
-
| `MoveResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `limit_rad`, `final_cmd_rad`, `steps`, `protected`, `released` | `ok` |
|
|
363
|
-
| `GraspResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `force_n`, `cycles`, `travel_guard`, `released` | `ok` |
|
|
362
|
+
| `MoveResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `limit_rad`, `final_cmd_rad`, `steps`, `protected`, `released`, `no_bite` | `ok` |
|
|
363
|
+
| `GraspResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `force_n`, `cycles`, `travel_guard`, `released`, `no_bite` | `ok` |
|
|
364
364
|
| `ReleaseResult` | `ok`, `state`, `opened_mm`, `target_rad`, `aborted` | `ok` |
|
|
365
365
|
| `EnableResult` | `ok`, `state`, `tries` | `ok` |
|
|
366
366
|
|
|
@@ -386,6 +386,25 @@ A fourth combination is a failure, and new in this version:
|
|
|
386
386
|
`cycles=0`. Nothing was gripped. If you see this, the closing leg is being starved — a stale
|
|
387
387
|
state read, or friction the mechanism's own budget cannot overcome.
|
|
388
388
|
|
|
389
|
+
A fifth is a refusal:
|
|
390
|
+
|
|
391
|
+
- **`grasp()` with `ok=False, no_bite=True`** means the approach carried its force but never moved
|
|
392
|
+
the jaws: it stopped within `MotionConfig.no_bite_mm` (0.5 mm) of where it started *and* its
|
|
393
|
+
budget (`force_n × 0.1 × press_safety`) was below `MotionConfig.breakaway_nm` (0.2 N·m on this
|
|
394
|
+
unit, so setpoints up to 2.2 N). That is not contact — it is a budget that cannot break static
|
|
395
|
+
friction — and it is exactly the case where handing over the hold would send a jaw with a free
|
|
396
|
+
stroke ahead of it into the torque-only frames and let it accelerate. So the hold is never
|
|
397
|
+
entered, the call releases in place, and `cycles` is 0. `stalled` and `reached` are both `False`
|
|
398
|
+
on this path. The remedy is a setpoint above the breakaway (~2.5 N here), not a longer hold.
|
|
399
|
+
Above the breakaway a zero-displacement stop *is* contact and is held normally: a part already
|
|
400
|
+
against the open jaw, or a re-grasp in place after `release(abort=True)`, still grips.
|
|
401
|
+
|
|
402
|
+
Two edges worth knowing. An approach that starts within `reach_tol` (0.9 mm) of the closed stop
|
|
403
|
+
gets no stall verdict at all — it reports `reached` instead, and the hold has nothing to run
|
|
404
|
+
because the jaws are already on the end stop. And the refusal is about the budget, not the part:
|
|
405
|
+
if a grippy part sits at the start pose *and* the setpoint is below the breakaway, the grasp is
|
|
406
|
+
refused rather than risked.
|
|
407
|
+
|
|
389
408
|
- **`grasp()` ended by a release** returns `released=True`: `ok=True` when the opening completed,
|
|
390
409
|
`ok=False` when it was an E-stop (`release(abort=True)`), which sends no opening move. `reached`
|
|
391
410
|
and `stalled` still describe the closing leg; `state` is the pose after the release.
|
|
@@ -447,6 +466,8 @@ with LiteGrip("can0") as gripper:
|
|
|
447
466
|
| `max_lead_mm` | `4.0` | cap on how far the command may lead the measured position, on moves that carry no force setpoint |
|
|
448
467
|
| `stop_lead_mm` | `0.7` | the same cap on the approach to a stop, so the pressing torque stays bounded |
|
|
449
468
|
| `press_safety` | `0.9` | fraction of the setpoint a force-carrying approach may spend |
|
|
469
|
+
| `no_bite_mm` | `0.5` | a force-carrying approach that stops this close to its start pose is refused, not read as contact (see `grasp()` above) |
|
|
470
|
+
| `breakaway_nm` | `0.2` | measured static-friction breakaway; only a budget below it makes a zero-displacement stop a refusal rather than contact |
|
|
450
471
|
| `reach_tol` | `0.02` | position tolerance for `reached`, radians |
|
|
451
472
|
| `stop_tol` | `0.03` | how close to the calibrated stop the jaw must park to count as pressed home |
|
|
452
473
|
| `settle_s` | `0.3` | time spent holding the target after the ramp |
|
|
@@ -14,7 +14,7 @@ name = "litegrip-python"
|
|
|
14
14
|
# Python repositories the placeholder has to be plain `0.0.0`. The nearby
|
|
15
15
|
# `0.0.0+semantic-release` spelling is valid PEP 440 but PyPI rejects local version
|
|
16
16
|
# labels, so it would only move the failure to upload time.
|
|
17
|
-
version = "1.2.
|
|
17
|
+
version = "1.2.1"
|
|
18
18
|
description = "Python SDK for the LiteGrip lightweight robotic gripper series"
|
|
19
19
|
readme = "README.md"
|
|
20
20
|
requires-python = ">=3.10"
|
|
@@ -151,6 +151,37 @@ class MotionConfig:
|
|
|
151
151
|
# 照设定的力往下发。
|
|
152
152
|
press_safety: float = 0.9 # 预算余量:撞上时实测力落在设定值之下
|
|
153
153
|
|
|
154
|
+
# ── 带设定力的接近段「从起点就没动过」的判据 mm ───────────────────
|
|
155
|
+
# 位置窗口判据只能看见「没动」,可「没动」有三种:真顶到工件、顶到限位、
|
|
156
|
+
# 以及**这一段的力矩预算低于静摩擦,压根没能脱离**。第三种最危险:它会被
|
|
157
|
+
# 当成接触,交接给纯力矩的保力段 —— 那一段没有位置项也没有速度项,而保力
|
|
158
|
+
# 的力矩是设定值的 1.0 倍、接近段只有 0.9 倍,多出来的这一成正好越过脱离
|
|
159
|
+
# 力,于是夹爪带着设定力在自由行程里一路加速(2026-10-29 实测:2 N 夹取
|
|
160
|
+
# 的接近段压 0.18 Nm 原地不动,接手的保力段压 0.20 Nm 推了 19 mm)。
|
|
161
|
+
#
|
|
162
|
+
# 所以带设定力的接近段里,位移小于这个值的停住,且预算压不出脱离力(见
|
|
163
|
+
# ``breakaway_nm``)时**不算接触**:报「没能脱离静摩擦」(``MoveResult.no_bite``)、
|
|
164
|
+
# 撤力、不交接。代价是「工件就贴在起点旁边、夹爪还没走开就顶上了」也按这个
|
|
165
|
+
# 处理 —— 那一次夹取会报失败,而反过来放行会把一次误判变成一次带力冲程,
|
|
166
|
+
# 两边代价不对称,所以选失败。
|
|
167
|
+
#
|
|
168
|
+
# 0.5 mm 是台架闭合侧粘滑死区(约 0.0103 rad ≈ 0.76 mm)的下面:比死区更短
|
|
169
|
+
# 的「顶住」读数本来就分辨不出来,真工件也做不到停在这么窄的缝里。
|
|
170
|
+
no_bite_mm: float = 0.5
|
|
171
|
+
|
|
172
|
+
# ── 脱离力:判断「没动」是哪一种的力矩门槛 ────────────────────────
|
|
173
|
+
# 上面那条判据只在**这一段的预算本来就压不出脱离力**时才成立。预算远高于
|
|
174
|
+
# 脱离力时,夹爪没动几乎只可能是顶上了东西 —— 那正是「夹住了」,该交接,
|
|
175
|
+
# 保力段照着设定值压,不会跑。所以判据再收紧一层:只有预算
|
|
176
|
+
# (``force_n × 0.1 × press_safety``) 低于这个值,零位移才判 ``no_bite``;
|
|
177
|
+
# 否则照旧 ``stalled``。少了这一层,20 N 夹一个已经贴在张开侧的工件、或者
|
|
178
|
+
# ``release(abort=True)`` 之后原地重夹(那一次松开不发张开指令),都会被拒。
|
|
179
|
+
#
|
|
180
|
+
# 0.2 Nm 就是这台机器上实测的脱离力(2026-10-29:接近段 0.18 Nm 原地不动,
|
|
181
|
+
# 保力段 0.20 Nm 推走 19 mm,落在 1.8–2.0 N 之间)。换成设定值:≤ 2.2 N 的
|
|
182
|
+
# 夹取预算不到它,零位移判拒夹;≥ 2.5 N 的预算在它之上,零位移判顶住东西。
|
|
183
|
+
breakaway_nm: float = 0.2
|
|
184
|
+
|
|
154
185
|
# ── 行进段堵转保护(≈7 N) ────────────────────────────────────────
|
|
155
186
|
# 普通移动(``press=True`` 的 open/close)行进段的领先上限是 max_lead_mm,
|
|
156
187
|
# 一旦夹爪在半路被硬挡,``kp × 领先上限`` ≈ 7.6 N·m 会一直压着;而位置
|
|
@@ -276,6 +307,11 @@ class MoveResult:
|
|
|
276
307
|
# 只有 ``grasp()`` 的带力接近段会检查它:那一段走的不是用户要的终点,而是
|
|
277
308
|
# 夹取的第一步,松开请求意味着「别夹了」。``grasp()`` 据此改走张开。
|
|
278
309
|
release_requested: bool = False
|
|
310
|
+
# 带设定力的接近段**从起点就没动过**:停住时离起始位置还不到
|
|
311
|
+
# :attr:`MotionConfig.no_bite_mm`。这不是接触 —— 也可能是力矩预算低于静
|
|
312
|
+
# 摩擦、夹爪压根没能脱离(判据和代价见 ``MotionConfig.no_bite_mm``)。置位
|
|
313
|
+
# 时 ``stalled`` 为 False,``grasp()`` 不交接、直接撤力返回。
|
|
314
|
+
no_bite: bool = False
|
|
279
315
|
|
|
280
316
|
def __bool__(self) -> bool:
|
|
281
317
|
return self.ok
|
|
@@ -302,6 +338,11 @@ class GraspResult:
|
|
|
302
338
|
# 请求后先完成松开(张开到 ``max(当前, 夹取点) + 余量``),再返回。与
|
|
303
339
|
# ``travel_guard`` 的区别是这不是故障 —— 松开是用户要的正常收尾。
|
|
304
340
|
released: bool = False
|
|
341
|
+
# 接近段从起点就没能推动夹爪:位移小于 ``MotionConfig.no_bite_mm``,设定值
|
|
342
|
+
# 的 0.9 倍力矩压不出脱离静摩擦需要的力。这一条**不交接**,保力段一帧都不
|
|
343
|
+
# 发 —— 交过去它会在自由行程里一路加速(见 ``MotionConfig.no_bite_mm``)。
|
|
344
|
+
# 置位时 ``stalled`` / ``reached`` 都是 False,``cycles`` 为 0。
|
|
345
|
+
no_bite: bool = False
|
|
305
346
|
|
|
306
347
|
def __bool__(self) -> bool:
|
|
307
348
|
return self.ok
|
|
@@ -790,6 +831,14 @@ class GripperActions:
|
|
|
790
831
|
排程由摩擦和读数延迟定。两条都没成立时**如实报 ``ok=False``** 并撤力
|
|
791
832
|
返回(``reached`` / ``stalled`` 都是 ``False``,``cycles=0``),不放跑。
|
|
792
833
|
|
|
834
|
+
还有一条不算交接:**从起点就没动过**。带设定力的接近段如果停住时离它
|
|
835
|
+
自己的起点不到 :attr:`MotionConfig.no_bite_mm`(0.5 mm),而且这一段的
|
|
836
|
+
预算(``force_n × 0.1 × press_safety``)低于
|
|
837
|
+
:attr:`MotionConfig.breakaway_nm`(0.2 Nm,实测脱离力),那它不是顶到
|
|
838
|
+
工件,而是压根没脱离静摩擦 —— 交过去的话保力段 1.0 倍的力矩正好越过
|
|
839
|
+
脱离力,夹爪会在自由行程里带着设定力一路走。这一条报 ``no_bite=True``、
|
|
840
|
+
``cycles=0``、撤力返回,一帧保力都不发(见 :attr:`MotionConfig.no_bite_mm`)。
|
|
841
|
+
|
|
793
842
|
保力段是纯力矩源,没有位置指令可夹,所以它有自己的一条护栏
|
|
794
843
|
(:attr:`MotionConfig.hold_runaway_rad`):越出闭合侧标定限位太多就撤力
|
|
795
844
|
返回,结果里 ``ok=False`` / ``travel_guard=True``。正常夹取不会触发。
|
|
@@ -804,8 +853,9 @@ class GripperActions:
|
|
|
804
853
|
Returns:
|
|
805
854
|
:class:`GraspResult`。夹住工件时 ``stalled=True`` 且
|
|
806
855
|
``reached=False``(压不到空载目标位置是正常的)。闭合段结束时夹爪
|
|
807
|
-
既没到位也没堵转时 ``ok=False``、``cycles=0`` ——
|
|
808
|
-
|
|
856
|
+
既没到位也没堵转时 ``ok=False``、``cycles=0`` —— 见上。接近段没能
|
|
857
|
+
脱离静摩擦时 ``ok=False``、``no_bite=True``、``cycles=0``。被松开
|
|
858
|
+
结束时 ``released=True``:正常松开 ``ok=True``,急停 ``ok=False``。
|
|
809
859
|
|
|
810
860
|
Raises:
|
|
811
861
|
CommandError: ``force_n`` / ``hold_s`` 不是有限数。两条都不是
|
|
@@ -854,6 +904,21 @@ class GripperActions:
|
|
|
854
904
|
if req is not None:
|
|
855
905
|
return self._grasp_ends_with_release(req, move, force, cycles=0)
|
|
856
906
|
|
|
907
|
+
if move.no_bite:
|
|
908
|
+
# 接近段从起点就没动过:可能是工件就在那里,也可能是设定值的
|
|
909
|
+
# 0.9 倍力矩压不出脱离静摩擦需要的力。两者在电机看来一模一样,
|
|
910
|
+
# 而接手的是纯力矩的保力段(没有位置、没有限速,力矩还比接近段
|
|
911
|
+
# 高一成)—— 猜错的代价是一次带力冲程,猜对(拒夹)的代价只是
|
|
912
|
+
# 一次报失败。所以宁可报失败,也不交接。
|
|
913
|
+
self._release(move.state.position_rad)
|
|
914
|
+
log.warning(
|
|
915
|
+
"夹取未交接:接近段从起点就没能推动夹爪(设定 %.1f N,预算 "
|
|
916
|
+
"%.3f Nm,停在 %.1f mm,目标是闭合端)。保力段是纯力矩源,"
|
|
917
|
+
"交过去会在自由行程里一路加速 —— 撤力返回,不下发保力。",
|
|
918
|
+
force, force * UnitConversion.N_TO_NM * cfg.press_safety,
|
|
919
|
+
move.state.position_mm)
|
|
920
|
+
return self._refused_handover(move, force, no_bite=True)
|
|
921
|
+
|
|
857
922
|
if not (move.reached or move.stalled):
|
|
858
923
|
# 既没到位也没顶上东西 —— 夹爪还在自由行程里,而位置环是此刻
|
|
859
924
|
# 唯一拦着它的东西(kp × 领先 + kd × 速度误差)。保力段的帧里
|
|
@@ -865,16 +930,7 @@ class GripperActions:
|
|
|
865
930
|
"%+.5f rad,目标 %+.5f rad)—— 它还在自由行程里,而保"
|
|
866
931
|
"力段没有位置项也没有速度项,交过去会一路加速。撤力返回。",
|
|
867
932
|
move.state.position_rad, move.target_rad)
|
|
868
|
-
return
|
|
869
|
-
ok=False,
|
|
870
|
-
reached=move.reached,
|
|
871
|
-
stalled=move.stalled,
|
|
872
|
-
state=move.state,
|
|
873
|
-
target_rad=move.target_rad,
|
|
874
|
-
force_n=force,
|
|
875
|
-
cycles=0,
|
|
876
|
-
travel_guard=False,
|
|
877
|
-
)
|
|
933
|
+
return self._refused_handover(move, force)
|
|
878
934
|
|
|
879
935
|
# 交接点:带力接近段的终点(夹爪「声明」抓住的位置),不是随后被
|
|
880
936
|
# 20 N 压实后停下的位置。松开的基准取它,见 _do_release。
|
|
@@ -915,6 +971,31 @@ class GripperActions:
|
|
|
915
971
|
self._grip_rad = None
|
|
916
972
|
self._hold_done.set()
|
|
917
973
|
|
|
974
|
+
@staticmethod
|
|
975
|
+
def _refused_handover(
|
|
976
|
+
move: MoveResult,
|
|
977
|
+
force: float,
|
|
978
|
+
*,
|
|
979
|
+
no_bite: bool = False,
|
|
980
|
+
) -> GraspResult:
|
|
981
|
+
"""交接被拒时的 :class:`GraspResult`:一帧保力都没发。
|
|
982
|
+
|
|
983
|
+
两条拒绝路径 —— 接近段从起点就没动过(``no_bite``),和闭合段结束时
|
|
984
|
+
既没到位也没堵转 —— 结果形状完全一样,只有 ``no_bite`` 不同。放在一处
|
|
985
|
+
构造,免得将来改了字段只改到一条(见 ``grasp()`` 里的两处调用)。
|
|
986
|
+
"""
|
|
987
|
+
return GraspResult(
|
|
988
|
+
ok=False,
|
|
989
|
+
reached=move.reached,
|
|
990
|
+
stalled=move.stalled,
|
|
991
|
+
state=move.state,
|
|
992
|
+
target_rad=move.target_rad,
|
|
993
|
+
force_n=force,
|
|
994
|
+
cycles=0,
|
|
995
|
+
travel_guard=False,
|
|
996
|
+
no_bite=no_bite,
|
|
997
|
+
)
|
|
998
|
+
|
|
918
999
|
def _grasp_ends_with_release(
|
|
919
1000
|
self,
|
|
920
1001
|
req: _ReleaseRequest,
|
|
@@ -1529,6 +1610,11 @@ class GripperActions:
|
|
|
1529
1610
|
# 整段斜坡都是「不动」。`home()` 紧跟在 `close()` 之后(两个都瞄着闭合
|
|
1530
1611
|
# 端,只剩一点点齿隙)就是这个形状。压紧路径不受影响:那里目标在限位
|
|
1531
1612
|
# 外侧,「到了还不动」正是要判的堵转。
|
|
1613
|
+
# 带设定力的接近段里,这一条还留了个小口子:起点落在 ``reach_tol``
|
|
1614
|
+
# (0.02 rad ≈ 0.9 mm)以内时不判堵转,于是 ``no_bite`` 也设不上 ——
|
|
1615
|
+
# 但那时 ``reached`` 为真、夹爪已经在闭合端 0.9 mm 之内,保力段前面
|
|
1616
|
+
# 没有自由行程可跑,交过去最多把最后那点缝隙压到限位上。所以这条口子
|
|
1617
|
+
# 不补,README 说的是「从起点就没动过」不是「任何情况下都不交接」。
|
|
1532
1618
|
judge_stall = press or dist_mm > cfg.reach_tol * gcfg.rad_to_mm
|
|
1533
1619
|
|
|
1534
1620
|
# 两档领先上限:行进段用 max_lead_mm 破静摩擦,贴近限位后收窄到
|
|
@@ -1558,6 +1644,7 @@ class GripperActions:
|
|
|
1558
1644
|
|
|
1559
1645
|
hist = [before.position_rad]
|
|
1560
1646
|
stalled = False
|
|
1647
|
+
no_bite = False # 带力接近段从起点就没动过(见上)
|
|
1561
1648
|
protected = False
|
|
1562
1649
|
release_requested = False # 松开请求叫停了带力接近段
|
|
1563
1650
|
over_torque = 0 # 连续过阈的采样点数
|
|
@@ -1653,10 +1740,31 @@ class GripperActions:
|
|
|
1653
1740
|
if (judge_stall and win_delta is not None
|
|
1654
1741
|
and (press or in_ramp)
|
|
1655
1742
|
and win_delta < win_thresh_rad):
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1743
|
+
# 「没动」不等于「顶到工件」:带设定力时,从起点起就没挪过位的
|
|
1744
|
+
# 停住也可能是这一段压不出脱离静摩擦的力矩。这一条不能当接触,
|
|
1745
|
+
# 否则交接给纯力矩的保力段就是一次带力冲程(见
|
|
1746
|
+
# ``MotionConfig.no_bite_mm``)。但只有预算本来就在脱离力之下时
|
|
1747
|
+
# 才这么判 —— 预算远高于脱离力还没动,那是真顶上了东西
|
|
1748
|
+
# (见 ``MotionConfig.breakaway_nm``)。
|
|
1749
|
+
if (force_n is not None
|
|
1750
|
+
and force_n * UnitConversion.N_TO_NM * cfg.press_safety
|
|
1751
|
+
< cfg.breakaway_nm
|
|
1752
|
+
and abs(pos - before.position_rad)
|
|
1753
|
+
< cfg.no_bite_mm / gcfg.rad_to_mm):
|
|
1754
|
+
no_bite = True
|
|
1755
|
+
log.warning(
|
|
1756
|
+
"接近段没能脱离静摩擦:预算 %.3f Nm 下,夹爪从 %+.5f rad "
|
|
1757
|
+
"起只挪了 %.2f mm 就停住(目标 %+.5f rad,还差 %.1f mm)。"
|
|
1758
|
+
"「没动」也可能是力矩不够,不是顶到工件 —— 不交接、撤力。",
|
|
1759
|
+
force_n * UnitConversion.N_TO_NM * cfg.press_safety,
|
|
1760
|
+
before.position_rad,
|
|
1761
|
+
abs(pos - before.position_rad) * gcfg.rad_to_mm,
|
|
1762
|
+
target, abs(pos - target) * gcfg.rad_to_mm)
|
|
1763
|
+
else:
|
|
1764
|
+
stalled = True
|
|
1765
|
+
log.info("堵转:最近 %d 次采样(%.2f s)净位移仅 %.5f rad "
|
|
1766
|
+
"(< %.5f),停在 %+.5f rad",
|
|
1767
|
+
win, win_s, win_delta, win_thresh_rad, pos)
|
|
1660
1768
|
break
|
|
1661
1769
|
|
|
1662
1770
|
# 行进段堵转力矩保护(≈7 N):与位置窗口判据**互补** —— 位置窗口对
|
|
@@ -1703,6 +1811,7 @@ class GripperActions:
|
|
|
1703
1811
|
steps=last_i,
|
|
1704
1812
|
protected=protected,
|
|
1705
1813
|
release_requested=release_requested,
|
|
1814
|
+
no_bite=no_bite,
|
|
1706
1815
|
)
|
|
1707
1816
|
|
|
1708
1817
|
def _hold_force(
|
|
@@ -1393,7 +1393,12 @@ class LiteGrip:
|
|
|
1393
1393
|
it closed onto an object, which is the expected outcome.
|
|
1394
1394
|
``released=True`` means the grasp ended because a release was
|
|
1395
1395
|
requested: ``ok=True`` for a normal release, ``ok=False`` for
|
|
1396
|
-
an abort.
|
|
1396
|
+
an abort. ``no_bite=True`` (with ``ok=False``, ``cycles=0``)
|
|
1397
|
+
means the approach never moved the jaws and its torque budget
|
|
1398
|
+
was below the breakaway: the hold was **not** entered, because
|
|
1399
|
+
handing a jaw with a free stroke ahead of it to the torque-only
|
|
1400
|
+
hold would power it across the gap. See
|
|
1401
|
+
``MotionConfig.no_bite_mm`` and ``.breakaway_nm``.
|
|
1397
1402
|
"""
|
|
1398
1403
|
self._check_connected()
|
|
1399
1404
|
return self._actions.grasp(force_n, hold_s, progress=progress)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: litegrip-python
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: Python SDK for the LiteGrip lightweight robotic gripper series
|
|
5
5
|
Author: NEXFORM ROBOTICS
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -202,7 +202,7 @@ young. Ask both when the difference matters.
|
|
|
202
202
|
| `open(speed_mm_s=None, *, progress=None)` → `MoveResult` | Ramps toward the calibrated open-side stop. With `GripperConfig.work_stroke_mm` set it stops at that opening instead — the shipped calibration sets `80.0` against the unit's 85 mm of travel, so a plain `open()` ends 5 mm short of the open end. |
|
|
203
203
|
| `close(speed_mm_s=None, *, progress=None)` → `MoveResult` | The same, toward the closed side. `work_stroke_mm` is an open-side number and does not change where a close ends. |
|
|
204
204
|
| `home()` → `MoveResult` | Ramps to the calibrated closed position. |
|
|
205
|
-
| `grasp(force_n=None, hold_s=0.0, *, progress=None)` → `GraspResult` | Closes onto the object — or onto the closed-side calibrated stop if there is nothing there — then ramps to and holds `force_n` N. The closing leg carries `force_n` as its torque budget, so meeting the object presses no harder than the setpoint. The hold takes over only once the jaw is stopped: it is `stalled=True` (something is between the jaws) or `reached=True` (the jaws closed empty). `hold_s=0` holds until a fault, the runaway watch, Ctrl+C, or a `release()` / `request_release()` from another thread — which ends the grasp with `released=True`. `force_n=None` uses `MotionConfig.force_n` (20 N). |
|
|
205
|
+
| `grasp(force_n=None, hold_s=0.0, *, progress=None)` → `GraspResult` | Closes onto the object — or onto the closed-side calibrated stop if there is nothing there — then ramps to and holds `force_n` N. The closing leg carries `force_n` as its torque budget, so meeting the object presses no harder than the setpoint. The hold takes over only once the jaw is stopped: it is `stalled=True` (something is between the jaws) or `reached=True` (the jaws closed empty). A stop that came **without the jaw ever moving from where the approach began**, with a budget below `MotionConfig.breakaway_nm`, is not treated as contact — the budget simply cannot break static friction — so the call releases in place and returns `no_bite=True` instead of handing over the hold. `hold_s=0` holds until a fault, the runaway watch, Ctrl+C, or a `release()` / `request_release()` from another thread — which ends the grasp with `released=True`. `force_n=None` uses `MotionConfig.force_n` (20 N). |
|
|
206
206
|
| `release(clearance_mm=10.0, *, abort=False, timeout_s=None)` → `ReleaseResult` | Ends an in-progress `grasp()` and opens the jaws from the pose where the grip was declared, by `clearance_mm` more, clamped to the calibrated open stop. Safe to call from any thread while `grasp(hold_s=0)` is blocked in another: it queues the request, the grasp thread performs the opening, and the call returns that outcome. With no grasp running it opens from the current position in the calling thread. `abort=True` is the E-stop form: torque off, no opening move, `ok=False`. A second call during the same grasp joins the first. |
|
|
207
207
|
| `request_release(clearance_mm=10.0, *, abort=False)` → `bool` | Non-blocking form of `release()`: records the request if a grasp is running and returns `True`, else `False`. Never sends a frame, so it is safe for a UI thread, a signal handler or an E-stop callback. The grasp thread acts on it before its next frame (within 5 ms). |
|
|
208
208
|
| `goto(position_mm, kp=None, kd=None, duration=0.5)` → `MoveResult` | Ramp to a position in millimetres. |
|
|
@@ -387,8 +387,8 @@ What it *means*, and what to check, is per action:
|
|
|
387
387
|
|
|
388
388
|
| Type | Fields | `bool()` is |
|
|
389
389
|
| --- | --- | --- |
|
|
390
|
-
| `MoveResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `limit_rad`, `final_cmd_rad`, `steps`, `protected`, `released` | `ok` |
|
|
391
|
-
| `GraspResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `force_n`, `cycles`, `travel_guard`, `released` | `ok` |
|
|
390
|
+
| `MoveResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `limit_rad`, `final_cmd_rad`, `steps`, `protected`, `released`, `no_bite` | `ok` |
|
|
391
|
+
| `GraspResult` | `ok`, `reached`, `stalled`, `state`, `target_rad`, `force_n`, `cycles`, `travel_guard`, `released`, `no_bite` | `ok` |
|
|
392
392
|
| `ReleaseResult` | `ok`, `state`, `opened_mm`, `target_rad`, `aborted` | `ok` |
|
|
393
393
|
| `EnableResult` | `ok`, `state`, `tries` | `ok` |
|
|
394
394
|
|
|
@@ -414,6 +414,25 @@ A fourth combination is a failure, and new in this version:
|
|
|
414
414
|
`cycles=0`. Nothing was gripped. If you see this, the closing leg is being starved — a stale
|
|
415
415
|
state read, or friction the mechanism's own budget cannot overcome.
|
|
416
416
|
|
|
417
|
+
A fifth is a refusal:
|
|
418
|
+
|
|
419
|
+
- **`grasp()` with `ok=False, no_bite=True`** means the approach carried its force but never moved
|
|
420
|
+
the jaws: it stopped within `MotionConfig.no_bite_mm` (0.5 mm) of where it started *and* its
|
|
421
|
+
budget (`force_n × 0.1 × press_safety`) was below `MotionConfig.breakaway_nm` (0.2 N·m on this
|
|
422
|
+
unit, so setpoints up to 2.2 N). That is not contact — it is a budget that cannot break static
|
|
423
|
+
friction — and it is exactly the case where handing over the hold would send a jaw with a free
|
|
424
|
+
stroke ahead of it into the torque-only frames and let it accelerate. So the hold is never
|
|
425
|
+
entered, the call releases in place, and `cycles` is 0. `stalled` and `reached` are both `False`
|
|
426
|
+
on this path. The remedy is a setpoint above the breakaway (~2.5 N here), not a longer hold.
|
|
427
|
+
Above the breakaway a zero-displacement stop *is* contact and is held normally: a part already
|
|
428
|
+
against the open jaw, or a re-grasp in place after `release(abort=True)`, still grips.
|
|
429
|
+
|
|
430
|
+
Two edges worth knowing. An approach that starts within `reach_tol` (0.9 mm) of the closed stop
|
|
431
|
+
gets no stall verdict at all — it reports `reached` instead, and the hold has nothing to run
|
|
432
|
+
because the jaws are already on the end stop. And the refusal is about the budget, not the part:
|
|
433
|
+
if a grippy part sits at the start pose *and* the setpoint is below the breakaway, the grasp is
|
|
434
|
+
refused rather than risked.
|
|
435
|
+
|
|
417
436
|
- **`grasp()` ended by a release** returns `released=True`: `ok=True` when the opening completed,
|
|
418
437
|
`ok=False` when it was an E-stop (`release(abort=True)`), which sends no opening move. `reached`
|
|
419
438
|
and `stalled` still describe the closing leg; `state` is the pose after the release.
|
|
@@ -475,6 +494,8 @@ with LiteGrip("can0") as gripper:
|
|
|
475
494
|
| `max_lead_mm` | `4.0` | cap on how far the command may lead the measured position, on moves that carry no force setpoint |
|
|
476
495
|
| `stop_lead_mm` | `0.7` | the same cap on the approach to a stop, so the pressing torque stays bounded |
|
|
477
496
|
| `press_safety` | `0.9` | fraction of the setpoint a force-carrying approach may spend |
|
|
497
|
+
| `no_bite_mm` | `0.5` | a force-carrying approach that stops this close to its start pose is refused, not read as contact (see `grasp()` above) |
|
|
498
|
+
| `breakaway_nm` | `0.2` | measured static-friction breakaway; only a budget below it makes a zero-displacement stop a refusal rather than contact |
|
|
478
499
|
| `reach_tol` | `0.02` | position tolerance for `reached`, radians |
|
|
479
500
|
| `stop_tol` | `0.03` | how close to the calibrated stop the jaw must park to count as pressed home |
|
|
480
501
|
| `settle_s` | `0.3` | time spent holding the target after the ramp |
|
|
@@ -1879,6 +1879,126 @@ class TestForceApproachPressBudget(unittest.TestCase):
|
|
|
1879
1879
|
self.assertAlmostEqual(f.tau_ff, 2.0, places=9)
|
|
1880
1880
|
|
|
1881
1881
|
|
|
1882
|
+
class TestTheApproachRefusesToHandOverWithoutBite(unittest.TestCase):
|
|
1883
|
+
"""接近段从起点就没动过时不许交接:那是「没能脱离静摩擦」,不是接触。
|
|
1884
|
+
|
|
1885
|
+
2026-10-29 台架实测(2 N 夹取):接近段压 0.18 Nm,整个 0.25 s 堵转窗口只挪了
|
|
1886
|
+
0.0004 rad;它被判成「顶到工件」,接手的保力段压 0.20 Nm —— 设定值的 1.0 倍,
|
|
1887
|
+
比接近段高出一成,正好越过脱离力 —— 于是夹爪带着设定力在自由行程里推了 19 mm,
|
|
1888
|
+
夹取点报在工件前 19–39 mm。操作者看到的是「先不动,然后飞速闭合」。
|
|
1889
|
+
|
|
1890
|
+
判据见 ``MotionConfig.no_bite_mm``:带设定力的接近段里,位移小于这个值的停住
|
|
1891
|
+
不算接触 —— 报 ``no_bite``、撤力,保力段一帧都不发。而且只在预算低于
|
|
1892
|
+
``MotionConfig.breakaway_nm`` 时才这么判:预算远高于脱离力还没动,那是真顶上了
|
|
1893
|
+
东西(见 ``test_a_workpiece_at_the_start_is_contact_above_the_breakaway``)。
|
|
1894
|
+
"""
|
|
1895
|
+
|
|
1896
|
+
#: 实测脱离力落在 1.8–2.0 N,取 0.19 Nm(1.9 N):2 N 夹取的预算 0.18 Nm 压不动,
|
|
1897
|
+
#: 3 N 的 0.27 Nm 压得动。
|
|
1898
|
+
BREAKAWAY_NM = 0.19
|
|
1899
|
+
#: 纯力矩的保力帧在假台上要靠这个才动(默认模型里 kp=0 一点不动)。
|
|
1900
|
+
CREEP = 5.0
|
|
1901
|
+
|
|
1902
|
+
def _grasp(self, force_n, hold_s=0.2, *, no_bite_mm=None, **kw):
|
|
1903
|
+
motion = MotionConfig(sleep_fn=lambda _: None,
|
|
1904
|
+
monotonic_fn=tick_clock(0.1))
|
|
1905
|
+
if no_bite_mm is not None:
|
|
1906
|
+
motion.no_bite_mm = no_bite_mm
|
|
1907
|
+
g, fake = make_gripper(stops=True, motion=motion,
|
|
1908
|
+
breakaway_tau_nm=self.BREAKAWAY_NM,
|
|
1909
|
+
creep_rad_s_per_nm=self.CREEP, **kw)
|
|
1910
|
+
return g, fake, g.grasp(force_n=force_n, hold_s=hold_s)
|
|
1911
|
+
|
|
1912
|
+
@staticmethod
|
|
1913
|
+
def _budget(force_n):
|
|
1914
|
+
return force_n * UnitConversion.N_TO_NM * MotionConfig().press_safety
|
|
1915
|
+
|
|
1916
|
+
@staticmethod
|
|
1917
|
+
def _travelled_mm(fake):
|
|
1918
|
+
return abs(fake.motor.pos - POS_OPEN_RAD) * RAD_TO_MM
|
|
1919
|
+
|
|
1920
|
+
def test_the_old_handover_walks_the_jaws_across_the_whole_free_stroke(self):
|
|
1921
|
+
"""修复前的行为,钉在这里当对照:保力段把夹爪一路推到底。
|
|
1922
|
+
|
|
1923
|
+
``no_bite_mm=0`` 关掉拒夹,就是修复前的样子。零位移被判成接触之后,保力
|
|
1924
|
+
段的 0.20 Nm 越过了 0.19 Nm 的脱离力,夹爪在整段自由行程里被推着走 ——
|
|
1925
|
+
这正是台架上「先不动,然后飞速闭合」的那一台。下一条用例要证明的,就是
|
|
1926
|
+
拒夹把这段行程拦在了开头。两条用的是同一个假台,只差一个 ``no_bite_mm``。
|
|
1927
|
+
"""
|
|
1928
|
+
_g, fake, res = self._grasp(2.0, no_bite_mm=0.0)
|
|
1929
|
+
|
|
1930
|
+
self.assertTrue(res.stalled, res) # 修复前:零位移被当成接触
|
|
1931
|
+
self.assertFalse(res.no_bite, res)
|
|
1932
|
+
self.assertGreater(res.cycles, 0, res)
|
|
1933
|
+
# 0.2 s 的保力就推了十几毫米(台架那次是 19 mm,夹取点报在工件前),
|
|
1934
|
+
# 而修复后同一个动作一毫米都不走 —— 对比就在下一条用例。
|
|
1935
|
+
self.assertGreater(self._travelled_mm(fake), 10.0,
|
|
1936
|
+
f"保力段应该把夹爪推着走,实际只走了 "
|
|
1937
|
+
f"{self._travelled_mm(fake):.1f} mm")
|
|
1938
|
+
|
|
1939
|
+
def test_the_refusal_stops_that_stroke_before_it_starts(self):
|
|
1940
|
+
_g, fake, res = self._grasp(2.0)
|
|
1941
|
+
|
|
1942
|
+
self.assertLess(self._budget(2.0), self.BREAKAWAY_NM) # 前提
|
|
1943
|
+
self.assertFalse(res.ok, res)
|
|
1944
|
+
self.assertTrue(res.no_bite, res)
|
|
1945
|
+
self.assertFalse(res.stalled, res) # 停住 ≠ 顶到工件
|
|
1946
|
+
self.assertFalse(res.reached, res)
|
|
1947
|
+
self.assertEqual(res.cycles, 0)
|
|
1948
|
+
self.assertLess(self._travelled_mm(fake), MotionConfig().no_bite_mm,
|
|
1949
|
+
"拒夹之后夹爪不许离开起点")
|
|
1950
|
+
self.assertEqual([f for f in fake.frames if f.tau_ff != 0.0], [],
|
|
1951
|
+
"保力段一帧都不许发:它是纯力矩源,没有位置也没有限速")
|
|
1952
|
+
self.assertEqual(fake.frames[-1].kp, 0.0, "结尾要撤力")
|
|
1953
|
+
|
|
1954
|
+
def test_the_setpoint_above_the_breakaway_still_grasps(self):
|
|
1955
|
+
_g, fake, res = self._grasp(3.0)
|
|
1956
|
+
|
|
1957
|
+
self.assertGreater(self._budget(3.0), self.BREAKAWAY_NM) # 前提
|
|
1958
|
+
self.assertFalse(res.no_bite, res)
|
|
1959
|
+
self.assertTrue(res.reached, res)
|
|
1960
|
+
self.assertTrue(res.ok, res)
|
|
1961
|
+
self.assertGreater(res.cycles, 0)
|
|
1962
|
+
|
|
1963
|
+
def test_a_workpiece_at_the_start_is_contact_above_the_breakaway(self):
|
|
1964
|
+
"""预算远高于脱离力时,零位移是**顶上东西**,不是没能脱离。
|
|
1965
|
+
|
|
1966
|
+
电机分不出这两种零位移,判据改用预算来分:0.20 Nm 以上还不动,只可能是
|
|
1967
|
+
有东西挡着。这时该交接 —— 保力段照着设定值压,压的就是用户要的力。少了
|
|
1968
|
+
这一条,一个已经贴在张开侧的工件、以及 ``release(abort=True)`` 之后原地
|
|
1969
|
+
重夹(那一次松开不发张开指令),都会变成一次失败的夹取。
|
|
1970
|
+
"""
|
|
1971
|
+
start = POS_OPEN_RAD
|
|
1972
|
+
block = start + 0.001 * (POS_CLOSED_RAD - POS_OPEN_RAD) # ≈ 0.08 mm
|
|
1973
|
+
motion = MotionConfig(sleep_fn=lambda _: None,
|
|
1974
|
+
monotonic_fn=tick_clock(0.1))
|
|
1975
|
+
g, _fake = make_gripper(stops=True, motion=motion, block_rad=block)
|
|
1976
|
+
res = g.grasp(force_n=20.0, hold_s=0.2)
|
|
1977
|
+
|
|
1978
|
+
self.assertFalse(res.no_bite, res)
|
|
1979
|
+
self.assertTrue(res.stalled, res)
|
|
1980
|
+
self.assertTrue(res.ok, res)
|
|
1981
|
+
self.assertGreater(res.cycles, 0)
|
|
1982
|
+
|
|
1983
|
+
def test_a_workpiece_at_the_start_is_refused_below_the_breakaway(self):
|
|
1984
|
+
"""代价写在测试里:预算不到脱离力时,贴在起点上的工件也会被拒。
|
|
1985
|
+
|
|
1986
|
+
和上一条同一块挡块、同一个起点,只把设定值降到 2 N。拒夹的代价是操作者
|
|
1987
|
+
看到一次失败、重摆一次;放行的代价是一次带力冲程(上一条用例里的整段)。
|
|
1988
|
+
两边不对称,所以选拒夹。
|
|
1989
|
+
"""
|
|
1990
|
+
start = POS_OPEN_RAD
|
|
1991
|
+
block = start + 0.001 * (POS_CLOSED_RAD - POS_OPEN_RAD)
|
|
1992
|
+
motion = MotionConfig(sleep_fn=lambda _: None,
|
|
1993
|
+
monotonic_fn=tick_clock(0.1))
|
|
1994
|
+
g, fake = make_gripper(stops=True, motion=motion, block_rad=block)
|
|
1995
|
+
res = g.grasp(force_n=2.0, hold_s=0.2)
|
|
1996
|
+
|
|
1997
|
+
self.assertTrue(res.no_bite, res)
|
|
1998
|
+
self.assertFalse(res.ok, res)
|
|
1999
|
+
self.assertEqual([f for f in fake.frames if f.tau_ff != 0.0], [])
|
|
2000
|
+
|
|
2001
|
+
|
|
1882
2002
|
class TestNonFiniteInputIsRefused(unittest.TestCase):
|
|
1883
2003
|
"""非有限值不许变成运动:拒绝带原因,而且**一帧都不发**。
|
|
1884
2004
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{litegrip_python-1.2.0 → litegrip_python-1.2.1}/src/litegrip_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{litegrip_python-1.2.0 → litegrip_python-1.2.1}/tests/test_send_failure_reports_its_cause.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|