Skip to content

Adds friction force reporting to ContactSensor - #3563

Merged
kellyguo11 merged 40 commits into
isaac-sim:mainfrom
gattra-rai:friction-forces
Dec 10, 2025
Merged

kellyguo11 merged 40 commits into
isaac-sim:mainfrom
gattra-rai:friction-forces

Conversation

@gattra-rai

@gattra-rai gattra-rai commented Sep 25, 2025 •

Copy link
Copy Markdown
Collaborator

Description

This PR extends the ContactSensor class to expose aggregated friction forces for each filtered body. It uses the same vectorized approach used for contact_points.

Concretely, this change introduces:

  • ContactSensorCfg.track_friction_forces toggle to turn on friction tracking
  • ContactSensorData.friction_forces_w where the sum of friction forces for each filtered body are stored

Fixes #2074, #2064

Performance

Results of check_contact_sensor.py with track_friction_data = False:

avg dt real-time 0.017448579105403043
avg dt real-time 0.017589360827958443
avg dt real-time 0.016146250123070787

Results of check_contact_sensor.py with track_friction_data = True:

avg dt real-time 0.01818224351439858
avg dt real-time 0.017720674386015163
avg dt real-time 0.01777262271923246

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Sep 25, 2025
@gattra-rai
gattra-rai marked this pull request as ready for review September 26, 2025 13:44

@jtigue-bdai jtigue-bdai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good just some docstring stuff and a slight augmentation of the test. Thanks @gattra-rai

@jtigue-bdai jtigue-bdai linked an issue Sep 26, 2025 that may be closed by this pull request
@Mayankm96 Mayankm96 moved this to In review in Isaac Lab Oct 10, 2025
@Mayankm96 Mayankm96 moved this from In review to In progress in Isaac Lab Oct 10, 2025
@Mayankm96 Mayankm96 added the enhancement New feature or request label Oct 13, 2025

@ooctipus ooctipus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, I like how you refactor and docstring the unpack

@ooctipus

Copy link
Copy Markdown
Collaborator

I am curious how do you use the friction force for your learning setup, would love to learn how you guys are using it : ))

Comment on lines +53 to +56
* If the :attr:`ContactSensorCfg.track_friction_forces` is False, then this quantity is None.
* If the :attr:`ContactSensorCfg.filter_prim_paths_expr` is empty, then this quantity is an empty tensor.
* If the :attr:`ContactSensorCfg.max_contact_data_per_prim` is not specified or less than 1, then this quantity
will not be calculated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These three conditions are mentioned but in the code, the checks are only performed when track_friction_forces are provided. Is this intentional? Do we handle the cases where the configuration is provided incorrectly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also this is not the net contact forces, right? Just making sure.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i've added a validation check per gremlin's recommendation, in which a value error is raised if track_friction_forces = True but either filter_prim_paths_expr = None | [] or max_contact_data_per_prim = None | < 1

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

and yes this is not the net contact forces

Comment on lines +444 to +445
expected_friction, _, _, _ = scene["contact_sensor"].contact_physx_view.get_friction_data(dt=sim_dt)
reported_friction = scene["contact_sensor"].data.friction_forces_w[0, 0, :]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think instead of comparing the two to the same PhysX buffers, it would make more sense to compare the physical realism of this. For example, if the cube is on a ground with friction of coefficient as 1 and we add a push velocity, then the friction force is mu * Mg.

@gattra-rai gattra-rai Oct 22, 2025 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

my thinking was that we shouldn't be testing the underlying functionality of the physx API, and instead just test that the friction force reporting code is doing what is intended, which is to provide the unpacked friction tensor from the physx view

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it would also require reverse engineering the physx friction force implementation, which could change and break the test, despite the code under test not being broken

Comment thread source/isaaclab/docs/CHANGELOG.rst Resolved
Comment thread source/isaaclab/docs/CHANGELOG.rst Resolved
@Mayankm96

Copy link
Copy Markdown
Contributor

@greptileai some help ;)

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd be happy to help! Could you please clarify what you need assistance with regarding this PR?

For example, are you asking about:

  • How the friction force tracking implementation works?
  • Understanding specific parts of the code changes?
  • Testing the new feature?
  • Integration with existing code?
  • Performance considerations?
  • Something else entirely?

Let me know what specific aspect you'd like me to explain or help with! 😊

@Mayankm96 Mayankm96 moved this from In progress to In review in Isaac Lab Oct 22, 2025
@Mayankm96

Copy link
Copy Markdown
Contributor

@greptileai everything you said. Whatever it takes to improve the MR and make it less error-prone and feature complete :)

gattra-rai and others added 4 commits December 9, 2025 10:04
Signed-off-by: Kelly Guo <kellyg@nvidia.com>
Signed-off-by: Kelly Guo <kellyg@nvidia.com>
@kellyguo11
kellyguo11 merged commit 7b16b67 into isaac-sim:main Dec 10, 2025
8 of 9 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Isaac Lab Dec 10, 2025
T-K-233 pushed a commit to ucb-bar/IsaacLab that referenced this pull request Dec 29, 2025
# Description

This PR extends the `ContactSensor` class to expose aggregated friction
forces for each filtered body. It uses the same vectorized approach used
for [`contact_points`](isaac-sim#2842).

Concretely, this change introduces:
- `ContactSensorCfg.track_friction_forces` toggle to turn on friction
tracking
- `ContactSensorData.friction_forces_w` where the sum of friction forces
for each filtered body are stored

Fixes isaac-sim#2074, isaac-sim#2064

## Performance

Results of `check_contact_sensor.py` with `track_friction_data = False`:
```
avg dt real-time 0.017448579105403043
avg dt real-time 0.017589360827958443
avg dt real-time 0.016146250123070787
```

Results of `check_contact_sensor.py` with `track_friction_data = True`:
```
avg dt real-time 0.01818224351439858
avg dt real-time 0.017720674386015163
avg dt real-time 0.01777262271923246
```

## Type of change
- New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [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

---------

Signed-off-by: Kelly Guo <kellyg@nvidia.com>
Co-authored-by: Kelly Guo <kellyg@nvidia.com>
Edify0991 pushed a commit to Edify0991/IsaacLab that referenced this pull request Jan 14, 2026
# Description

This PR extends the `ContactSensor` class to expose aggregated friction
forces for each filtered body. It uses the same vectorized approach used
for [`contact_points`](isaac-sim#2842).

Concretely, this change introduces:
- `ContactSensorCfg.track_friction_forces` toggle to turn on friction
tracking
- `ContactSensorData.friction_forces_w` where the sum of friction forces
for each filtered body are stored

Fixes isaac-sim#2074, isaac-sim#2064

## Performance

Results of `check_contact_sensor.py` with `track_friction_data = False`:
```
avg dt real-time 0.017448579105403043
avg dt real-time 0.017589360827958443
avg dt real-time 0.016146250123070787
```

Results of `check_contact_sensor.py` with `track_friction_data = True`:
```
avg dt real-time 0.01818224351439858
avg dt real-time 0.017720674386015163
avg dt real-time 0.01777262271923246
```

## Type of change
- New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [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

---------

Signed-off-by: Kelly Guo <kellyg@nvidia.com>
Co-authored-by: Kelly Guo <kellyg@nvidia.com>
nitesh-subedi pushed a commit to nitesh-subedi/IsaacLab that referenced this pull request Feb 5, 2026
# Description

This PR extends the `ContactSensor` class to expose aggregated friction
forces for each filtered body. It uses the same vectorized approach used
for [`contact_points`](isaac-sim#2842).

Concretely, this change introduces:
- `ContactSensorCfg.track_friction_forces` toggle to turn on friction
tracking
- `ContactSensorData.friction_forces_w` where the sum of friction forces
for each filtered body are stored

Fixes isaac-sim#2074, isaac-sim#2064

## Performance

Results of `check_contact_sensor.py` with `track_friction_data = False`:
```
avg dt real-time 0.017448579105403043
avg dt real-time 0.017589360827958443
avg dt real-time 0.016146250123070787
```

Results of `check_contact_sensor.py` with `track_friction_data = True`:
```
avg dt real-time 0.01818224351439858
avg dt real-time 0.017720674386015163
avg dt real-time 0.01777262271923246
```

## Type of change
- New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [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

---------

Signed-off-by: Kelly Guo <kellyg@nvidia.com>
Co-authored-by: Kelly Guo <kellyg@nvidia.com>
csj-275 pushed a commit to csj-275/IsaacLab that referenced this pull request Jul 8, 2026
# Description

This PR extends the `ContactSensor` class to expose aggregated friction
forces for each filtered body. It uses the same vectorized approach used
for [`contact_points`](isaac-sim#2842).

Concretely, this change introduces:
- `ContactSensorCfg.track_friction_forces` toggle to turn on friction
tracking
- `ContactSensorData.friction_forces_w` where the sum of friction forces
for each filtered body are stored

Fixes isaac-sim#2074, isaac-sim#2064

## Performance

Results of `check_contact_sensor.py` with `track_friction_data = False`:
```
avg dt real-time 0.017448579105403043
avg dt real-time 0.017589360827958443
avg dt real-time 0.016146250123070787
```

Results of `check_contact_sensor.py` with `track_friction_data = True`:
```
avg dt real-time 0.01818224351439858
avg dt real-time 0.017720674386015163
avg dt real-time 0.01777262271923246
```

## Type of change
- New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [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

---------

Signed-off-by: Kelly Guo <kellyg@nvidia.com>
Co-authored-by: Kelly Guo <kellyg@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

asset New asset feature or request documentation Improvements or additions to documentation enhancement New feature or request infrastructure isaac-lab Related to Isaac Lab team isaac-mimic Related to Isaac Mimic team isaac-sim Related to Isaac Sim team

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Question] Contact Sensor force not showing x,y directional force

5 participants