Skip to content

Commit c5c174f

Browse files
committed
fix: no blocked-flash on reset, arm animates immediately while Gemma thinks
- JS applyState: reset frames skip arm.blocked/arm.attacking assignment so the red \"BLOCKED\" overlay never fires at routine start - run_safe_routine: yield reach_state (step-1 pose) before _call_gemma() so the arm starts moving toward the source immediately instead of freezing for the full Gemma inference time (~5-10 s) - inject_attack: remove unnecessary time.sleep(0.5) before Gemma call
1 parent ab8d68a commit c5c174f

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

apps/hdp-physical-hf/app.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,9 @@ def _guard_action(action: RobotAction, hdp_enabled: bool) -> dict[str, Any]:
503503
// ── apply state from Python ──
504504
function applyState(last){
505505
if (!last) return;
506-
arm.blocked = !last.approved;
507-
arm.attacking = !!last.attack;
506+
// reset frames carry no approved/attack — don't flash red/orange
507+
arm.blocked = last.reset ? false : !last.approved;
508+
arm.attacking = last.reset ? false : !!last.attack;
508509
509510
if (last.reset) {
510511
// reset to home, box stays where it was
@@ -601,12 +602,22 @@ def run_safe_routine(hdp_enabled: bool) -> Generator:
601602

602603
reset_state = json.dumps([{"reset": True}])
603604

604-
# ── Step 0: ask Gemma ──
605+
# ── Step 0: reset arm, then immediately animate toward source ──
606+
# Send reset first (arm returns home, no blocked flash)
605607
gemma_status = (
606608
f"🤖 **Gemma** (`{_GEMMA_MODEL}`) planning:\n"
607609
f"> *Pick from **{src}** → place at **{dst}***"
608610
)
609-
yield "", f"🤖 Asking Gemma 4 to plan route: {src}{dst}…", reset_state, "", gemma_status
611+
yield "", f"🤖 Asking Gemma to plan: {src}{dst}…", reset_state, "", gemma_status
612+
613+
# Immediately animate arm to step-1 reach pose so the arm starts moving
614+
# while Gemma is thinking (avoids 5-10 s frozen screen).
615+
reach_state = json.dumps([{
616+
"step": 1, "direction": direction,
617+
"approved": True, "attack": False,
618+
"zone": src, "force_n": 0.0, "velocity_ms": 0.0,
619+
}])
620+
yield "⏳ Gemma planning…", f"🤖 Arm reaching {src} while Gemma thinks…", reach_state, "", gemma_status
610621

611622
prompt = _gemma_plan_prompt(src, dst)
612623
raw_gemma = _call_gemma(prompt)
@@ -676,9 +687,8 @@ def inject_attack(hdp_enabled: bool) -> Generator:
676687
"",
677688
reset_state,
678689
"",
679-
"🤖 **Calling Gemma 4** with poisoned prompt…",
690+
"🤖 **Calling Gemma** with poisoned prompt…",
680691
)
681-
time.sleep(0.5)
682692

683693
prompt = _gemma_attack_prompt(src, dst)
684694
raw_gemma = _call_gemma(prompt, single=True)

0 commit comments

Comments
 (0)