asset_conversion_utils
convert_scene_urdf_to_json(urdf, json_path)
Converts a scene from a URDF file to a JSON file.
This function loads the scene described by the URDF file into the OmniGibson simulator, plays the simulation, and saves the scene to a JSON file. After saving, it removes the "init_info" from the JSON file and saves it again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf
|
str
|
The file path to the URDF file describing the scene. |
required |
json_path
|
str
|
The file path where the JSON file will be saved. |
required |
Source code in OmniGibson/omnigibson/utils/asset_conversion_utils.py
convert_urdf_to_usd(urdf_path, obj_category, obj_model, dataset_root, use_omni_convex_decomp=False, use_usda=False, merge_fixed_joints=False, import_inertia_tensor=True)
Imports an object from a URDF file into the current stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_path
|
str
|
Path to URDF file to import |
required |
obj_category
|
str
|
The category of the object. |
required |
obj_model
|
str
|
The model name of the object. |
required |
dataset_root
|
str
|
Dataset root directory to use for writing imported USD file. |
required |
use_omni_convex_decomp
|
bool
|
Whether to use omniverse's built-in convex decomposer for collision meshes |
False
|
use_usda
|
bool
|
If set, will write files to .usda files instead of .usd (bigger memory footprint, but human-readable) |
False
|
merge_fixed_joints
|
bool
|
whether to merge fixed joints or not |
False
|
import_inertia_tensor
|
bool
|
Whether to import the URDF's native inertia tensor or not |
True
|
Returns:
| Type | Description |
|---|---|
2 - tuple
|
|
Source code in OmniGibson/omnigibson/utils/asset_conversion_utils.py
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 | |
find_all_prim_children_with_type(prim_type, root_prim)
Recursively searches children of @root_prim to find all instances of prim that satisfy type @prim_type
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prim_type
|
str
|
Type of the prim to search |
required |
root_prim
|
Prim
|
Root prim to search |
required |
Returns:
| Type | Description |
|---|---|
list of Usd.Prim
|
All found prims whose prim type includes @prim_type |
Source code in OmniGibson/omnigibson/utils/asset_conversion_utils.py
generate_collision_meshes(trimesh_mesh, method='coacd', hull_count=32, discard_not_volume=True, error_handling=False)
Generates a set of collision meshes from a trimesh mesh using CoACD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trimesh_mesh
|
Trimesh
|
The trimesh mesh to generate the collision mesh from. |
required |
method
|
str
|
Method to generate collision meshes. Valid options are {"coacd", "convex"} |
'coacd'
|
hull_count
|
int
|
If @method="coacd", this sets the max number of hulls to generate |
32
|
discard_not_volume
|
bool
|
If @method="coacd" and set to True, this discards any generated hulls that are not proper volumes |
True
|
error_handling
|
bool
|
If true, will run coacd_runner.py and handle the coacd assertion fault by using convex hull instead |
False
|
Returns:
| Type | Description |
|---|---|
List[Trimesh]
|
The collision meshes. |
Source code in OmniGibson/omnigibson/utils/asset_conversion_utils.py
1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 | |
generate_urdf_for_mesh(asset_path, out_dir, category, mdl, collision_method=None, hull_count=32, up_axis='z', scale=1.0, check_scale=False, rescale=False, overwrite=False)
Generate URDF file for either single mesh or articulated files. Each submesh in articulated files (glb, gltf) will be extracted as a separate link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_path
|
str
|
Path to the input mesh file (.obj, .glb, .gltf) |
required |
out_dir
|
str
|
Output directory |
required |
category
|
str
|
Category name for the object |
required |
mdl
|
str
|
Model name |
required |
collision_method
|
str or None
|
Method for generating collision meshes ("convex", "coacd", or None) |
None
|
hull_count
|
int
|
Maximum number of convex hulls for COACD method |
32
|
up_axis
|
str
|
Up axis for the model ("y" or "z") |
'z'
|
scale
|
float
|
User choice scale, will be overwritten if check_scale and rescale |
1.0
|
check_scale
|
bool
|
Whether to check mesh size based on heuristic |
False
|
rescale
|
bool
|
Whether to rescale mesh if check_scale |
False
|
overwrite
|
bool
|
Whether to overwrite existing files |
False
|
Source code in OmniGibson/omnigibson/utils/asset_conversion_utils.py
2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 | |
get_collision_approximation_for_urdf(urdf_path, collision_method='coacd', hull_count=32, coacd_links=None, convex_links=None, no_decompose_links=None, visual_only_links=None, ignore_links=None)
Computes collision approximation for all collision meshes (which are assumed to be non-convex) in the given URDF.
NOTE: This is an in-place operation! It will overwrite @urdf_path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_path
|
str
|
Absolute path to the URDF to decompose |
required |
collision_method
|
str
|
Default collision method to use. Valid options are: {"coacd", "convex"} |
'coacd'
|
hull_count
|
int
|
Maximum number of convex hulls to decompose individual visual meshes into. Only relevant if @collision_method is "coacd" |
32
|
coacd_links
|
None or list of str
|
If specified, links that should use CoACD to decompose collision meshes |
None
|
convex_links
|
None or list of str
|
If specified, links that should use convex hull to decompose collision meshes |
None
|
no_decompose_links
|
None or list of str
|
If specified, links that should not have any special collision decomposition applied. This will only use the convex hull |
None
|
visual_only_links
|
None or list of str
|
If specified, link names corresponding to links that should have no collision associated with them (so any pre-existing collisions will be removed!) |
None
|
ignore_links
|
None or list of str
|
If specified, link names corresponding to links that should be skipped during collision generation process |
None
|
Source code in OmniGibson/omnigibson/utils/asset_conversion_utils.py
2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 | |
import_obj_metadata(usd_path, obj_category, obj_model, dataset_root, keep_instanceable=True, force_asset_pipeline_materials=False)
Imports metadata for a given object model from the dataset. This metadata consist of information that is NOT included in the URDF file and instead included in the various JSON files shipped in iGibson and BEHAVIOR-1K datasets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
usd_path
|
str
|
Path to USD file |
required |
obj_category
|
str
|
The category of the object. |
required |
obj_model
|
str
|
The model name of the object. |
required |
dataset_root
|
str
|
The root directory of the dataset. |
required |
keep_instanceable
|
bool
|
Whether to keep the instanceable attributes from the imported USD object or not |
True
|
force_asset_pipeline_materials
|
bool
|
Flag to force the use of asset pipeline materials. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the bounding box size is not found in the metadata. |
Returns:
| Type | Description |
|---|---|
bool
|
Success status of the conversion |
Source code in OmniGibson/omnigibson/utils/asset_conversion_utils.py
722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | |
import_og_asset_from_urdf(category, model, dataset_name, urdf_path=None, collision_method='coacd', coacd_links=None, convex_links=None, no_decompose_links=None, visual_only_links=None, keep_instanceable=True, merge_fixed_joints=False, import_inertia_tensor=True, hull_count=32, overwrite=False, use_usda=False)
Imports an asset from URDF format into OmniGibson-compatible USD format. This will write the new USD (and copy the URDF if it does not already exist within @dataset_name) to @dataset_name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
Category to assign to imported asset |
required |
model
|
str
|
Model name to assign to imported asset |
required |
urdf_path
|
None or str
|
If specified, external URDF that should be copied into the dataset first before converting into USD format. Otherwise, assumes that the urdf file already exists within @dataset_name dir |
None
|
collision_method
|
None or str
|
If specified, collision decomposition method to use to generate OmniGibson-compatible collision meshes. Valid options are {"coacd", "convex"} |
'coacd'
|
coacd_links
|
None or list of str
|
If specified, links that should use CoACD to decompose collision meshes |
None
|
convex_links
|
None or list of str
|
If specified, links that should use convex hull to decompose collision meshes |
None
|
no_decompose_links
|
None or list of str
|
If specified, links that should not have any special collision decomposition applied. This will only use the convex hull |
None
|
visual_only_links
|
None or list of str
|
If specified, links that should have no colliders associated with it |
None
|
keep_instanceable
|
bool
|
Whether to keep the instanceable attributes from the imported USD object or not |
True
|
merge_fixed_joints
|
bool
|
Whether to merge fixed joints or not |
False
|
import_inertia_tensor
|
bool
|
Whether to import the URDF's native inertia tensor or not |
True
|
dataset_name
|
str
|
Dataset name to which the USD will be written. Lives in get_dataset_path(dataset_name) |
required |
hull_count
|
int
|
Maximum number of convex hulls to decompose individual visual meshes into. Only relevant if @collision_method is "coacd" |
32
|
overwrite
|
bool
|
If set, will overwrite any pre-existing files |
False
|
use_usda
|
bool
|
If set, will write files to .usda files instead of .usd (bigger memory footprint, but human-readable) |
False
|
Returns:
| Type | Description |
|---|---|
3 - tuple
|
|
Source code in OmniGibson/omnigibson/utils/asset_conversion_utils.py
2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 | |
record_obj_metadata_from_urdf(urdf_path, obj_dir, joint_setting='zero', overwrite=False)
Records object metadata and writes it to misc/metadata.json within the object directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_path
|
str
|
Path to object URDF |
required |
obj_dir
|
str
|
Absolute path to the object's root directory |
required |
joint_setting
|
str
|
Setting for joints when calculating canonical metadata. Valid options are {"low", "zero", "high"} (i.e.: lower joint limit, all 0 values, or upper joint limit) |
'zero'
|
overwrite
|
bool
|
Whether to overwrite any pre-existing data |
False
|
Source code in OmniGibson/omnigibson/utils/asset_conversion_utils.py
simplify_convex_hull(tm, max_vertices=60, max_faces=128)
Simplifies a convex hull mesh by using quadric edge collapse to reduce the number of faces
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tm
|
Trimesh
|
Trimesh mesh to simply. Should be convex hull |
required |
max_vertices
|
int
|
Maximum number of vertices to generate |
60
|