Skip to content

Commit 6411377

Browse files
Milotrinceclaude
andcommitted
Rename _apply_counterpart_filter -> _drop_filtered_counterpart_contacts
"apply ... filter" didn't convey what the function does. It clears mask entries for contacts whose counterpart link is filtered out, matching the wording already used for this behavior elsewhere (e.g. the test docstring "drops contacts whose counterpart is filtered"). The self-describing name replaces the docstring, which is dropped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1358dea commit 6411377

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

genesis/engine/sensors/contact_force.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ def _func_link_is_filtered(filter_links_idx: qd.types.ndarray(), i_s: int, link:
3939
return is_filtered
4040

4141

42-
def _apply_counterpart_filter(is_a: torch.Tensor, is_b: torch.Tensor, link_a, link_b, shared_metadata) -> None:
43-
"""Zero out, in place, the contacts a filtered sensor should ignore. ``is_a``/``is_b`` are the per-side
44-
"this contact touches the sensor link" masks, shape ``(B, n_sensors, n_contacts)``; when the sensor is on side
45-
a its counterpart is ``link_b`` (and vice versa), so a contact is dropped when that counterpart is blacklisted.
46-
Only the filtered-sensor rows are touched, so unfiltered sensors keep the cheap masks unchanged.
47-
"""
42+
def _drop_filtered_counterpart_contacts(
43+
is_a: torch.Tensor, is_b: torch.Tensor, link_a, link_b, shared_metadata
44+
) -> None:
4845
filt = shared_metadata.filtered_sensor_idx
4946
if filt.numel() == 0:
5047
return
@@ -182,7 +179,7 @@ def _update_raw_data(cls, shared_context: None, shared_metadata: ContactSensorMe
182179

183180
is_contact_a = link_a[..., None, :] == shared_metadata.expanded_links_idx[..., None]
184181
is_contact_b = link_b[..., None, :] == shared_metadata.expanded_links_idx[..., None]
185-
_apply_counterpart_filter(is_contact_a, is_contact_b, link_a, link_b, shared_metadata)
182+
_drop_filtered_counterpart_contacts(is_contact_a, is_contact_b, link_a, link_b, shared_metadata)
186183
# Float-valued contact count per sensor (intermediate cache is float; bool projection in `_post_process`).
187184
result = (is_contact_a | is_contact_b).sum(dim=-1).to(dtype=gs.tc_float)
188185
raw_data_T[:] = result.T
@@ -312,7 +309,7 @@ def _update_raw_data(
312309
# Forces are aggregated BEFORE moving them in local frame for efficiency.
313310
force_mask_a = link_a[:, None] == shared_metadata.links_idx[None, :, None]
314311
force_mask_b = link_b[:, None] == shared_metadata.links_idx[None, :, None]
315-
_apply_counterpart_filter(force_mask_a, force_mask_b, link_a, link_b, shared_metadata)
312+
_drop_filtered_counterpart_contacts(force_mask_a, force_mask_b, link_a, link_b, shared_metadata)
316313
force_mask = force_mask_b.to(dtype=gs.tc_float) - force_mask_a.to(dtype=gs.tc_float)
317314
sensors_force = (force_mask[..., None] * force[:, None]).sum(dim=2)
318315
sensors_quat = links_quat[:, shared_metadata.links_idx]

0 commit comments

Comments
 (0)