Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions config/register_asset_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
import sys
import json

def main():
if len(sys.argv) != 2:
print("Usage: python register_asset_path.py <path_to_assets>")
sys.exit(1)

asset_path = sys.argv[1]

if not os.path.exists(asset_path):
print(f"Error: Provided path does not exist: {asset_path}")
sys.exit(1)

json_data = {"asset_path": os.path.abspath(asset_path)}
oceansim_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
json_path = os.path.join(oceansim_root, 'isaacsim', 'oceansim', 'utils', 'asset_path.json')

with open(json_path, 'w') as f:
json.dump(json_data, f, indent=2)

print(f"Asset path registered successfully: {json_data['asset_path']}")

if __name__ == "__main__":
main()
7 changes: 4 additions & 3 deletions docs/subsections/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ git clone https://github.com/umfieldrobotics/OceanSim.git

Download `OceanSim_assets` from [Google Drive](https://drive.google.com/drive/folders/1qg4-Y_GMiybnLc1BFjx0DsWfR0AgeZzA?usp=sharing) which contains USD assets of robot and environment.

And change function `get_oceansim_assets_path()` in [~/isaacsim/extsUser/OceanSim/isaacsim/oceansim/utils/assets_utils.py](../../isaacsim/oceansim/utils/assets_utils.py) to return the path to the installed assets folder.
Then, run the following to configure OceanSim to point to your asset path:

```bash
def get_oceansim_assets_path() -> str:
return "/path/to/downloaded/assets/OceanSim_assets"
cd /path/to/OceanSim
python3 config/register_asset_path.py /path/to/OceanSim_assets
```

Launch Isaac Sim following this [guide](https://docs.isaacsim.omniverse.nvidia.com/latest/installation/install_workstation.html#isaac-sim-short-app-selector).
Expand Down
3 changes: 3 additions & 0 deletions isaacsim/oceansim/utils/asset_path.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"asset_path": null
}
45 changes: 43 additions & 2 deletions isaacsim/oceansim/utils/assets_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
import os
import json

OCEANSIM_ASSET_PATH=None

def get_oceansim_assets_path() -> str:
# return "/home/haoyu/Desktop/OceanSim_assets"
return "/home/haoyu-ma/Desktop/OceanSim_assets"
global OCEANSIM_ASSET_PATH

if OCEANSIM_ASSET_PATH is not None:
return OCEANSIM_ASSET_PATH

json_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'asset_path.json'))

if not os.path.isfile(json_path):
raise FileNotFoundError(
f"'asset_path.json' not found at {json_path}. "
"Run 'register_asset_path.py <path_to_assets>' to register the asset path."
)

try:
with open(json_path, 'r') as f:
json_data = json.load(f)
except json.JSONDecodeError as e:
raise ValueError(f"'asset_path.json' is not valid JSON: {e}")

if "asset_path" not in json_data:
raise KeyError(
f"'asset_path.json' at {json_path} does not contain the required 'asset_path' key."
)

asset_path = json_data["asset_path"]

if not os.path.isdir(asset_path):
raise FileNotFoundError(f"The provided asset path does not exist: {asset_path}. "
"Run /path/to/oceansim/config/register_asset_path.py /path/to/assets as described in the ReadMe.")

OCEANSIM_ASSET_PATH = asset_path
return asset_path

# Run once to validate on import
get_oceansim_assets_path()

if __name__ == "__main__":
print("OceanSim Assets are configured at", get_oceansim_assets_path())