[FEATURE] Add filter_link_idx to ContactForceSensor (#2771)#2856
[FEATURE] Add filter_link_idx to ContactForceSensor (#2771)#2856yeezhouyi wants to merge 3 commits into
Conversation
…-AI#2771) Adds `filter_link_idx` parameter to `gs.sensors.ContactForce`, mirroring the existing `ContactSensor.filter_link_idx`. Contacts whose counterpart link is in the filter list are excluded from the reported force. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 353a252a23
ℹ️ 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".
| force_mask_b = link_b[:, None] == shared_metadata.links_idx[None, :, None] | ||
| force_mask = force_mask_b.to(dtype=gs.tc_float) - force_mask_a.to(dtype=gs.tc_float) | ||
| # Apply filter_link_idx: zero out contacts where the counterpart link is in the filter list. | ||
| if shared_metadata.filtered_sensor_idx.numel() > 0: |
There was a problem hiding this comment.
Apply contact-force filters outside zerocopy
When GS_ENABLE_ZEROCOPY=0 or zero-copy is unsupported for the selected backend/device, this new filter is never applied: the else branch still calls _kernel_get_contacts_forces with only links_idx, so filter_link_idx is accepted by options/build but contact forces from filtered counterpart links are still included. Users running those configurations will get different sensor readings for the same ContactForce(filter_link_idx=...) setup.
Useful? React with 👍 / 👎.
…nesis-Embodied-AI#2771) The filter_link_idx feature was only implemented in the zerocopy (PyTorch) path. The quadrants kernel _kernel_get_contacts_forces ignored the filter, so users with GS_ENABLE_ZEROCOPY=0 or backends without zerocopy support would get different sensor readings for the same ContactForce setup. Fix by adding filter_links_idx parameter to the kernel and checking the filter before accumulating forces for each contact-sensor pair. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…th (Genesis-Embodied-AI#2771) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
filter_link_idxparameter togs.sensors.ContactForce, mirroring the existingContactSensor.filter_link_idxfeature from [FEATURE] Addhistory_lengthto Sensors #2655.Implementation
genesis/options/sensors/options.py: Addedfilter_link_idx: OptionalIArrayTypefield toContactForceoptions class with scene validation.genesis/engine/sensors/contact_force.py: Addedfilter_links_idxandfiltered_sensor_idxmetadata tensors; processing logic in the zero-copy_update_raw_datapath.Test plan
pytest tests/test_rigid_sensors.py -x -vtest_contact_sensors_gravity_force[0]failure is pre-existing onmain(int64 dtype issue, unrelated to these changes).