Skip to content

Validate simulator motor targets before updating controls - #41

Open
qilinxiaoxiang wants to merge 1 commit into
pollen-robotics:developfrom
qilinxiaoxiang:codex/validate-sim-targets
Open

qilinxiaoxiang wants to merge 1 commit into
pollen-robotics:developfrom
qilinxiaoxiang:codex/validate-sim-targets

Conversation

@qilinxiaoxiang

Copy link
Copy Markdown

Body.set_targets() writes one actuator at a time. If conversion fails in a later slot, the handler returns an error but earlier motor targets have already changed. NaN and infinity are also accepted; even a valid JSON number such as 1e400 decodes to infinity in Python.

This validates all 15 wire targets before updating data.ctrl, including the mouth slot that the current model does not actuate. Targets must be a JSON array of finite numbers. Strings, booleans, nulls, nested values, and overflowing numbers are rejected. Valid targets keep the existing name-based wire mapping.

The new tests use the actual MuJoCo body model. They check unchanged controls after invalid frames, valid mapping, and a local TCP connection that receives an error and then successfully writes a valid frame. Before the fix, 31 of the first 38 cases failed.

Validation on macOS, Python 3.12, CPU:

  • uv run --with pytest pytest tests/test_body_server_targets.py -q: 39 passed.
  • uv run --with pytest pytest tests/ -q: 238 passed, 1 skipped.
  • git diff --check: passed.

No GPU, policy weights, robot hardware, or credentials are required for these tests. This does not change the protocol, joint limits, actuator physics, or training configuration.

Reject malformed and non-finite target frames atomically, including the unmapped mouth slot. Exercise invalid frames, wire mapping, and recovery on a live local TCP connection.

Assisted-by: OpenAI Codex
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