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

External asset + robot import script #902

Merged
merged 75 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
8fbdc06
Initial version of asset conversion utils
cgokmen Sep 18, 2024
ff0d34f
Scipy rotation to T
cgokmen Sep 18, 2024
2b3a7f4
Update public API of asset utils
cgokmen Sep 18, 2024
e18cf97
Documentation and cleanup
cgokmen Sep 18, 2024
80e8ce7
Start work on obj import
cgokmen Sep 23, 2024
cf0db52
Some more work, including replacing print with log
cgokmen Sep 23, 2024
cd02f5c
New entrypoint
cgokmen Sep 23, 2024
d992afb
Add logger
cgokmen Sep 23, 2024
4fce143
Add logger
cgokmen Sep 23, 2024
2a4d218
Some more fixes
cgokmen Sep 23, 2024
5b999f4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 24, 2024
02049d0
Merge branch 'og-develop' into asset-conversion
cgokmen Sep 24, 2024
5b1e0a1
Add support for user-added datasetobject
cgokmen Sep 24, 2024
b6b50c3
Update asset_conversion_utils.py
cgokmen Sep 25, 2024
cfbe5c9
Update asset_conversion_utils.py
cgokmen Sep 25, 2024
8fc8e8f
Add scale
cgokmen Sep 28, 2024
b240941
Merge branch 'og-develop' into asset-conversion
cgokmen Oct 1, 2024
86e74fa
Merge branch 'og-develop' into asset-conversion
cgokmen Oct 10, 2024
9713a88
Support importing textures
cgokmen Oct 11, 2024
6c24445
Merge branch 'og-develop' into asset-conversion
cremebrule Nov 19, 2024
72f1508
add urdfy utils
cremebrule Nov 25, 2024
1b90faf
update asset conversion utils for generalized asset imports
cremebrule Nov 25, 2024
b2bfcae
remove old asset import script
cremebrule Nov 25, 2024
54df654
update utils to support usda imports
cremebrule Nov 25, 2024
1f8ed23
standardize object imports from external datasets
cremebrule Nov 25, 2024
fa06d23
add updated import custom object example script
cremebrule Nov 25, 2024
970a9ea
add import custom robot script (WIP)
cremebrule Nov 25, 2024
066a336
Merge branch 'og-develop' into asset-conversion
cremebrule Nov 25, 2024
2a09f01
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 25, 2024
08bc8f4
Merge remote-tracking branch 'origin/asset-conversion' into asset-con…
cremebrule Nov 26, 2024
4e8765f
update for newest assets
cremebrule Nov 27, 2024
6c2b317
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 27, 2024
704c14e
add option to merge fixed joints, fix collision spheres logic, simpli…
cremebrule Dec 3, 2024
3e61ed8
set friction to 0 by default when importing robots
cremebrule Dec 3, 2024
9b24e2c
Merge remote-tracking branch 'origin/asset-conversion' into asset-con…
cremebrule Dec 3, 2024
edceabe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 3, 2024
462b16d
enforce max 60 vertex constraint
cremebrule Dec 6, 2024
25331ca
verify that all material paths are relative instead of absolute for p…
cremebrule Dec 6, 2024
74211fc
Merge remote-tracking branch 'origin/asset-conversion' into asset-con…
cremebrule Dec 6, 2024
12af115
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2024
3e5cb80
update all robot classes for refactored assets
cremebrule Dec 10, 2024
fb07969
handle edge cases when importing custom robots
cremebrule Dec 10, 2024
878ad6c
remove todos
cremebrule Dec 10, 2024
7727f35
Merge remote-tracking branch 'origin/asset-conversion' into asset-con…
cremebrule Dec 10, 2024
5f20029
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 10, 2024
117b11c
update example config
cremebrule Dec 10, 2024
b78a278
update custom robot import tutorial
cremebrule Dec 10, 2024
6c3922f
Merge remote-tracking branch 'origin/asset-conversion' into asset-con…
cremebrule Dec 10, 2024
f8b6922
Merge branch 'og-develop' into asset-conversion
cremebrule Dec 10, 2024
53eaa23
remove lula FK solver from curobo, fix typo in curobo test
cremebrule Dec 10, 2024
905fc13
fix bugs in curobo config generator during custom robot import
cremebrule Dec 11, 2024
a233df0
update default pose for R1 Pro model in curobo test
cremebrule Dec 11, 2024
c8600a6
tune object states test for new fetch asset
cremebrule Dec 11, 2024
43922ca
Merge branch 'og-develop' into asset-conversion
cremebrule Dec 11, 2024
541b15c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 11, 2024
863209b
fix grasping state inference for gripper controller
cremebrule Dec 12, 2024
e790e77
add attribution
cremebrule Dec 12, 2024
5971fbb
update sensor ground truth for new fetch robot test
cremebrule Dec 12, 2024
c71dda8
do not 0 friction during URDF->USD import process, update docs
cremebrule Dec 12, 2024
a375fca
Merge remote-tracking branch 'origin/asset-conversion' into asset-con…
cremebrule Dec 12, 2024
2f7a8f8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 12, 2024
2e9cb38
fix bugs in FOV robot object state
cremebrule Dec 12, 2024
1ca3f87
prune utils, update docs, update package deps version
cremebrule Dec 12, 2024
ee495ad
Merge remote-tracking branch 'origin/asset-conversion' into asset-con…
cremebrule Dec 12, 2024
f6b8a14
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 12, 2024
b4b7c21
update docs
cremebrule Dec 12, 2024
9392606
fix freight and locobot offsets
cremebrule Dec 12, 2024
b648a2f
update curobo dep version
cremebrule Dec 12, 2024
e515c8a
fix curobo naming convention
cremebrule Dec 12, 2024
73d757b
modify scene graph for updated robots
cremebrule Dec 12, 2024
ac165ef
ensure pillow compatibility with isaac pip prebundle
cremebrule Dec 12, 2024
1eb8e0e
add low pass filter for multi finger gripper to reduce velocity noise…
cremebrule Dec 12, 2024
813b4f7
align prim getter with inputted stage
cremebrule Dec 12, 2024
fea8975
rename EXTERNAL_DATASET -> CUSTOM_DATASET
cremebrule Dec 12, 2024
002a536
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 12, 2024
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
4 changes: 2 additions & 2 deletions docs/modules/object_states.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ These are object states that are agnostic to other objects in a given scene.
<tr>
<td valign="top" width="60%">
[**`ObjectsInFOVOfRobot`**](../reference/object_states/robot_related_states.md)<br><br>
A robot-specific state. Comptues the list of objects that are currently in the robot's field of view.<br><br>
A robot-specific state. Comptues the set of objects that are currently in the robot's field of view.<br><br>
<ul>
<li>`get_value()`: returns `obj_list`, the list of `BaseObject`s</li>
<li>`get_value()`: returns `obj_set`, the set of `BaseObject`s</li>
<li>`set_value(new_value)`: Not supported</li>
</ul>
</td>
Expand Down
1,146 changes: 989 additions & 157 deletions docs/tutorials/custom_robot_import.md

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions omnigibson/controllers/multi_finger_gripper_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# is_grasping heuristics parameters
m.POS_TOLERANCE = 0.002 # arbitrary heuristic
m.VEL_TOLERANCE = 0.01 # arbitrary heuristic
m.VEL_TOLERANCE = 0.02 # arbitrary heuristic


class MultiFingerGripperController(GripperController):
Expand Down Expand Up @@ -251,10 +251,9 @@ def _update_grasping_state(self, control_dict):
dist_from_lower_limit = finger_pos - min_pos
dist_from_upper_limit = max_pos - finger_pos

# If the joint positions are not near the joint limits with some tolerance (m.POS_TOLERANCE)
# If either of the joint positions are not near the joint limits with some tolerance (m.POS_TOLERANCE)
valid_grasp_pos = (
th.mean(dist_from_lower_limit) > m.POS_TOLERANCE
and th.mean(dist_from_upper_limit) > m.POS_TOLERANCE
th.mean(dist_from_lower_limit) > m.POS_TOLERANCE or th.mean(dist_from_upper_limit) > m.POS_TOLERANCE
)

# And the joint velocities are close to zero with some tolerance (m.VEL_TOLERANCE)
Expand Down
151 changes: 151 additions & 0 deletions omnigibson/examples/objects/import_custom_object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
"""
Helper script to download OmniGibson dataset and assets.
"""

import math
from typing import Literal

import click
import trimesh

import omnigibson as og
from omnigibson.utils.asset_conversion_utils import (
generate_collision_meshes,
generate_urdf_for_obj,
import_og_asset_from_urdf,
)
from omnigibson.utils.python_utils import assert_valid_key


@click.command()
@click.option(
"--asset-path",
required=True,
type=click.Path(exists=True, dir_okay=False),
help="Absolute path to asset file to import. This can be a raw visual mesh (for single-bodied, static objects), e.g. .obj, .glb, etc., or a more complex (such as articulated) objects defined in .urdf format.",
)
@click.option("--category", required=True, type=click.STRING, help="Category name to assign to the imported asset")
@click.option(
"--model",
required=True,
type=click.STRING,
help="Model name to assign to the imported asset. This MUST be a 6-character long string that exclusively contains letters, and must be unique within the given @category",
)
@click.option(
"--collision-method",
type=click.Choice(["coacd", "convex", "none"]),
default="coacd",
help="Method to generate the collision mesh. 'coacd' generates a set of convex decompositions, while 'convex' generates a single convex hull. 'none' will not generate any explicit mesh",
)
cremebrule marked this conversation as resolved.
Show resolved Hide resolved
@click.option(
"--hull-count",
type=int,
default=32,
help="Maximum number of convex hulls to decompose individual visual meshes into. Only relevant if --collision-method=coacd",
)
@click.option("--scale", type=float, default=1.0, help="Scale factor to apply to the mesh.")
@click.option("--up-axis", type=click.Choice(["z", "y"]), default="z", help="Up axis for the mesh.")
@click.option("--headless", is_flag=True, help="Run the script in headless mode.")
@click.option("--confirm-bbox", default=True, help="Whether to confirm the scale factor.")
@click.option("--overwrite", is_flag=True, help="Overwrite any pre-existing files")
def import_custom_object(
asset_path: str,
category: str,
model: str,
collision_method: Literal["coacd", "convex", "none"],
hull_count: int,
scale: float,
up_axis: Literal["z", "y"],
headless: bool,
confirm_bbox: bool,
overwrite: bool,
):
"""
Imports an externally-defined object asset into an OmniGibson-compatible USD format and saves the imported asset
files to the external dataset directory (gm.EXTERNAL_DATASET_PATH)
"""
assert len(model) == 6 and model.isalpha(), "Model name must be 6 characters long and contain only letters."
collision_method = None if collision_method == "none" else collision_method

# Sanity check mesh type
valid_formats = trimesh.available_formats()
mesh_format = asset_path.split(".")[-1]

# If we're not a URDF, import the mesh directly first
if mesh_format != "urdf":
assert_valid_key(key=mesh_format, valid_keys=valid_formats, name="mesh format")

# Load the mesh
visual_mesh: trimesh.Trimesh = trimesh.load(asset_path, force="mesh", process=False)

# Generate collision meshes if requested
collision_meshes = (
generate_collision_meshes(visual_mesh, method=collision_method, hull_count=hull_count)
if collision_method is not None
else []
)

# If the up axis is y, we need to rotate the meshes
ChengshuLi marked this conversation as resolved.
Show resolved Hide resolved
if up_axis == "y":
rotation_matrix = trimesh.transformations.rotation_matrix(math.pi / 2, [1, 0, 0])
visual_mesh.apply_transform(rotation_matrix)
for collision_mesh in collision_meshes:
collision_mesh.apply_transform(rotation_matrix)

# If the scale is nonzero, we apply it to the meshes
if scale != 1.0:
scale_transform = trimesh.transformations.scale_matrix(scale)
visual_mesh.apply_transform(scale_transform)
for collision_mesh in collision_meshes:
collision_mesh.apply_transform(scale_transform)

# Check the bounding box size and complain if it's larger than 3 meters
bbox_size = visual_mesh.bounding_box.extents
click.echo(f"Visual mesh bounding box size: {bbox_size}")

if confirm_bbox:
if any(size > 3.0 for size in bbox_size):
click.echo(
f"Warning: The bounding box sounds a bit large. Are you sure you don't need to scale? "
f"We just wanted to confirm this is intentional. You can skip this check by passing --no-confirm-bbox."
)
click.confirm("Do you want to continue?", abort=True)

elif any(size < 0.01 for size in bbox_size):
click.echo(
f"Warning: The bounding box sounds a bit small. Are you sure you don't need to scale? "
f"We just wanted to confirm this is intentional. You can skip this check by passing --no-confirm-bbox."
)
click.confirm("Do you want to continue?", abort=True)

# Generate the URDF
click.echo(f"Generating URDF for {category}/{model}...")
generate_urdf_for_obj(visual_mesh, collision_meshes, category, model, overwrite=overwrite)
click.echo("URDF generation complete!")

urdf_path = None
collision_method = None
else:
urdf_path = asset_path
collision_method = collision_method

# Convert to USD
import_og_asset_from_urdf(
category=category,
model=model,
urdf_path=urdf_path,
collision_method=collision_method,
hull_count=hull_count,
overwrite=overwrite,
use_usda=False,
)

# Visualize if not headless
if not headless:
click.echo("The asset has been successfully imported. You can view it and make changes and save if you'd like.")
while True:
og.sim.render()


if __name__ == "__main__":
import_custom_object()
Loading
Loading