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

ObjectStateSpec, ObjectStateMachine base classes #1842

Merged
merged 10 commits into from
Apr 3, 2024

Conversation

aclegg3
Copy link
Contributor

@aclegg3 aclegg3 commented Mar 9, 2024

Motivation and Context

Context: we want to simulate more abstract states than physics/geometry. These should be event driven (e.g. "wash dish" action) or temporally driven (e.g. state machine logic in step())

Two identified initial states examples:

  • "dish" objects have dirty/clean states and there is some state-machine logic to evolve this state
    • e.g. "dirty" object in sink or dishwasher when "clean()" action is activated
  • "appliance" objects have "on/off" states which can be set from an action

Notes on Implementation:

  • If the states are semantically driven, we need something like the MetadataInterface class in habitat-lab to manage registration and set membership. Another option would be to embed the semantic classes directly into the dataset configs so they would be parsed and available from sim.
  • Current concrete implementations are examples and should be updated to reflect true logic better before merging
  • Current module locations within habitat_simulator module are best guess, open to discussion.

Update: this PR now contains only the foundation of the feature and basic unit tests. MetadataInterface and original example logic is removed for now.

How Has This Been Tested

added basic tests with contrived scenarios

Types of changes

  • [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 Mar 9, 2024
@@ -77,6 +78,43 @@ def save(self, output_path: str, prefix: str = "") -> str:
return file_path


def draw_object_highlight(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we control the thickness of the highlight as well? I imagine this can be important for some applications based on the camera resolution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this can be done in the debug_line_render object before it is passed into this function. https://aihabitat.org/docs/habitat-sim/habitat_sim.gfx.DebugLineRender.html#set_line_width

So it shouldn't need to be explicitly controlled here. Rather the user application can set that for all debug renders.

self.receptacles: List[hab_receptacle.Receptacle] = None

# generate a lexicon from the metadata
self.hash_to_cat: Dict[str, str] = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Will the categories have a notion of hierarchy? What if we want to say "all dinning ware can be dirty" which should include fork, plate, spoon, etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we have any limitations as long as we can represent the desired hierarchy or grouping in the MetadataInterface logic. Currently we only pull the primary category and search a single map. I imagine we need to define these groupings or hierarchy somewhere. Could be an additional annotation field in the csv, or a dict-like map.

@aclegg3 aclegg3 changed the title [WIP] ObjectStateSpec, ObjectStateMachine, MetadataInterface ObjectStateSpec, ObjectStateMachine base classes Mar 19, 2024
@aclegg3 aclegg3 marked this pull request as ready for review March 19, 2024 21:41
Copy link

@rutadesai rutadesai left a comment

Choose a reason for hiding this comment

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

LGTM! Looking forward to extending this to one to two instantiations pretty soon and also its integration in benchmark generation :) Thanks, Alex!

@@ -13,6 +13,18 @@
from habitat.sims.habitat_simulator.debug_visualizer import DebugVisualizer


def object_shortname_from_handle(object_handle: str) -> str:

Choose a reason for hiding this comment

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

we have a similar function in hab-llm: https://github.com/facebookresearch/habitat-llm/blob/main/dataset_generation/benchmark_generation/generate_instructions.py#L62 Not sure if it is worth making this a utils function in one place..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Once this merges, I'll refactor downstream code to use this util.

@aclegg3 aclegg3 merged commit 3d295b9 into main Apr 3, 2024
4 checks passed
@aclegg3 aclegg3 deleted the alex-03_08-object-state-machine branch April 3, 2024 21:13
dannymcy pushed a commit to dannymcy/habitat-lab that referenced this pull request Jun 26, 2024
* add abstract implementation of ObjectStateSpec and ObjectStateMachine

* add some contrived test logic for the state machine

* add an obejct highlight debug line visualization util
dannymcy pushed a commit to dannymcy/habitat-lab that referenced this pull request Jul 8, 2024
* add abstract implementation of ObjectStateSpec and ObjectStateMachine

* add some contrived test logic for the state machine

* add an obejct highlight debug line visualization util
dannymcy pushed a commit to dannymcy/habitat-lab that referenced this pull request Jul 8, 2024
* add abstract implementation of ObjectStateSpec and ObjectStateMachine

* add some contrived test logic for the state machine

* add an obejct highlight debug line visualization util
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.

5 participants