Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Receptacle filtering refactor #1889

Merged
merged 3 commits into from
Apr 4, 2024
Merged

Conversation

aclegg3
Copy link
Contributor

@aclegg3 aclegg3 commented Apr 2, 2024

Motivation and Context

We want to use the scene Receptacle filtering earlier in the process. Currently, filters are only taken into account during sampling which is too late. This means our generic lists of Receptacles in the scene contains many un-usable entries to sift through.

This PR refactors the functionality to load and leverage the filter files into a set of util functions which can be used at other stages. It also adds the option to provide filter strings directly to the find_receptacles function to get a pre-filtered list of Receptacle instances.

How Has This Been Tested

Added a CI test to validate the functionality.

Example of using the new utils to get a pre-filtered list of Receptacles from the active scene:

import habitat.datasets.rearrange.samplers.receptacle as hab_receptacle
...
with habitat_sim.Simulator(cfg) as sim:
   scene_filter_filepath = hab_receptacle.get_scene_rec_filter_filepath(sim.metadata_mediator, sim.curr_scene_name)
   if scene_filter_filepath is not None:
      exclude_filter_strings = hab_receptacle.get_excluded_recs_from_filter_file(scene_filter_filepath)
      filtered_receptacles = hab_receptacle.find_receptacles(
         sim, 
        ignore_handles=None, #this is a list of object handles for parent objects to exclude
         exclude_filter_strings=exclude_filter_strings #this is a list of unique_name substrings to exclude.
      )

Types of changes

  • [Refactoring] Large changes to the code that improve its functionality or performance
  • [Development] A pull request that add new features to the habitat-lab task and environment codebase. Development Pull Requests must be small (less that 500 lines of code change), have unit testing, very extensive documentation and examples. These are typically new tasks, environments, sensors, etc... The review process for these Pull Request is longer because these changes will be maintained by our core team of developers, so make sure your changes are easy to understand!

Checklist

  • My code follows the code style of this project.
  • I have updated the documentation if required.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes if required.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Apr 2, 2024
) -> List[Union[Receptacle, AABBReceptacle, TriangleMeshReceptacle]]:
"""
Scrape and return a list of all Receptacles defined in the metadata belonging to the scene's currently instanced objects.

:param sim: Simulator must be provided.
:param ignore_handles: An optional list of handles for ManagedObjects which should be skipped. No Receptacles for matching objects will be returned.
:param exclude_filter_strings: An optional list of excluded Receptacle substrings. Any Receptacle which contains any excluded filter substring in its unique_name will not be included in the returned set.
Copy link
Contributor

Choose a reason for hiding this comment

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

can you provide some examples of what these strings can be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, these are exactly the strings found in the receptacle_filter_files here: https://huggingface.co/datasets/hssd/hssd-hab/tree/main/scene_filter_files

In that file, they are exact matches for the Receptacle.unique_name attribute.

They can also be any substring you want. For example, an object hash like 033ec086c23a6d39fb37df87e6748c413bf80e29 or if the receptacles have semantic names, something like "top_drawer".

Copy link
Contributor

@akshararai akshararai left a comment

Choose a reason for hiding this comment

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

looks great, thank you!

@aclegg3 aclegg3 merged commit 92ea7a9 into main Apr 4, 2024
4 checks passed
@aclegg3 aclegg3 deleted the alex-04_02-rec_filtering_refactor branch April 4, 2024 17:55
dannymcy pushed a commit to dannymcy/habitat-lab that referenced this pull request Jun 26, 2024
* refactor filter file loading to extract functions for use elsewhere

* add util to cull filtered receptacles and integrate with find_receptacles() function. Add unit test.
dannymcy pushed a commit to dannymcy/habitat-lab that referenced this pull request Jul 8, 2024
* refactor filter file loading to extract functions for use elsewhere

* add util to cull filtered receptacles and integrate with find_receptacles() function. Add unit test.
dannymcy pushed a commit to dannymcy/habitat-lab that referenced this pull request Jul 8, 2024
* refactor filter file loading to extract functions for use elsewhere

* add util to cull filtered receptacles and integrate with find_receptacles() function. Add unit test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants