Skip to content

feat(webui): web interface for data collection and eval with 1 kHz state recording - #351

Closed
juelg wants to merge 63 commits into
masterfrom
feat/webui-extension
Closed

juelg wants to merge 63 commits into
masterfrom
feat/webui-extension

Conversation

@juelg

@juelg juelg commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Web interface for data collection and evaluation as a new pure Python extension extensions/rcs_webui, plus the stack changes it needs: the 1 kHz robot states are forwarded through the env into the same parquet data, and a robot error ends the episode visibly.

Draft. Everything below is implemented and tested in sim / with mocks; nothing ran on hardware yet.

Done

  • fr3: control state forwarding (opt-in). FrankaConfig.record_control_states (or WrapperConfig.record_control_states). The control threads (osc, joint, zero torque) copy every franka::RobotState into a preallocated SPSC lock-free ring buffer (8192 samples, 608 B each; no allocation, no lock, no Python in the loop). FR3HW drains it once per step into info[robot]["control_states"]: one contiguous array per signal (q, dq, tau_J, tau_J_d, dtau_J, tau_ext_hat_filtered N x 7, O_F_ext_hat_K, K_F_ext_hat_K N x 6, O_T_EE N x 16 column major, timestamp (host wall clock), robot_time, control_command_success_rate, robot_mode, current_errors / last_motion_errors as bit masks, names from hw.control_state_error_names()), plus num_samples and dropped.
  • fr3: visible robot errors. A FrankaControlException (reflex) no longer gets recovered silently inside the step: the step returns truncated=True, info["robot_error"] (empty string otherwise) and the control states up to the error; recovery happens on the next reset. TeleopLoop resets on terminated / truncated.
  • sim mirror. SimControlStateWrapper records the same keys and shapes after every physics step (async control), so tests and the viewer work in sim.
  • StorageWrapper. ndim > 1 arrays in the info are stored flattened with a <key>_shape column (same convention as for the observation, the returned info is untouched); new terminated / truncated columns.
  • rcs_webui. rcs-webui collect (CLI), runner thread that owns env + Quest operator + StorageWrapper, Quest A start / B successful / Y unsuccessful (also as web buttons), every env (re)start writes a new folder with env_config.json (complete config as tagged JSON, loadable), session.json, git.json (commit, branch, untracked) and <repo>.diff; restart from the same config, the default config of another env or the config of a previous recording, with dotted-path overrides; live camera view; rcs-webui envs, rcs-webui dump-config. Only dependencies RCS already has (stdlib http server, no JS libraries).
  • Data viewer (Data tab, or rcs-webui view): episodes with label / robot error, camera playback, SVG plots of joints, gripper, TCP, actions and the controller rate signals (q, dq, tau_J, dtau_J, external torque and wrench); relabel (success in the last row, like the recorder) and delete rewrite the affected parquet files atomically, refused for the episode being recorded.
  • Config selection: the Start env panel lists default configs, *.json of --config-dir (repeatable) and configs of previous recordings, editable JSON, validate, start. Config files are {"creator", "config"} (rcs-webui dump-config); bare configs still load with --env. Snapshots store python config subclasses (Robotiq) and asset paths relative to RCS_PREFIX.
  • Eval mode (rcs-webui eval --policy ... --policy-server host:port): PolicyClient interface (connect / reset / infer / action_at / close, capability flags), selectable by name, entry point rcs_webui.policy_clients or module:Class (project clients live in their projects); VLAgents client (following examples/inference/franka.py) and a mock; runtime switch of the policy server in the page; Quest A / B / Y labelling; held trigger = human intervention; per step annotations (source, chunk id / index, query send / receive time, switch-over step, wait).
  • Real-time chunking (off by default, --rtc-delay d): the query is sent d steps before the switch-over step from a worker thread with the committed prefix and the rest of the chunk (guidance for inpainting); the loop keeps executing and switches to the newest chunk at the aligned index.
  • StorageWrapper: annotate_step(); fix: no more endless hang when the writer thread died.
  • README with setup from scratch, docs page.

Measured overhead of the state forwarding

  • ring buffer push in the 1 kHz loop: ~50 ns mean (C++ microbenchmark incl. clock call), 608 B per sample
  • drain of one 15 Hz step (67 samples) into numpy via pybind: 2.6 us median, 5.1 us p99, 40.5 kB per step in memory
  • sim (FR3, 15 Hz, 2 ms physics step, 33 samples per step, Python sampling): 0.44 -> 1.60 ms per step
  • parquet on disk: see the follow-up comment / report (compressed)

Tested

  • sim: end-to-end recording through the HTTP API (A / B / Y, restart, restart from recording / edited config), parquet content, control states shape and rate, viewer API, relabel / delete, eval with the mock server (50 ms delay, sync and RTC), runtime policy switch; full python/tests suite passes
  • unit: chunk executor (sync, RTC prefix / guidance, late answers, starvation, receding horizon)
  • not tested: the VLAgents client against a real server
  • mocks: ring buffer (order, overflow, error names), FR3HW with a fake robot (states in info, opt-in, reflex -> truncated + message, no silent recovery)
  • not tested: anything with a real FR3, real Quest, real cameras

Hardware checklist for Tobi

  • build rcs_fr3 from this branch on the robot PC (RT kernel), start rcs-webui collect --env fr3 --config fr3.json ...
  • control loop still runs without communication_constraints_violation with recording on (check control_command_success_rate)
  • info.right.control_states.num_samples is ~1000 / step rate per step, dropped stays 0, timestamps monotonic
  • a provoked reflex (push the robot hard) ends the episode: status shows the error, last row has truncated=True and robot_error; next reset recovers
  • Quest A / B / Y and the trigger teleop work through the interface, cameras appear in the page
  • env_config.json of the session restarts the same robot setup (--from-recording or the Start env panel)
  • viewer: plots and camera playback of a real episode, relabel and delete
  • eval with a real policy server, switch the server in the page, intervention with the Quest trigger

Open questions

  • 2D control states are stored flat + _shape (existing StorageWrapper convention, robust to N=0 steps) instead of list<fixed_size_list>; OK?
  • Unsuccessful (Y), robot error and aborted episodes all have success=False; robot errors are distinguishable by truncated. Do we want an explicit label column?
  • After a reflex the episode ends and the env resets (robot moves home) immediately, as in TeleopLoop. Should it instead wait for the operator?
  • The sync control path (async_control=False, motion generator) records no control states.
  • Sim mirror approximations: tau_ext = constraint torques, wrench by least squares through the jacobian, robot_mode / errors always 0.
  • Intervention only works when the env uses the Quest action space (tquat relative to the configured origin); with other action spaces the trigger is ignored in eval.
  • When python/tests and the webui sim tests run in one pytest process, the webui sim tests fail with eglMakeCurrent failed (GL context created on another thread); separately both pass. CI could run the extension tests in their own job.
  • With numpy 2.4.6 mypy reports one error in the untouched extensions/rcs_zed/tests/test_zed_extension.py (stub shape typing).

🤖 Generated with Claude Code

https://claude.ai/code/session_01L1mcETeEyCruGo6RztGybW

juelg and others added 30 commits November 15, 2026 13:29
Opt-in via FrankaConfig.record_control_states. The control threads (osc,
joint and zero torque controller) copy every robot state into a
preallocated single producer single consumer ring buffer (no allocation,
no locks, no Python in the loop). Franka.drain_control_states() returns
everything since the last call as one contiguous numpy array per signal
(N or N x D) plus num_samples and dropped. The buffer is also exposed as
hw.ControlStateBuffer for tests and mocks.
FR3HW drains the control state buffer once per step and adds it to
info["control_states"] (one array per signal with N samples since the
last step), so the 1 kHz states travel synchronously with the step and
end up in the same recording. States recorded during reset are dropped.
Nothing changes unless record_control_states is enabled.
A FrankaControlException (e.g. a reflex) used to be recovered inside the
step and returned with an empty info, so the error vanished from the
recording. Now the step returns truncated=True, keeps the robot info and
the control states up to the error and reports the message in
info["robot_error"] (empty string otherwise, so the column has a stable
type). The automatic error recovery happens on the next reset.
TeleopLoop ignored terminated/truncated, so after a robot error the loop
kept stepping a robot in error state. It now logs the reason and resets
the env and the operator, the episode ends as unsuccessful.
The StorageWrapper now stores numpy arrays with ndim > 1 inside the info
dict flattened with a "<key>_shape" column (same convention as for the
observation) instead of failing on them, without touching the info that
is returned to the caller. This makes the per step control loop states
(N x D) end up in the parquet data. terminated and truncated are stored
in their own columns so episodes that were cut short (e.g. by a reflex)
are visible in the data.
WrapperConfig.record_control_states adds SimControlStateWrapper to every
simulated robot. It samples the robot after each physics step (SimEnv
steps one physics step at a time when sub step callbacks are registered,
which is identical to sim.step(n)) and puts the samples of the env step
into info["control_states"] with the same keys and shapes as on the FR3,
so recordings, tests and the viewer work in sim. Without async_control
one sample per step is recorded.
WrapperConfig.record_control_states now switches on the 1 kHz state
recording of the FR3 as well, so the same flag works in sim and on
hardware.
New pure Python extension rcs_webui. snapshot.py serializes the complete
env creator config (dataclasses with pybind11 robot, gripper, camera and
sim configs, poses, enums, arrays) into tagged JSON that can be loaded
back into a config, supports dotted path overrides and logs the git
commit, branch, untracked files and diff of every repository in use.
The runner thread owns the env, the Quest operator and the
StorageWrapper. A starts an episode (recording), B ends it successful, Y
unsuccessful, a truncating env (robot error) ends it as unsuccessful.
Every env (re)start writes a new folder with env_config.json,
session.json, git.json and the diffs next to the parquet data. Default
configs are adapted for recording (control state forwarding, async
control at the step rate, Quest action space), configs from a file or a
previous recording are used as stored.
Standard library HTTP server with a JSON API (status, A/B/Y buttons,
instruction, env restart from the same, a default or a recorded config
with overrides, live camera images) and a static page without external
dependencies. rcs-webui collect starts env, operator and server;
rcs-webui envs and rcs-webui dump-config help to write config files.
Starts the interface on rcs/fr3 with the web buttons, records a
successful and an unsuccessful episode, checks the snapshot files, the
parquet rows (labels, steps, timestamps, control states, frames) and
restarting from a previous recording with overrides.
Fields of python subclasses of pybind11 configs (e.g. the Robotiq
gripper config with its serial number) were missing in env_config.json,
and robot model paths were stored as absolute paths of the recording
machine. Instance fields are serialized now, python constructors are
matched by signature, and paths below the RCS asset prefix are stored
relative to it.
Data tab: sessions and episodes (steps, duration, label, robot error),
camera playback over the recorded steps, SVG plots of the per step
joints, gripper, TCP position and actions and of the controller rate
signals (q, dq, tau_J, dtau_J, external torque and wrench) with a
cursor at the shown step. Episodes can be relabelled (success written
to the last row, like the recorder does) and deleted; both rewrite the
affected parquet files atomically and are refused for the episode that
is being recorded. rcs-webui view starts only the viewer.
BaseOperator.is_engaged() (default False) tells whether the human
actively commands the robot, the Quest operator returns True while an
index trigger is held. Used to detect human interventions during policy
rollouts.
If the parquet writer thread failed, the bounded queue was never
emptied and the next flush blocked forever (the env step hung). The
flush now waits with a timeout and raises the writer's exception.
annotate_step(**fields) adds fields to the annotations column of the
next recorded step, e.g. where its action came from (policy chunk and
index, query send / receive times, human intervention), so that this
provenance lives in the same parquet rows as the step.
…hunking

PolicyClient (connect / reset / infer / close, capability flags) with
ChunkRequest / ActionChunk types: chunks carry RCS env actions and the
raw actions of the server. Clients are selected by name (vlagents, mock),
by entry point (rcs_webui.policy_clients) or as module:Class, so project
specific clients live outside RCS. ChunkExecutor turns chunks into one
action per step: synchronous queries after execute_steps actions, or
real-time chunking (off by default): the next query is sent delay steps
before the switch-over step from a worker thread with the committed
prefix and the rest of the current chunk as inpainting guidance, the
loop keeps executing and switches to the newest chunk at the aligned
index. Per step provenance (chunk id and index, send / receive times,
switch-over step, wait time) is returned for recording. Includes a VLAgents
client following examples/inference/franka.py (no RTC) and a mock client
with artificial delay for tests.
The Start env panel lists the default configs of all envs, the *.json
files of the --config-dir directories and the configs of previous
recordings, shows the selected config as editable JSON, validates it
and starts the env with it (new session folder with config, git commit
and diff as before). Config files carry their env creator
({"creator": ..., "config": ...}, the output of rcs-webui dump-config),
so --config no longer needs --env.
…tions

rcs-webui eval connects to a policy server through the PolicyClient
interface (--policy, --policy-server host:port, options, actions per
chunk, RTC delay). A starts a rollout, B / Y label it as in data
collection, a held Quest trigger takes over (intervention: the policy
is paused and resumes with a fresh chunk when the trigger is released).
The policy server can be switched in the web page without restarting
the interface or the env. Every recorded step is annotated with its
source (policy, intervention, teleop) and the chunk provenance (chunk
id and index, query send / receive time, switch-over step, wait).
ChunkRequest.prefix_chunk_id and prefix_start tell which chunk and
index the prefix was cut from, so stateful servers can reuse their own
(normalized) copy of that chunk.
With RTC a chunk starts at its switch-over index (normally the delay),
so execute_steps now counts the executed actions from there. With
execute_steps = r every chunk contributes r actions and the prefix of
the next query is rows r .. r+d-1 of the current chunk, as in a
receding horizon with r replan steps.
PolicyClient.action_at(chunk, index, observation) returns the env action
of a chunk row when it is executed, with the newest observation. The
default returns the precomputed chunk.actions; clients whose actions
depend on the state at execution time (e.g. a gripper velocity
integrated against the measured width) can return raw-only chunks.
QuestOperator.close() never stopped the simpub web dashboard
(127.0.0.1:5000), which runs serve_forever in pyzlc's thread pool. At
interpreter exit the thread pool join and pyzlc's atexit shutdown waited
on it forever, so rcs-webui hung after "Disconnecting from RCSNode".
Only seen with real hardware, since the publisher is not created in sim.

- quest.py: close() shuts down the publisher web server and pyzlc
- rcs_webui cli: a second Ctrl+C/SIGTERM exits immediately (os._exit),
  previously further signals were swallowed and only kill -9 worked

Tested: QuestOperator(simulation=False) start+close exits in 2 s,
the old close() still hung after 20 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29940c9 called pyzlc.shutdown() in QuestOperator.close(). The pyzlc node
can not be initialized again in the same process (its thread pool is shut
down, the next operator crashes), so the operator could not be re-created,
e.g. on an env restart.

close() now only stops the scene publisher: the RigidObjectUpdate stream
(Streamer.running) and the web dashboard on 127.0.0.1:5000, whose
serve_forever is what blocked the interpreter exit. pyzlc's own atexit
shutdown then completes. The helper stop_publisher() is also used for the
MuJoCo publisher in sim.

Tested: hardware-mode operator start/close exits the process in 2 s;
sim -> hw -> sim -> hw operator cycles in one process (pick_place sim).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- envs.import_env_packages(): imports every submodule of packages that
  register RCS envs on import (default duobench.tasks, skipped if not
  installed); available_envs() lists every gym id with an RCSEnvCreator,
  so duobench/* shows up next to rcs/*
- infer_creator(): a config file without creator (e.g. SURF's
  droid_ai2.json, a bare env_config.json) gets the generic config driven
  creator of its type: RCSFR3MultiConfigEnvCreator for FR3 hardware, the
  new ConfigSimEnvCreator for sim (SimEnvCreator is abstract)
- normalize_config(): hardware robot configs get robot_platform=HARDWARE;
  the C++ default SIMULATION is never read on hardware but confusing
- describe(): platform, creator, task, robots, cameras, rate, control mode
- configs.changed_paths(): dotted paths of the changed fields between two
  serialized configs (provenance of edits in the interface)
- catalog groups the defaults into hardware and simulation, skips missing
  config directories

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The interface no longer starts an env on launch and takes no env options on
the command line:

- `rcs-webui serve --data-root ... [--host] [--port]` replaces `collect`
  and `eval` with their --env/--config/--set/--quest-addr/--policy... options
- settings (mode, instruction, operator, Quest address, swap left/right,
  MuJoCo viewer, default config rate, config directories, env packages,
  policy server, last started config) are edited in the page and stored in
  <data-root>/.rcs_webui/settings.json; mode, operator, Quest and viewer
  settings are only changeable while no env runs (409 otherwise)
- the runner starts in state "idle"; POST /api/restart {config, base_id}
  starts the env, POST /api/stop_env closes it
- session.json stores the picked catalog entry (source.base) and the
  changed fields (source.changed)
- the catalog offers the running env's complete config ("running:")
- the Quest operator is created with every env start and closed with the
  env: on hardware with the empty scene publisher, in sim with a
  MujocoPublisher of the new sim (Quest teleop in sim did not work before:
  the operator was created without publisher and pyzlc was never started)
- an operator failure leaves the env running (web buttons still work) and
  is shown in the status

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juelg and others added 29 commits November 15, 2026 16:48
…ceeds

A task that ends the episode itself (e.g. duobench's TaskStageWrapper:
terminated=True with info["success"]=True when the red cube rests on the
green one) was handled like a robot error: _end_episode(False,
"truncated"). The episode was stored with success=False in every row and
counted as "ended by the robot" with an error in the status. Seen in the
first sim session 2026-11-15_16-23-54_PickPlaceEnvConfig_collect: 4 of 5
episodes have stage 4 / info.success True but success False.

Now terminated without truncation, without robot error and with
info["success"] ends the episode like B (storage.success(), counted as
successful). Everything else that terminates or truncates stays
unsuccessful. StorageWrapper's success_from_env is not used: it sets a
sticky flag on any step, so a later Y could not undo it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
…pisode

New setting auto_reset (default on, checkbox next to "swap Quest left /
right", can be changed while the env runs):

- on: as before, the env's end of episode ends and stores it and resets
  the env (task success: successful, other terminations / truncations:
  unsuccessful)
- off: the end is only reported (status "env reports task success /
  truncated / terminated", one event) and the episode keeps recording
  until the operator presses B or Y; the env is not reset. Robot errors
  (info.<robot>.robot_error) still end the episode and reset the env,
  the robot can not continue before the error recovery of the reset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
New extensible str enum rcs_webui.policy.Controller, recorded per step
as annotations.controller (its string value, so new members do not
change the parquet schema):

- human: teleop and every step of a human intervention
- learned_policy: trained policies (default of PolicyClient, vlagents)
- scripted_policy: hand written controllers (the mock client)
- agent: agents that act through tools / reasoning
- none: nobody commands, the hold action keeps the robot in place
  (eval without running policy and without trigger)

A policy client declares its kind with the class attribute `controller`;
a kind that the enum does not know yet is recorded as given. This makes
interventions filterable (controller == "human" in an eval episode).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
Before, releasing the Quest trigger during an eval rollout handed the
robot straight back to the policy. Now the intervention lasts until the
operator presses X:

- trigger held: the operator moves the robot (controller "human")
- trigger released: the robot holds the pose the operator left it in,
  still recorded as human / intervention, the status asks for X
- X (Quest left controller, new TeleopCommands.resume, or the new web
  button, shown in eval): the policy continues with a fresh chunk from
  the current state; ignored with a message while the trigger is held
  or when there is no intervention

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
…viewer

- episode view: a "controlled by" timeline above the plots, one colored
  run per controller (human orange, learned policy blue, scripted policy
  aqua, agent violet, none gray), hatched where the step was an
  intervention, step range and time in the hover title, synced cursor
- episode list: "controlled by" column (share of steps per controller)
  and the number of intervention steps; filter for episodes with /
  without intervention, successful, unsuccessful
- data.py: list_episodes counts controllers and intervention steps,
  episode_signals returns the per step controller and intervention flag;
  recordings without annotations.controller are derived from
  annotations.source (teleop/intervention -> human, policy ->
  learned_policy, idle -> none), without annotations "unknown"

Colors validated (dataviz palette checks, light and dark).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
… config

git.json only covered RCS, its extensions and the working directory, so
a task from another package (e.g. duobench.tasks.pick_place) was not
reproducible from a recording. write_snapshot now also logs the package
of the env creator and of every class / enum in the serialized config
(commit, branch, remote, untracked file names, <package>.diff), and the
installed version of each package. A package outside a git checkout
(installed from PyPI) is logged with its version and path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
After a sim env the MuJoCo scene stayed visible in the Quest when the
real robot was started next. The Quest app only deletes a scene with the
name of the scene that is spawned next, and the hardware placeholder
scene is called "RCS", so the old scene was never removed.
stop_publisher() now:

- deletes the publisher's scene on every Quest it sent it to
  (DeleteSimScene with its scene name)
- makes the publisher ignore Quest apps that (re)connect: its device
  search loop keeps running on the shared pyzlc event loop and would
  send the old scene again
- stops the scene stream and the web dashboard as before

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
_close_env only closed the StorageWrapper, which flushes the recording
but does not close the env below it. A sim env kept its MuJoCo viewer
window open after switching to the real robot, and on hardware the
robot, gripper and camera connections stayed open on restart (a second
start in the same process would find the cameras busy). Now the env
below the StorageWrapper is closed and, for sim, the viewer
(Sim.close_gui, which env.close does not call).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
The config JSON editor and its diff bar are in a <details> section that
is closed on every page load. The config dropdown, the summary chips,
the validate result and start / stop stay visible; the collapsed header
shows the number of changes against the picked config, so edits are not
hidden.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
With async control, robotiq2f 0.2.0 reads the gripper status in a
`while True` thread that has no stop flag. RobotiQ2F85Gripper.close()
closed the serial port under it, so the thread crashed with
termios.error: (9, 'Bad file descriptor') as soon as the env was closed
(first seen when the RCS web interface stopped the DROID env).

close() now ends that thread first (it looks read_status_sync up on the
instance every loop; shadowing it with a function that raises SystemExit
stops it silently after the current read), joins it and closes the port
under the library's client lock. To be replaced by a stop flag in
robotiq2f (RobotControlStack/robotiq2f).

Test without hardware: the library's own status loop against a fake
port; it reproduces the crash without the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
When the env was stopped, the page re-rendered its camera images and the
browser aborted the pending /api/live/<cam>.jpg requests. The server
logged each as "request failed" with a BrokenPipeError traceback, then
failed again writing the 500 answer, so one env stop printed dozens of
interleaved tracebacks. send_bytes now treats BrokenPipeError /
ConnectionResetError as the client being gone (debug log, connection
closed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
…ollers

libfranka compensates gravity in torque control but not Coriolis /
centrifugal torques; its impedance examples add model.coriolis() to the
commanded torque. Neither RCS controller did: joint_controller() sent
only Kp*e - Kd*dq, and osc() computed the Coriolis vector but never used
it. Without it, fast motions are tracked worse (the error is
proportional to dq^2) and part of the PD effort is spent fighting
velocity-dependent torques.

Both controllers now add the Coriolis vector before the joint-limit
guard (so that guard still blocks torque towards a limit) and before
rate limiting and the torque limit clamp.

Compiled (incremental build); not yet run on the robot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
The editor keeps the text of the picked config from when it was loaded.
If the file changes on disk afterwards (here: torque_limit raised in
droid_ai2.json while the page was open), "start env" sent the old text,
the gutter (comparing against the old text) showed no change, and the
server recorded the difference to the new file as an edit
(source.changed: torque_limit = 5). Two sessions ran with the old limits
without the operator noticing.

Before starting, the page now reloads the picked entry and compares it
with the editor's base: unedited -> the new version is loaded and shown,
nothing is started; edited -> the operator confirms starting the edits
that are based on the old version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
…mits

osc() and joint_controller() stop pushing towards a joint limit within
0.1 rad of it (OSC also adds an avoidance potential from 0.25 rad), but
both used hard coded Panda limits instead of FrankaConfig::joint_limits.
On the FR3 that blocks reachable configurations: e.g. the elbow (joint 4,
FR3 config limit -3.077) was not driven below -2.97, which showed in the
first DROID recording as a 5.6 cm tracking offset for 4 s while the
elbow sat in that band (ep d0b1071c, 2026-11-15_17-23-02).

Both controllers now take the lower / upper limits from the config.
Configs without explicit joint_limits get the conservative FrankaConfig
default. Compiled, not yet run on the robot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
… mode

robotiq2f 0.2.0's async mode only reads the status in a thread;
go_to() still writes the Modbus registers in the calling thread and
waits for the gripper's reply. GripperWrapper.action() calls it in the
env step whenever the (binary) command changes, so every open / close
blocked the step; in the DROID recordings 2 of 9 opens and 1 close
stalled the 15 Hz loop for 80-197 ms.

With async_control, set_normalized_width() now only stores the target;
a writer thread sends it with go_to(). Commands that arrive while one
is being written replace each other, only the newest is sent. close()
stops the writer before the status thread and the serial port.
Without async_control nothing changes (go_to blocks until the motion is
done, as before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
For Quest teleop the converter needs to drop operator repositioning
(trigger released, robot still) without inferring it from poses. Every
recorded step now has, per robot:

- annotations.engaged.<robot>: the operator commanded that robot in
  this step (Quest trigger held; new BaseOperator.engaged_controllers(),
  per controller = robot name, QuestOperator returns its trigger state)
- annotations.joint_speed.<robot>: max joint speed over the step (rad/s,
  from the observations before and after the step)
- annotations.moving.<robot>: joint_speed > 0.0075 rad/s; at rest the
  FR3 reads <= 0.0018 rad/s, teleoperated 95 % of steps are > 0.024 rad/s

Motion is only known after the step, so StorageWrapper gets
annotate_recorded_step(), which adds fields to the row just recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
The per robot annotations.engaged / annotations.moving (b2851d8) were
recorded but not shown. The "controlled by" timeline of an episode now
has a lane per robot for "trigger held" and "moving" under the
controller row, and the legend counts the steps with the trigger
released and the robot still (controller repositioning). Moving without
trigger shows external pushes, e.g. the operator moving the arm by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
HardwareCameraSet.close() set running=False and closed the cameras
before joining the polling thread, so a poll in progress hit a closed
camera. With the ZED cameras this printed
`KeyError: 'front_rgb'` (rcs_zed poll_frame) every time the RCS web
interface stopped the env. close() now stops and joins the polling
thread first, then closes the cameras and the video writers.

Test with a fake camera that fails like rcs_zed after close; it fails
reliably on the old order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
LinearPoseTrajInterpolator and LinearJointPositionTrajInterpolator start
every new segment at the previous goal. When a new goal arrives before
the previous segment is finished (normal jitter of the 15 Hz policy
loop), the reference jumps from where it is to that goal in one 1 kHz
tick. Simulated at 1 m/s with one goal 5 ms early: a 5.7 mm reference
step within 1 ms (old) vs at most 1.1 mm (new, smooth). These steps hit
the OSC / joint impedance controller as velocity spikes, felt as jerks
during fast teleoperation.

reset() now starts the new segment at the current reference
(last_p_t_ / last_q_t_) if next_step() ran since the previous reset.
The first goal still starts at the measured state.

The FR3 build includes the installed copy of this header: reinstall the
RCS core before rcs_fr3. Not yet run on the robot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
StorageWrapper.consolidate() deleted the data directory before renaming
the new one (a crash in between lost the recording), wrote one
unbounded file and read the source files in arbitrary order.

- files of about 512 MB with row groups of about 128 MB, sized from the
  measured bytes per row (image heavy rows: ~190 kB each)
- source files are read in recording order (first timestamp), so an
  episode stays contiguous; preserve_order on write
- the schema is unified over all files
- swap: write next to the directory, verify the row count, move the old
  directory aside, rename, then delete the old one; on any error the
  original files stay
- returns a summary; still not called from close(), the caller decides
  when (it must not run while the directory is being written)

Checked on a copy of a 1656-row DROID session: 58 -> 3 files with
100 MB targets, content identical, episodes contiguous, 0.8 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
When an env is stopped or restarted, its session's small batch files are
merged into large parquet files (StorageWrapper.consolidate) in a
background thread, so starting the next env is not delayed. The status
lists the sessions being consolidated, relabel / delete on such a
session answer 409 until it is done, and shutting the interface down
waits for a running consolidation (a second Ctrl+C exits at once; the
original files are kept). Setting consolidate_on_stop (default on,
checkbox in the settings).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
Teleoperating close to the workspace limits can trigger a reflex (e.g.
joint_velocity_violation near the elbow limit) that so far always ended
the episode. New setting on_robot_error:

- end (default, as before): the episode ends as unsuccessful, env reset
- recover: FR3HW.recover() (new; libfranka automatic error recovery and
  clearing the background error) clears the error, the robot stays
  where it stopped and the episode keeps recording. The error row keeps
  truncated=True and info.<robot>.robot_error. The Quest origin is
  reset, so the robot does not jump to the current hand pose; the
  operator re-presses the trigger. In eval the policy gets a fresh
  chunk. If recovery fails the episode ends as before.

Tested in sim with an injected error (both modes); recovery on the FR3
itself not yet run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
FR3HW.recover() also called hw.Franka.clear_background_error(), which is
not exposed to Python, so every recovery on the robot failed with an
AttributeError and the web interface fell back to ending the episode
(first hardware test of "recover and continue", 2026-11-15 18:41).

The call is not needed: Franka::check_for_background_errors() already
loads and clears the stored control-thread exception (and stops the
control thread) when it raises it in the step; after
automatic_error_recovery() the next command starts the controller fresh.

New test checks recover() against the compiled binding
(mock.create_autospec(hw.Franka)); it fails on the old code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
After consolidation a camera frame took ~53 ms to serve (a single-row
read decodes the whole row group of the image column, ~130 MB for 721
rows), two cameras per step exceeded the 67 ms step, the player changed
img.src before the frames arrived and the browser aborted every request:
nothing was shown while playing.

- data.frame() reads all frames of an (episode, camera) in one pass and
  keeps the last 4 in a cache keyed by the session's files (name, mtime,
  size), so relabel / delete / consolidation invalidate it
- the player follows the recording time but only switches images after
  the previous ones loaded, skipping frames if loading falls behind
- switching the session closes the open episode (playback kept
  requesting frames of the previous session's episode: 404)

Checked in Chrome on a consolidated and a batch-file session: real-time
playback, 0 aborted requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
…r is held

reset_operator_state() set the controller offset to identity; the offset
is only taken again on a trigger *press*. With the trigger still held
after a reset (e.g. after a recovered reflex), the action was the
absolute Quest controller pose relative to the robot's origin: in the
DROID recording 2026-11-15_19-01-11 it jumped from 0 to
(-23, +50, +107) cm in one step, the robot lunged (clipped to 0.5 m) and
ran into the next reflex, repeatedly, until the trigger was released.

After a reset the next packet with the trigger held now takes the
offset from the current controller pose, like a fresh press.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
… a fresh trigger press

After a recovered robot error or an env reset, a robot whose trigger is
still held ignores the operator (hold action) until that trigger was
released once; the next press starts following from where the robot
is. The status asks to release and re-press. annotations.engaged is
false while the operator is ignored, so these steps are not counted as
operated.

Sim test: trigger held through a simulated reflex, recovery, no motion
while still held, motion again after release and press.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
Both torque controllers cut every torque component towards a joint limit
within a hard coded 0.1 rad (OSC: plus a nullspace potential within
0.25 rad). On the DROID setup this made the area close to the base
unreachable by teleoperation: pushed by hand the arm placed a cube at
x=0.297 m, z=0.033 m with the elbow (J4) 0.082 rad from its limit, i.e.
inside the cut-off, so the controller could never get there and the
operator felt the arm push back.

New FrankaConfig fields (per joint, defaults = previous behaviour):
- joint_limit_stop_margin (0.1): no torque towards the limit within it
- joint_limit_avoid_margin (0.25): OSC nullspace potential band, and the
  band in which the velocity towards the limit is braked
- joint_limit_damping (0, off): braking gain in Nm s/rad, reached at the
  stop margin, growing linearly over the band; it slows a fast approach
  so a smaller stop margin does not end in a joint_velocity_violation
  reflex. Braking and torque away from the limit are never cut.

Shared JointLimitGuardFn for OSC and joint controller. Standalone check
of the function: damping 0 reproduces the old cut-off exactly; motion
away from a limit is not braked. Compiled, not yet run on the robot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
…Space

With RelativeTo.CONFIGURED_ORIGIN the action is limited against the
previous action (_last_action), which is relative to the previous
origin. set_origin / set_origin_to_current (e.g. on every Quest trigger
press) did not reset it, so with a small max_mov the first action after
a new origin was clipped towards the stale offset: the target jumped in
the direction of the old offset and walked back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
…pose

New config field max_step_movement (SimEnvCreatorConfig,
FR3HardwareEnvCreatorConfig, FR3MultiHardwareEnvCreatorConfig; default
None = unchanged). With a relative action space it stacks
LimitedAbsoluteAction *below* RelativeActionSpace: the relative wrapper
turns the action (e.g. the Quest offset from the trigger-press origin)
into an absolute target, LimitedAbsoluteAction then clips that target to
max_step_movement from the robot's measured pose. With (0.075, 0.15)
this is DROID's per-step limit (7.5 cm / 0.15 rad, 1.1 m/s at 15 Hz):
fast hand motions no longer drive the robot at 1-1.5 m/s with large
tracking errors, and the executed target is recorded as
info.<robot>.limited_absolute_action next to the unclipped
absolute_action. max_relative_movement keeps bounding the action
relative to the origin / last step.

Sim tests: the target stays within 7.5 cm of the measured pose for a
30 cm hand offset; small offsets are followed exactly; None changes
nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1mcERLGSJX4bAVtyhC3Rg
@juelg juelg closed this Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant