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 61 commits into
base: isaac_sim_dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
c722108
Add convert glb to usd objects. Issac Lab repo installation required.
danieltmeta Nov 27, 2024
176c7c9
Add urdf_conversion.py. This file converts .urdf to .usd.
danieltmeta Dec 6, 2024
8b3af05
Add clean_urdf_xml.py. Written by Eric Undersander
danieltmeta Dec 10, 2024
ef1bb47
Add bulk_usd_conversion.py.
danieltmeta Dec 10, 2024
fc9b2e4
Add glb decompression file. Add note and terminal command example. Wr…
danieltmeta Dec 10, 2024
52c6b2e
Remove asyncio library. Add MeshConverter Cfg and remove all asyncio …
danieltmeta Dec 10, 2024
75aee50
Remove remote_content folder. Move associated scripts to parent direc…
danieltmeta Dec 10, 2024
c5f4c51
Remove ssh_conversion.py. SAFEKEEPING.
danieltmeta Dec 10, 2024
2639996
Remove private funciton in urdf_conversion.py. Add UrdfConverterCfg i…
danieltmeta Dec 10, 2024
51b2e3c
Move AppLauncher class into if/main statement
danieltmeta Dec 10, 2024
9dfde68
Move Applauncher class into if/main statement.
danieltmeta Dec 10, 2024
33b51df
Fix syntax and variable errors in converter.py.
danieltmeta Dec 11, 2024
7b1a6b6
Remove and archive older versions of conversion .py
danieltmeta Jan 4, 2025
fc2e667
Draft. Add urdf to usd converter.
danieltmeta Jan 4, 2025
61287f9
Add scene_instance_json_to_usd.py. Draft stage.
danieltmeta Jan 5, 2025
c5bf778
Minor formatting
danieltmeta Jan 5, 2025
ec5d0e6
Black formatting
danieltmeta Jan 6, 2025
511d8da
Remove temporary archive folder.
danieltmeta Jan 6, 2025
ec6e720
Fix github actions issues and formatting issues.
danieltmeta Jan 6, 2025
dc683e2
Fix github actions and formatting issues.
danieltmeta Jan 6, 2025
f1c1342
Save black formatting changes.
danieltmeta Jan 6, 2025
c32fb4e
Fix black formatting.
danieltmeta Jan 6, 2025
06fcc52
Fix black formatting
danieltmeta Jan 6, 2025
365cbb2
Fix black formatting.
danieltmeta Jan 6, 2025
6f05bb7
Fix black formatting
danieltmeta Jan 6, 2025
eaacc63
FIx black formatting
danieltmeta Jan 6, 2025
21453bc
Fix black formatting.
danieltmeta Jan 6, 2025
c71926e
Fix black formatting.
danieltmeta Jan 6, 2025
0e146c7
Fix black formatting
danieltmeta Jan 6, 2025
3d4eed0
Fix isort formatting
danieltmeta Jan 6, 2025
465397d
Fix black formatting.
danieltmeta Jan 6, 2025
ab74bee
Fix isort formatting.
danieltmeta Jan 6, 2025
80b46a0
Fixing various formatting issues.
danieltmeta Jan 6, 2025
16bb555
Fix formatting.
danieltmeta Jan 6, 2025
2ee9d87
Fix formatting.
danieltmeta Jan 6, 2025
7d7a01e
Fix formatting.
danieltmeta Jan 6, 2025
41020e4
Remove unused libraries for github actions.
danieltmeta Jan 6, 2025
d180400
Minor docstring changes as suggested on github.
danieltmeta Jan 9, 2025
fd4b5d6
Update docstring for scene_instance_json_to_usd.py
danieltmeta Jan 9, 2025
5b2c63d
Add CLI for usd conversion.
danieltmeta Jan 10, 2025
1b9c9d5
Draft, add bulk scene instance json coversion
danieltmeta Jan 10, 2025
a6010f3
Draft, add CLI
danieltmeta Jan 10, 2025
d1d2fa2
precommit formatting.
danieltmeta Jan 12, 2025
14d4ee9
Remove bulk scene conversion logic. Will be transferred to unit tests.
danieltmeta Jan 12, 2025
d2db102
Update docstrings, minor check, and conversion function into if/main
danieltmeta Jan 12, 2025
1c2b1bc
precommit formatting.
danieltmeta Jan 12, 2025
fabe34c
Remove redundant imports
danieltmeta Jan 12, 2025
b096e3b
Updated docstrings and type annotations for scene_instance_json_to_us…
danieltmeta Jan 13, 2025
709c288
Updated doctring and minor formatting for urdf_to_usd.py
danieltmeta Jan 13, 2025
eec904e
Migrate draft of unit test and example data from PR #2123
danieltmeta Jan 13, 2025
9401213
Save progress unit test usd conversion.
danieltmeta Jan 15, 2025
8d047dc
Draft of unit test for usd conversion.
danieltmeta Jan 15, 2025
cee0591
Add files for unit test conversion
danieltmeta Jan 15, 2025
589aefb
minor formatting
danieltmeta Jan 15, 2025
175dcce
Formatting, end of file fix
danieltmeta Jan 15, 2025
4d428a3
Make some minor changes as described in the above comments.
danieltmeta Jan 23, 2025
71d3d06
Remove hssd comments.
danieltmeta Jan 23, 2025
0219137
Remove files generated by unit test.
danieltmeta Jan 23, 2025
a35fd09
Update pathing and import issues.
danieltmeta Jan 23, 2025
bdca713
Remove more necessary files for unit testing isaac lab conversion
danieltmeta Jan 23, 2025
2fe9535
Move meshColored folder and remove more unncessary unit test data files.
danieltmeta Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions habitat-lab/habitat/isaacsim/remote_content/converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'''
This module takes converts glb files to usd.

The system that runs this folder needs have the Issac Lab repo installed.
The converter function from isaac lab can import only after the Isaac Lab stage
is launched. asyncio library is used because the source code for
MeshConverter._convert_mesh_to_usd is also an async function.

'''
import asyncio
import argparse
from omni.isaac.lab.app import AppLauncher
import os
import timer

#Run laucher through Isaac Lab


async def convert_glb_to_usd(glb_folder_path: str, usd_folder_path: str) -> None:
danieltmeta marked this conversation as resolved.
Show resolved Hide resolved
"""
This function converts glb files to usd. This function launches an empty Isaac Lab stage,
Imports the respective Isaac Lab converter functions, then converts with another
MeshConverter._convert_mesh_to_usd async function. The simulation app then closes, and
the converted functions are dumped onto the respective usd_folder_path.
"""

# create argparser
parser = argparse.ArgumentParser(description="Tutorial on creating an empty stage.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()
# launch omniverse app
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

from omni.isaac.lab.sim.converters import MeshConverter #NOTE: Import isaac lab converter extension after launcher runs

glb_folder_list = [glb for glb in os.listdir(glb_folder_path) if os.path.isfile(os.path.join(glb_folder_path, glb))]

loop = asyncio.get_event_loop()
for glb_filename in glb_folder_list:
glb_filepath = glb_folder_path + glb_filename
usd_filename = f"{glb_filename.replace('.glb', '.usd')}"
usd_filepath = usd_folder_path + usd_filename
loop.run_until_complete(MeshConverter._convert_mesh_to_usd(in_file=glb_filepath, out_file=usd_filepath))
danieltmeta marked this conversation as resolved.
Show resolved Hide resolved
loop.close()

simulation_app.close()

if __name__ == "__main__":
glb_folder_path = '/path/object_glb/'
usd_folder_path = '/path/object_usd/'
asyncio.run(convert_glb_to_usd(glb_folder_path, usd_folder_path))
danieltmeta marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
danieltmeta marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
62 changes: 62 additions & 0 deletions habitat-lab/habitat/isaacsim/ssh_conversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
danieltmeta marked this conversation as resolved.
Show resolved Hide resolved
This module helps a local computer interact with a remote server.
The remote server has the machine specs required for Issac Lab installation
to run MeshConverter._convert_mesh_to_usd(). The local machine does not.
See this url for documentation:
https://isaac-sim.github.io/IsaacLab/main/_modules/omni/isaac/lab/sim/converters/mesh_converter.html#MeshConverter
"""

from scp import SCPClient
import os
import subprocess
from multiprocessing import Barrier

#NOTE: USER SHOULD INPUT REMOTE SERVER VALUES HERE
username = 'USERNAME'
hostname = 'IP_ADDRESS' #NOTE: THIS IS A SECURITY ISSUE
port = 23456
REMOTE_GLB_FOLDER = '/path/object_glb/'
REMOTE_USD_FOLDER = '/path/object_usd'


def upload_object_glb_to_server(object_glb_path: str) -> None:
"""
Upload a local folder with .glb files and upload it to remote server.
"""

attempts = 3 #NOTE: The attempts and for loop ensure uploads complete if upload task is dumped from queue.
for attempt in range(attempts):
try:
remote_file_path = REMOTE_GLB_FOLDER + os.path.basename(object_glb_path)
scp_command = f'scp {object_glb_path} {hostname}:{remote_file_path}'
subprocess.run(scp_command, shell=True)
break
except Exception as e:
print(f"Error uploading {filepath} (attempt {i+1}/{attempts}): {e}")
if attempt == attempts - 1:
raise

barrier.wait()

def run_remote_converter() -> None:
"""
This function runs the glb to usd conversion.py that sits on the given remote computer.
This sends bash commands to active Isaac Lab library in conda and run converter.py with a local subprocess library.
"""

#Check remote pathing.
scp_command = f"ssh {username}@{hostname} 'source /home/guest/miniforge3/etc/profile.d/conda.sh; conda activate isaaclab2; python /home/guest/dev/isaac_lab_converter/converter.py' "
subprocess.run(scp_command, shell=True)


def download_remote_usd_folder(local_download_file_path: str) -> None:
"""
This function downloads folder contents from a remote computer.
This function uses the bash script with the help of the subprocess library.
"""
scp_command = f'scp -r -C {hostname}:{REMOTE_USD_FOLDER} {local_download_file_path}'
subprocess.run(scp_command, shell=True)


if __name__ == "__main__":
run_remote_converter()
48 changes: 48 additions & 0 deletions habitat-lab/habitat/isaacsim/urdf_conversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""This module converts urdf files to usd."""
# TODO: first setup mamba activate isaaclab2?

import argparse
from omni.isaac.lab.app import AppLauncher

def convert_urdf_to_usd(source_urdf_filepath: str, usd_folder_path: str) -> None:
"""
This function converts a .urdf file into a .usd file. NOTE: Please be aware of
pathing issues and references to other .glb files within the urdf file.

:param source_urdf_filepath: The absolute string path of the urdf file
:param usd_folder_path: The absolute directory of the desired directory location of .usd file. The output will generatate a Props-> instanceable_meshes.usd, .asset_hash, config.yaml, and the desired .usd.

"""

# create argparser
parser = argparse.ArgumentParser(description="Create an empty Issac Sim stage.")
danieltmeta marked this conversation as resolved.
Show resolved Hide resolved
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()
# launch omniverse app
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

#NOTE: Import isaac lab converter extension after launcher runs
from omni.isaac.lab.sim.converters import UrdfConverter, UrdfConverterCfg

# urdf_filename = 'sink.urdf'
danieltmeta marked this conversation as resolved.
Show resolved Hide resolved
# usd_filepath = f"{source_urdf_filepath.replace('.urdf', '.usd')}"

# Add config information
config = UrdfConverterCfg()
config.asset_path = source_urdf_filepath # Source file
config.usd_dir = usd_folder_path # Output file
config.fix_base = True

# Convert asset
converter = UrdfConverter(cfg=config)
converter._convert_asset(cfg=config)
danieltmeta marked this conversation as resolved.
Show resolved Hide resolved

simulation_app.close()

if __name__ == "__main__":
urdf_folder_path = '/home/guest/dev/urdf_converter/object_urdf/sink.urdf'
usd_folder_path = '/home/guest/dev/urdf_converter/object_usd/'
convert_urdf_to_usd(urdf_folder_path, usd_folder_path)
Loading
Loading