Unverified Commit 26785e42 authored by James Tigue's avatar James Tigue Committed by GitHub

Fixes pytest conversion for test_contact_sensor (#2502)

# Description

<!--
Thank you for your interest in sending a pull request. Please make sure
to check the contribution guidelines.

Link:
https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html
-->

This test cleans up some of the pytest conversion for
test_contact_sensor that was causing issues in CI.

Fixes # (issue)

<!-- As a practice, it is recommended to open an issue to have
discussions on the proposed pull request.
This makes it easier for the community to keep track of what is being
developed or added, and if a given feature
is demanded by more than one party. -->

## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

- Bug fix (non-breaking change which fixes an issue)

## Screenshots

Please attach before and after screenshots of the change if applicable.

<!--
Example:

| Before | After |
| ------ | ----- |
| _gif/png before_ | _gif/png after_ |

To upload images to a PR -- simply drag and drop an image while in edit
mode and it should upload the image directly. You can then paste that
source into the above before/after sections.
-->

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->
parent aa0e7135
......@@ -304,15 +304,14 @@ def test_cube_stack_contact_filtering(setup_simulation, device, num_envs):
assert contact_sensor.data.net_forces_w.sum().item() > 0.0
@pytest.mark.parametrize("device", "cpu")
def test_no_contact_reporting(setup_simulation, device):
def test_no_contact_reporting(setup_simulation):
"""Test that forcing the disable of contact processing results in no contact reporting.
We borrow the test :func:`test_cube_stack_contact_filtering` to test this and force disable contact processing.
"""
# TODO: This test only works on CPU. For GPU, it seems the contact processing is not disabled.
sim_dt, durations, terrains, devices, carb_settings_iface = setup_simulation
with build_simulation_context(device=device, dt=sim_dt, add_lighting=True) as sim:
with build_simulation_context(device="cpu", dt=sim_dt, add_lighting=True) as sim:
sim._app_control_on_stop_handle = None
# Instance new scene for the current terrain and contact prim.
scene_cfg = ContactSensorSceneCfg(num_envs=32, env_spacing=1.0, lazy_sensor_update=False)
......@@ -500,21 +499,21 @@ def _test_sensor_contact(
# Check the data inside the contact sensor
if mode == ContactTestMode.IN_CONTACT:
_check_prim_contact_state_times(
sensor,
0.0,
durations[idx],
expected_last_test_contact_time,
expected_last_reset_contact_time,
duration + sim_dt,
sensor=sensor,
expected_air_time=0.0,
expected_contact_time=durations[idx],
expected_last_contact_time=expected_last_test_contact_time,
expected_last_air_time=expected_last_reset_contact_time,
dt=duration + sim_dt,
)
elif mode == ContactTestMode.NON_CONTACT:
_check_prim_contact_state_times(
sensor,
durations[idx],
0.0,
expected_last_reset_contact_time,
expected_last_test_contact_time,
duration + sim_dt,
sensor=sensor,
expected_air_time=durations[idx],
expected_contact_time=0.0,
expected_last_contact_time=expected_last_reset_contact_time,
expected_last_air_time=expected_last_test_contact_time,
dt=duration + sim_dt,
)
# switch the contact mode for 1 dt step before the next contact test begins.
shape.write_root_pose_to_sim(root_pose=reset_pose)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment