first commit

This commit is contained in:
cheng
2026-06-29 17:14:42 +08:00
parent 9ef1c8782a
commit c609c3901f
18 changed files with 49 additions and 4 deletions
+4
View File
@@ -0,0 +1,4 @@
{
"python-envs.defaultEnvManager": "ms-python.python:conda",
"python-envs.defaultPackageManager": "ms-python.python:conda"
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.
Binary file not shown.
+7
View File
@@ -35,6 +35,11 @@ class GripperClient:
f"accel={accel}, decel={decel}" f"accel={accel}, decel={decel}"
) )
return return
if self.motor is None:
raise RuntimeError(
"gripper motor is not connected; check serial port, conda environment, "
"and changingtek_p_rtu_Servo.py"
)
self.motor.temp_move( self.motor.temp_move(
position_mm=int(position), position_mm=int(position),
@@ -95,6 +100,8 @@ class GripperClient:
def final_open_if_needed(self): def final_open_if_needed(self):
if not self.config.open_at_end: if not self.config.open_at_end:
return return
if not self.config.dry_run and self.motor is None:
return
final_force = int(clamp( final_force = int(clamp(
self.config.initial_force, self.config.initial_force,
self.config.force_min, self.config.force_min,
+4 -2
View File
@@ -29,7 +29,7 @@ SENSOR_CPU = False
# 夹爪串口配置。 # 夹爪串口配置。
PORT = "COM5" PORT = "COM6"
SLAVE_ID = 1 SLAVE_ID = 1
BAUDRATE = 115200 BAUDRATE = 115200
SERIAL_TIMEOUT = 0.2 SERIAL_TIMEOUT = 0.2
@@ -79,9 +79,10 @@ OPEN_WAIT_STABLE_TREND_N = 0.015 # 近期样本首尾变化小于该值,认
# 闭合夹取:物体移动到中间后,左右两边都超过该阈值就认为夹住。 # 闭合夹取:物体移动到中间后,左右两边都超过该阈值就认为夹住。
GRIP_NORMAL_FORCE = 0.05 # 双侧接触阈值,单位 N。 GRIP_NORMAL_FORCE = 0.2 # 双侧接触阈值,单位 N。
GRIP_REQUIRES_BOTH = True # True 表示必须左右两侧都接触才算夹住。 GRIP_REQUIRES_BOTH = True # True 表示必须左右两侧都接触才算夹住。
CLOSE_TIMEOUT_SECONDS = 5.0 # 触发闭合后这么久还没夹住,就重新张开等待。 CLOSE_TIMEOUT_SECONDS = 5.0 # 触发闭合后这么久还没夹住,就重新张开等待。
CLOSING_COMMAND_INTERVAL = 0.2 # 闭合阶段还没双侧夹上时,按该间隔续发闭合命令,避免单侧扫过后停住。
# 检测到物体后慢慢加力,类似 01 的 gripping 状态。 # 检测到物体后慢慢加力,类似 01 的 gripping 状态。
@@ -211,6 +212,7 @@ CONFIG = {
"grip_normal_force": GRIP_NORMAL_FORCE, "grip_normal_force": GRIP_NORMAL_FORCE,
"grip_requires_both": GRIP_REQUIRES_BOTH, "grip_requires_both": GRIP_REQUIRES_BOTH,
"close_timeout_seconds": CLOSE_TIMEOUT_SECONDS, "close_timeout_seconds": CLOSE_TIMEOUT_SECONDS,
"closing_command_interval": CLOSING_COMMAND_INTERVAL,
"force_ramp_step": FORCE_RAMP_STEP, "force_ramp_step": FORCE_RAMP_STEP,
"force_ramp_interval": FORCE_RAMP_INTERVAL, "force_ramp_interval": FORCE_RAMP_INTERVAL,
"grip_settle_seconds": GRIP_SETTLE_SECONDS, "grip_settle_seconds": GRIP_SETTLE_SECONDS,
+8
View File
@@ -325,6 +325,14 @@ class SideTriggerGripController:
hold_pos = None hold_pos = None
reference = None reference = None
action = "close-timeout-open" action = "close-timeout-open"
else:
if (
config.closing_command_interval > 0
and now - last_force_ramp_time >= config.closing_command_interval
):
self.gripper.close(force_pct, "closing-continue")
last_force_ramp_time = now
action = "closing-continue"
else: else:
action = "closing-to-grip" action = "closing-to-grip"
+2
View File
@@ -69,6 +69,7 @@ class Demo02Config:
grip_normal_force: float = 0.05 grip_normal_force: float = 0.05
grip_requires_both: bool = True grip_requires_both: bool = True
close_timeout_seconds: float = 5.0 close_timeout_seconds: float = 5.0
closing_command_interval: float = 0.2
force_ramp_step: int = 1 force_ramp_step: int = 1
force_ramp_interval: float = 0.1 force_ramp_interval: float = 0.1
grip_settle_seconds: float = 0.1 grip_settle_seconds: float = 0.1
@@ -161,6 +162,7 @@ class Demo02Config:
add("--grip-requires-both", dest="grip_requires_both", action="store_true", default=get("grip_requires_both", cls.grip_requires_both)) add("--grip-requires-both", dest="grip_requires_both", action="store_true", default=get("grip_requires_both", cls.grip_requires_both))
add("--allow-single-side-grip", dest="grip_requires_both", action="store_false") add("--allow-single-side-grip", dest="grip_requires_both", action="store_false")
add("--close-timeout-seconds", type=float, default=get("close_timeout_seconds", cls.close_timeout_seconds)) add("--close-timeout-seconds", type=float, default=get("close_timeout_seconds", cls.close_timeout_seconds))
add("--closing-command-interval", type=float, default=get("closing_command_interval", cls.closing_command_interval))
add("--force-ramp-step", type=int, default=get("force_ramp_step", cls.force_ramp_step)) add("--force-ramp-step", type=int, default=get("force_ramp_step", cls.force_ramp_step))
add("--force-ramp-interval", type=float, default=get("force_ramp_interval", cls.force_ramp_interval)) add("--force-ramp-interval", type=float, default=get("force_ramp_interval", cls.force_ramp_interval))
add("--grip-settle-seconds", type=float, default=get("grip_settle_seconds", cls.grip_settle_seconds)) add("--grip-settle-seconds", type=float, default=get("grip_settle_seconds", cls.grip_settle_seconds))
+1
View File
@@ -114,6 +114,7 @@ ACTION_TEXT = {
"open-wait-stabilizing": "等待稳定基准", "open-wait-stabilizing": "等待稳定基准",
"open-wait-armed": "已就绪", "open-wait-armed": "已就绪",
"side-trigger-close": "侧边触发闭合", "side-trigger-close": "侧边触发闭合",
"closing-continue": "继续闭合",
"closing-to-grip": "闭合寻找物体", "closing-to-grip": "闭合寻找物体",
"object-detected-low-force": "检测到物体", "object-detected-low-force": "检测到物体",
"close-timeout-open": "闭合超时张开", "close-timeout-open": "闭合超时张开",
+21
View File
@@ -25,3 +25,24 @@ conda activate py311
3. 展示当前状态 state=open_wait这种 3. 展示当前状态 state=open_wait这种
4. force_pct与速度 展示 4. force_pct与速度 展示
5. 你看看还有其他什么可以展示的 5. 你看看还有其他什么可以展示的
1. 夹爪程序编写与调试
目前程序只是常驻监听单侧触发,每次触发后执行一次“闭合夹住 -> 监测变化 -> 直接张开”的流程。
## 流程
1.1. 程序启动后,夹爪先张开。
1.2. 程序等待任意一侧触觉传感器感受到法向力或切向力。
1.3. 展示时,把物体从某个侧边扫一下,触发单侧力变化。
1.4. 触发后夹爪开始闭合,你把物体移动到中间。
1.5. 闭合过程中检测到物体后,切到低力并保持当前位置。
1.6. 进入 `gripping`,先慢慢加力到基础 `HOLD_FORCE`
1.7. 进入 `hold_check` 后,根据切向力估计物体负载;切向力越大,目标夹紧力越高,并按小步进继续补力。
1.8. 自适应补力停止并稳定 `RELEASE_ARM_DELAY_SECONDS` 后,重新记录释放参考力,才开始检测人取物松开。
1.9. 后续法向力或切向力变化超过阈值,夹爪直接张开到 `OPEN_POS`
1.10. 张开后进入 `open_recover`,保持张开并等待恢复条件。
1.11. 夹爪回到 `OPEN_POS` 初始点位,或法向/切向读数都低于恢复阈值并稳定后,继续休息至少 `REARM_SECONDS`
1.12. 休息结束后才回到 `open_wait` 状态;休息期间不管有没有物体扫过,都不会闭合。
1.13. 如果达到没有夹持到物体自动闭合时会自动张开。
2. 参加展会
3. 01 02 3D展示效果探索
4. 02效果目前比较差,在优化中,但是一直没有实物都是使用视频来处理