Skip to content

Record each ZED camera's read-back exposure, gain and white balance per episode - #741

Open
v-positronic wants to merge 1 commit into
mainfrom
record-camera-state
Open

Record each ZED camera's read-back exposure, gain and white balance per episode#741
v-positronic wants to merge 1 commit into
mainfrom
record-camera-state

Conversation

@v-positronic

Copy link
Copy Markdown
Collaborator

Implements Positronic-Robotics/internal#1298.

The frames of an episode are kept, so any pixel statistic can be computed later. The exposure time, the gain and the white-balance temperature that the camera's automatic control chose are lost when the episode ends. This change records them.

What changes

  • SLCamera (drivers/camera/zed.py) reads the values back from the SDK with get_camera_settings once per state_period_sec (default 1 s) and emits them on a new state signal. The values are what the camera runs at, not the configured set points. The two auto_* flags record whether the values beside them are the camera's own choice. A setting the SDK refuses is left out.
  • Embodiment gains a recorded field: signals the recorder writes and the policy never reads. wire._recorder records them.
  • The DROID embodiment (cfg/embodiment.py) lists each camera's state there. An episode carries five scalar signals per camera: camera_state.<camera>.exposure, .gain, .white_balance_temperature, .auto_exposure, .auto_white_balance (keys.camera_state, Serializers.camera_state).

How the three readings of the ask land

  • Start: the recorder's opening turn writes the value each camera holds, so the first sample is the state at episode start.
  • During: one sample per state_period_sec.
  • End: the last sample before STOP, within one period of the end. No extra read is made at STOP.

Left out on purpose

  • The YAM embodiments keep no recorded entry. The ZED X One is opened as sl.CameraOne, and I did not verify its get_camera_settings on a rig.
  • The rig console (platform rollouts/console) needs only the positronic pin moved; the report reads nothing from these signals yet.

Tests

  • drivers/camera/tests/test_zed.py reads the state against a fake camera, with a pyzed stand-in installed by the new conftest.py where the SDK is absent.
  • policy/tests/test_harness.py: a recorded signal reaches the recorder under its own name and no harness observation.
  • Ran: positronic/policy/tests/test_harness.py, test_golden_pipeline.py, dataset/tests/test_ds_writer_agent.py, drivers/camera/tests — 115 passed.

The rules check was skipped for this first pass; it is due before merge.

…er episode

The frames of an episode are kept, so any pixel statistic can be computed later. The
exposure time, the gain and the white-balance temperature that the camera's automatic
control chose are lost when the episode ends. This change records them.

`SLCamera` reads the values back from the SDK once per `state_period_sec` (default 1 s)
and emits them on a new `state` signal. The values come from `get_camera_settings`, so
they are what the camera runs at, not the configured set points. The two `auto_*` flags
say whether the values beside them are the camera's own choice.

`Embodiment` gains `recorded`: signals the recorder writes and the policy never reads.
The DROID embodiment lists each camera's state there, so an episode carries
`camera_state.<camera>.exposure`, `.gain`, `.white_balance_temperature`, `.auto_exposure`
and `.auto_white_balance` as scalar signals. The recorder's opening turn writes the value
each camera holds at episode start; the samples during the episode follow at the period.

Ticket: Positronic-Robotics/internal#1298 #refs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 963978071c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

'exposure': 'EXPOSURE',
'gain': 'GAIN',
'white_balance_temperature': 'WHITEBALANCE_TEMPERATURE',
'auto_exposure': 'AEC_AGC',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Name the combined exposure/gain flag accurately

Rule misleading-name violated:
auto_exposure records the SDK's combined AEC_AGC setting, so datasets hide that this flag also determines whether the recorded gain is automatic; name the signal auto_exposure_gain (or otherwise include both concepts) and update the expected dataset key.

AGENTS.md reference: AGENTS.md:L7-L8

Useful? React with 👍 / 👎.

Comment on lines +20 to +25
CAMERA_STATE_SETTINGS = {
'exposure': 'EXPOSURE',
'gain': 'GAIN',
'white_balance_temperature': 'WHITEBALANCE_TEMPERATURE',
'auto_exposure': 'AEC_AGC',
'auto_white_balance': 'WHITEBALANCE_AUTO',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Store the SDK settings as enum members

Rule primitive-type violated:
CAMERA_STATE_SETTINGS represents the closed sl.VIDEO_SETTINGS domain as strings and converts every value with getattr; store the enum members directly in the mapping and pass them to get_camera_settings, updating the fake-backed tests accordingly.

AGENTS.md reference: AGENTS.md:L7-L8

Useful? React with 👍 / 👎.

Comment on lines +183 to +185
if clock.now() >= next_state_read:
self.state.emit(read_camera_state(zed))
next_state_read = clock.now() + self._state_period_sec

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the complexity suppression from the touched loop

Rule grandfathered-violation violated:
The new state-read conditional adds another branch inside SLCamera.run, which is already hidden by the enclosing # noqa: C901; extract the state polling and enough camera-loop work into focused helpers so run passes the complexity check and the suppression can be removed.

AGENTS.md reference: AGENTS.md:L7-L8

Useful? React with 👍 / 👎.

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