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_name='custom_dataset', use_omni_convex_decomp=False, use_usda=False, merge_fixed_joints=False)
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_name
|
str
|
The name of the dataset. |
'custom_dataset'
|
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
|
Returns:
| Type | Description |
|---|---|
2 - tuple
|
|
Source code in OmniGibson/omnigibson/utils/asset_conversion_utils.py
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 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 | |
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
1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 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 | |
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
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 2253 2254 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 | |
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
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 2117 2118 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 | |
import_obj_metadata(usd_path, obj_category, obj_model, dataset_root, 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 |
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
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 | |
import_og_asset_from_urdf(category, model, dataset_root, urdf_path=None, collision_method='coacd', coacd_links=None, convex_links=None, no_decompose_links=None, visual_only_links=None, merge_fixed_joints=False, 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_root) to @dataset_root
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_root 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
|
merge_fixed_joints
|
bool
|
Whether to merge fixed joints or not |
False
|
dataset_root
|
str
|
Dataset root directory to use for writing imported USD file. Default is custom dataset path set from the global macros |
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
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 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 | |
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
|