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

[Development] Add convert glb to usd objects. Issac Lab repo installation required. #2113

Open
wants to merge 62 commits into
base: isaac_sim_dev
Choose a base branch
from

Conversation

danieltmeta
Copy link
Contributor

@danieltmeta danieltmeta commented Dec 3, 2024

Motivation and Context

This pull request (PR) introduces the capability to convert file types in Isaac Lab, specifically converting files into .usda format. These conversion utilities are essential for Isaac Sim physics simulations to process scene instance JSONs and object meshes from Habitat-Sim.

The PR includes the conversion of scene instances, encompassing rigid body objects. However, it does not currently support articulated objects or the stage. Future updates will address these limitations.

Additionally, a separate set of functions is required to convert robot URDF files into .usda format for use in Isaac Sim. This functionality will be implemented in a subsequent update.

How Has This Been Tested

Unit tests will be added to code function and the usda file output.

Types of changes

  • [Docs change] Addition or changes to the documentation
  • [Refactoring] Large changes to the code that improve its functionality or performance
  • [Dependency Upgrade] Upgrades one or several dependencies in habitat
  • [Bug Fix] (non-breaking change which fixes an issue)
  • [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!
  • [Experiment] A pull request that add new features to the habitat-baselines training codebase. Experiments Pull Requests can be any size, must have smoke/integration tests and be isolated from the rest of the code. Your code additions should not rely on other habitat-baselines code. This is to avoid dependencies between different parts of habitat-baselines. You must also include a README that will document how to use your new feature or trainer. You will be the maintainer of this code, if the code becomes stale or is not supported often enough, we will eventually remove it.

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 Dec 3, 2024
Copy link
Contributor

@eundersander eundersander left a comment

Choose a reason for hiding this comment

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

Some good progress here! I left some comments.

My biggest request is to add a test file (the last comment in usd_conversion_scene.py).

Also, I see that pre-commit and python lint CI tests are failing (see below "Some checks are failing"). Try to get those passing. Have you installed pre-commit locally? See instructions.

Let me know when you've addressed my comments and I'll take another look!

habitat-lab/habitat/isaacsim/remote_content/converter.py Outdated Show resolved Hide resolved
habitat-lab/habitat/isaacsim/ssh_conversion.py Outdated Show resolved Hide resolved
habitat-lab/habitat/isaacsim/urdf_conversion.py Outdated Show resolved Hide resolved
habitat-lab/habitat/isaacsim/urdf_conversion.py Outdated Show resolved Hide resolved
habitat-lab/habitat/isaacsim/usd_conversion_scene.py Outdated Show resolved Hide resolved
habitat-lab/habitat/isaacsim/usd_conversion_scene.py Outdated Show resolved Hide resolved
habitat-lab/habitat/isaacsim/usd_conversion_scene.py Outdated Show resolved Hide resolved
local_download_folder = "/home/trandaniel/dev/IsaacSimConversion/usd_scene/"
glb_data_folder = "/home/trandaniel/dev/habitat-sim/data/hssd-hab/objects"

convert_scene_instance(
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add test/test_isaac_sim.py to habitat-lab in this PR. Look at our other test files in that folder for reference. Let's have a test that tries to convert a toy habitat scene instance (this is something you suggested a while back). The test can assume the source assets are present on the machine (or maybe check for them and skip the test if they're missing). The test should inspect the output usda file and check for expected contents.

Copy link
Contributor Author

@danieltmeta danieltmeta Jan 13, 2025

Choose a reason for hiding this comment

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

Migrating unit tests and example data from PR #2123

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to delete PR #2123 after unit tests are reviewed.

@danieltmeta danieltmeta changed the title Add convert glb to usd objects. Issac Lab repo installation required. **\[Development\]** Add convert glb to usd objects. Issac Lab repo installation required. Jan 9, 2025
@danieltmeta danieltmeta changed the title **\[Development\]** Add convert glb to usd objects. Issac Lab repo installation required. [Development] Add convert glb to usd objects. Issac Lab repo installation required. Jan 9, 2025
@eundersander eundersander changed the base branch from main to isaac_sim_dev January 17, 2025 17:42
Copy link
Contributor

@eundersander eundersander left a comment

Choose a reason for hiding this comment

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

Good progress here!

Please flesh out your PR description a bit. You don't have to explain what Isaac Sim is, but give some background for why we need these conversion utils. Mention that we convert scene instances including rigid objects (but not any included articulated objects or the stage yet). Mention the URDF conversion for converting robot URDF files. For Type of change, specify [Development].

Let's move meshColored inside data/usd_conversion_data so all the isaac-related test data is in one subfolder.

It looks like maybe you're not using test/data/usd_conversion_data/102343992.scene_instance.json for testing, so you can remove it from this PR.

I suspect you don't need to add test/data/usd_conversion_data/objects_EXAMPLE2/1efdc3d37dfab1eb9f99117bb84c59003d684811.glb to this repo, because it's a render GLB and it won't be used/loaded during the conversion (or am I missing something?). In general, we want to be really careful and selective about adding binary files to a git repo, since they are usually large.

test/data/usd_conversion_data/.asset_hash Outdated Show resolved Hide resolved
habitat-lab/habitat/isaacsim/urdf_to_usd.py Outdated Show resolved Hide resolved
)


if __name__ == "__main__":
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's update the CI to just convert a URDF to USD, rather than using/testing all the individual pieces. We want a user to be able to convert a URDF to USD with one command, without having to understand or worry about the intermediate pieces.

It should look like python habitat-lab/habitat/isaac_sim/urdf_to_usd.py [input_scene_instance_filepath] --output_folder [output_folder] --project_root_folder [project_root_folder]. It should do three things: (1) clean the input URDF (including removing visuals) and write the cleaned URDF to the output folder, perhaps as "temp.urdf". (2) Convert the cleaned URDF to USD and write to output_folder/scene_instance_base_name.usd (3) delete temp.urdf. By scene_instance_base_name, I mean that my_scene.scene_instance.json becomes my_scene.usd.

test/test_isaac_sim.py Outdated Show resolved Hide resolved
test/test_isaac_sim.py Outdated Show resolved Hide resolved
test/test_isaac_sim.py Outdated Show resolved Hide resolved
test/data/usd_conversion_data/config.yaml Show resolved Hide resolved
test/test_isaac_sim.py Show resolved Hide resolved
out_usd_path: str,
project_root_folder: str,
) -> None:
"""This converts an hssd object to a usda file.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just bumping this comment. Let's not name HSSD in comments.

Copy link
Contributor

@eundersander eundersander left a comment

Choose a reason for hiding this comment

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

I left a few more comments. Also, your test is failing in CI:

==================================== ERRORS ====================================
___________________ ERROR collecting test/test_isaac_sim.py ____________________
ImportError while importing test module '/home/runner/work/habitat-lab/habitat-lab/habitat-lab/test/test_isaac_sim.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../../miniconda3/envs/habitat/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
test/test_isaac_sim.py:7: in <module>
    from lxml import etree as ET
E   ModuleNotFoundError: No module named 'lxml'

I believe the fix here is to add lxml to habitat-lab/requirements.txt.


# Dependency Repos
IssacLab/
habitat-sim/
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't needed. .gitignore entries are generally for files that many or most folks will encounter, where we know 100% it shouldn't be added to source control. Folks generally aren't cloning habitat-sim at the root of habitat-lab. I recommend cloning habitat-sim outside habitat-lab. If you happen to have this cloned here on your local system and you're trying to clean up your branch, just leave this folder as un-staged. No need to add it to .gitignore.

test/data/usd_conversion_data/config.yaml

# Dependency Repos
IssacLab/
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise, this isn't needed. Folks generally shouldn't be cloning IsaacLab at the root of habitat-lab.

@@ -106,3 +106,11 @@ data

# Autogenerated navmesh files
*.navmesh

# urdf conversion artifact
.asset_hash
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 qualify this as test/data/usd_conversion_data/.asset_hash?

@@ -14,5 +14,5 @@ default_drive_damping: 0.0
link_density: 1000.0
Copy link
Contributor

Choose a reason for hiding this comment

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

This file looks like output from your test. It doesn't need to be added to version control.

)


if __name__ == "__main__":
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd still like to see the CLI for urdf_to_usd.py simplified as described in this comment. However, if you're eager to wrap up this PR, you can add a todo in the code here and we'll address this later.


convert_urdf(clean_urdf_filepath, output_usd)

if os.path.exists(output_usd):
Copy link
Contributor

Choose a reason for hiding this comment

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

You should assert that the file exists. I.e. the test should fail if the file doesn't exist.

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