Skip to content

policy_client: PolicyClient bridge, Face adapters, inference loop#253

Open
shantanuparab-tr wants to merge 4 commits into
06-15-policy-client-04-transportsfrom
06-15-policy-client-05-policy-client
Open

policy_client: PolicyClient bridge, Face adapters, inference loop#253
shantanuparab-tr wants to merge 4 commits into
06-15-policy-client-04-transportsfrom
06-15-policy-client-05-policy-client

Conversation

@shantanuparab-tr

@shantanuparab-tr shantanuparab-tr commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds PolicyClient — the hardware/observer bridge that packs neutral Observations, drives one PolicyTransport over the async push/poll contract, and presents per-arm action slices through Face adapters to the existing teleop machinery. This is the chunk-timing core of the subsystem.

Stack: PolicyClient stack, based on #248. Review bottom-up (#252 → here).

Changes

  • In include/trossen_sdk/hw/policy/policy_client.hpp + src/hw/policy/policy_client.cpp: PolicyClient (multi-inherits HardwareComponent + ObserverBase) and its per-arm Face. Implements the inference loop and its timing model:
    • timestep clock (⌊(now − epoch)·rate⌋) stamped on every observation and paired with the chunk's base_timestep on the return path;
    • drain-threshold θ firing gate — at θ=0 it packs at chunk exhaustion (openpi cadence, end-of-chunk pose); at θ>0 it fires early to overlap inference with playback;
    • freshness barrier so every observation snapshot is co-temporal (bounds cross-camera skew);
    • must_go starvation flag for queueing servers;
    • hold-last-action under any failure (Face::read() never throws), plus per-arm EMA output smoothing.
  • In tests/test_policy_client.cpp + tests/CMakeLists.txt: drives the client against a FakeTransport (the two-arg constructor) — chunk apply/publish, hold-last-action, pause/resume, width-mismatch rejection.
  • In cmake/policy_client.cmake: add policy_client.cpp to the gated sources.

Test Plan

Breaking Changes

None. New gated sources behind TROSSEN_SDK_ENABLE_POLICY_CLIENT (default OFF).

Related

Based on #248. Stacked on #252; followed by #254#255.

shantanuparab-tr commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-05-policy-client branch from 6f2f314 to e213588 Compare June 15, 2026 16:56
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-04-transports branch 2 times, most recently from 26b0e67 to 1485f2f Compare June 15, 2026 18:45
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-05-policy-client branch from e213588 to 30f15ff Compare June 15, 2026 18:45
@shantanuparab-tr shantanuparab-tr added the enhancement New feature or request label Jun 15, 2026 — with Graphite App
@shantanuparab-tr shantanuparab-tr self-assigned this Jun 15, 2026
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-04-transports branch from 1485f2f to f781714 Compare June 16, 2026 21:51
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-05-policy-client branch from 30f15ff to f34359c Compare June 16, 2026 21:51
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-04-transports branch from f781714 to b456b0e Compare June 16, 2026 21:58
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-05-policy-client branch from f34359c to 7673339 Compare June 16, 2026 21:59
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-04-transports branch from b456b0e to cc2b35e Compare July 16, 2026 15:12
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-05-policy-client branch from 7673339 to 74ce303 Compare July 16, 2026 15:12
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-04-transports branch from cc2b35e to b167d44 Compare July 16, 2026 15:41
shantanuparab-tr added a commit that referenced this pull request Jul 16, 2026
Replace the non-ASCII theta symbol with ASCII across the PolicyClient header,
implementation, and tests, matching the rest of the stack (Copilot portability
comment).
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-05-policy-client branch from 74ce303 to 7d32137 Compare July 16, 2026 15:41
shantanuparab-tr added a commit that referenced this pull request Jul 16, 2026
Replace the non-ASCII theta symbol with ASCII across the PolicyClient header,
implementation, and tests, matching the rest of the stack (Copilot portability
comment).
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-05-policy-client branch from 7d32137 to 42c5dc0 Compare July 16, 2026 17:13
shantanuparab-tr added a commit that referenced this pull request Jul 16, 2026
Replace the non-ASCII theta symbol with ASCII across the PolicyClient header,
implementation, and tests, matching the rest of the stack (Copilot portability
comment).
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-05-policy-client branch from 42c5dc0 to 3d44957 Compare July 16, 2026 17:27
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-04-transports branch from e160d6b to cf93349 Compare July 17, 2026 00:21
shantanuparab-tr added a commit that referenced this pull request Jul 17, 2026
Replace the non-ASCII theta symbol with ASCII across the PolicyClient header,
implementation, and tests, matching the rest of the stack (Copilot portability
comment).
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-05-policy-client branch from 3d44957 to 1664d6a Compare July 17, 2026 00:22
The hardware/observer bridge that packs neutral Observations, drives one
transport via the async push/poll contract, and presents per-arm action
slices through Face adapters. Implements the chunk-timing core: timestep
clock, drain-threshold theta firing, must_go starvation flag, freshness
barrier, and hold-last-action under any failure.
…he arm

Safety hardening on the untrusted-server -> physical-motion path:
- Reject any chunk containing NaN/Inf before it commands the arm; NaN
  defeats naive downstream clamps, so an unchecked value became
  uncontrolled motion. Hold-last on rejection, with an ongoing (not
  warn-once) log (PR253-F1).
- Stop a single non-finite row from permanently poisoning the per-arm
  EMA filter (PR253-F2).
- Add inference_timeout_ms so a half-open server that never returns a
  chunk can no longer silently freeze the arm forever (PR253-F3).
- Bound a far-future server base_timestep in the overlap path (PR253-F4).
- Fix a Face use-after-free: Face now holds shared state, not a raw
  back-pointer to the client, so a teleop consumer outliving the client
  degrades to hold-last instead of dereferencing freed memory (PR253-F5).
- Derive image channels from the Mat, not the encoding string, fixing a
  heap over-read on a mono8 record; convert to 3-channel RGB (PR253-F6).
- Make missing-camera behavior uniform regardless of resize (PR253-F7).
- read() failure now holds last, not a drive-to-zero-pose (PR253-F9).
- Correct the exhaust-target comment (PR253-F8); drop ADR/section refs
  in favor of inline facts (PR253-F10).

Also define ActiveHardwareRegistry::unregister here (with tests), where
its callers live, so this branch compiles standalone (PR254-F5).
…pass-2)

Pass-2 review noted an inconsistency: a configured camera with no resize
that never delivers a frame makes pack_observation_ return nullopt every
cycle (inference stalls forever), yet it was logged warn_once_ - the
weakest logging for the least-recoverable failure, contradicting the
throttled ongoing logging used for non-finite rejects. Switch it to
warn_throttled_ so a frozen arm keeps surfacing the cause. Also document
inline why the θ=0 consume-fully path needs no base_timestep guard.
Replace the non-ASCII theta symbol with ASCII across the PolicyClient header,
implementation, and tests, matching the rest of the stack (Copilot portability
comment).
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-04-transports branch from cf93349 to d6b2d74 Compare July 17, 2026 14:17
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-05-policy-client branch from 1664d6a to 3e64359 Compare July 17, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant