Skip to content

Commit

Permalink
Added everything I missed for Omniverse Replicator. Fixed README
Browse files Browse the repository at this point in the history
  • Loading branch information
davesarmoury committed Feb 1, 2023
1 parent 85e323c commit 4974af3
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Cornhole
# Follow Mini Me!

All files necessary for autonomous off-road navigation of the La Z Bot!
All files necessary for autonomous tracker following

[<img src="https://img.youtube.com/vi/h0uvkaR6fvo/0.jpg">](https://youtu.be/h0uvkaR6fvo)
[<img src="https://img.youtube.com/vi/YfQvBd4r_QU/0.jpg">](https://www.youtube.com/watch?v=YfQvBd4r_QU)

## License
<a rel="license" href="http://creativecommons.org/licenses/by/3.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/3.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.
59 changes: 59 additions & 0 deletions followminime_omniverse/HouseRender.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import omni.replicator.core as rep

with rep.new_layer():
# Define paths for the character, the props, the environment and the surface where the assets will be scattered in.

TRACKER = 'omniverse://localhost/Projects/FollowMe/TrackerTarget.usdc'
SURFACE = 'omniverse://localhost/NVIDIA/Assets/Scenes/Templates/Basic/display_riser.usd'
# Environments. Large so not swapping
PUDDLES = 'omniverse://localhost/NVIDIA/Assets/Scenes/Templates/Outdoor/Puddles.usd'
PARK='omniverse://localhost/NVIDIA/Assets/Scenes/Templates/Basic/abandoned_parking_lot.usd'
WAREHOUSE='omniverse://localhost/NVIDIA/Assets/XR/Stages/Indoor/Warehouse_XR.usd'
INDOOR='omniverse://localhost/NVIDIA/Assets/XR/Stages/Indoor/Modern_House_XR.usd'

ENVS=INDOOR

def tracker():
tracker = rep.create.from_usd(TRACKER, semantics=[('class', 'tracker')])

with tracker:
rep.modify.pose(
position=rep.distribution.uniform((-200, 100, -200), (200, 200, 200)),
rotation=rep.distribution.uniform((-90,-90, 0), (-90, 90, 0)),
)
return tracker

# Register randomization
rep.randomizer.register(tracker)

# Rotate the world so it is correct
env = rep.create.from_usd(ENVS)
with env:
rep.modify.pose(
position=(-450,0,550),
rotation=(-90,0, 0),
)
# Make the surface tiny so you can't see it in renders, and move it around so the shots are more varied
surface = rep.create.from_usd(SURFACE)
with surface:
rep.modify.pose(
position=rep.distribution.uniform((0, 100, 0), (0, 200, 0)),
scale=(0.001, 0.001, 0.001),
)

# Setup camera and attach it to render product
camera = rep.create.camera(
focus_distance=600,
f_stop=1.8
)
render_product = rep.create.render_product(camera, resolution=(1920, 1080))

# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir="Kitchen", rgb=True, bounding_box_2d_tight=True)
writer.attach([render_product])

with rep.trigger.on_frame(num_frames=100):
rep.randomizer.tracker()
with camera:
rep.modify.pose(position=rep.distribution.uniform((-200, 100, -200), (200, 200, 200)), look_at=surface)
76 changes: 76 additions & 0 deletions followminime_omniverse/OutdoorRender.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import omni.replicator.core as rep

with rep.new_layer():
# Define paths for the character, the props, the environment and the surface where the assets will be scattered in.

TRACKER = 'omniverse://localhost/Projects/FollowMe/TrackerTarget.usdc'
SURFACE = 'omniverse://localhost/NVIDIA/Assets/Scenes/Templates/Basic/display_riser.usd'
# Environments. Large so not swapping
PUDDLES = 'omniverse://localhost/NVIDIA/Assets/Scenes/Templates/Outdoor/Puddles.usd'
PARK='omniverse://localhost/NVIDIA/Assets/Scenes/Templates/Basic/abandoned_parking_lot.usd'
WAREHOUSE='omniverse://localhost/NVIDIA/Assets/XR/Stages/Indoor/Warehouse_XR.usd'
INDOOR='omniverse://localhost/NVIDIA/Assets/XR/Stages/Indoor/Modern_House_XR.usd'
# Prop Sets
INDOOR_PROPS = 'omniverse://localhost/Projects/FollowMe/Indoor'
OUTDOOR_PROPS='omniverse://localhost/Projects/FollowMe/Outdoor'
INDUSTRIAL_PROPS='omniverse://localhost/Projects/FollowMe/Industrial'

PROPS=OUTDOOR_PROPS
ENVS=PUDDLES

# Define randomizer function for Base assets. This randomization includes placement and rotation of the assets on the surface.
def env_props(size=50):
instances = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS, True), size=size, mode='point_instance')
with instances:
rep.modify.pose(
position=rep.distribution.uniform((-1000, 0, -1000), (1000, 0, 1000)),
rotation=rep.distribution.uniform((-90,-180, 0), (-90, 180, 0)),
)
return instances.node

def tracker():
tracker = rep.create.from_usd(TRACKER, semantics=[('class', 'tracker')])

with tracker:
rep.modify.pose(
position=rep.distribution.uniform((-300, 100, -300), (300, 300, 300)),
rotation=rep.distribution.uniform((-90,-90, 0), (-90, 90, 0)),
)
return tracker

# Register randomization
rep.randomizer.register(env_props)
rep.randomizer.register(tracker)

# Rotate the world so it is correct
env = rep.create.from_usd(ENVS)
with env:
rep.modify.pose(
position=(0,0,0),
rotation=(0,0, 0),
)
# Make the surface tiny so you can't see it in renders, and move it around so the shots are more varied
surface = rep.create.from_usd(SURFACE)
with surface:
rep.modify.pose(
position=rep.distribution.uniform((0, 100, 0), (0, 250, 0)),
scale=(0.001, 0.001, 0.001),
)

# Setup camera and attach it to render product
camera = rep.create.camera(
focus_distance=800,
f_stop=1.8
)
render_product = rep.create.render_product(camera, resolution=(1920, 1080))

# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir="Outdoor", rgb=True, bounding_box_2d_tight=True)
writer.attach([render_product])

with rep.trigger.on_frame(num_frames=500):
rep.randomizer.env_props(25)
rep.randomizer.tracker()
with camera:
rep.modify.pose(position=rep.distribution.uniform((-1000, 20, -1000), (1000, 500, 1000)), look_at=surface)
Binary file added followminime_omniverse/TrackerTarget.blend
Binary file not shown.
Binary file added followminime_omniverse/TrackerTarget.stl
Binary file not shown.
Binary file added followminime_omniverse/TrackerTarget.usdc
Binary file not shown.
76 changes: 76 additions & 0 deletions followminime_omniverse/WarehouseRender.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import omni.replicator.core as rep

with rep.new_layer():
# Define paths for the character, the props, the environment and the surface where the assets will be scattered in.

TRACKER = 'omniverse://localhost/Projects/FollowMe/TrackerTarget.usdc'
SURFACE = 'omniverse://localhost/NVIDIA/Assets/Scenes/Templates/Basic/display_riser.usd'
# Environments. Large so not swapping
PUDDLES = 'omniverse://localhost/NVIDIA/Assets/Scenes/Templates/Outdoor/Puddles.usd'
PARK='omniverse://localhost/NVIDIA/Assets/Scenes/Templates/Basic/abandoned_parking_lot.usd'
WAREHOUSE='omniverse://localhost/NVIDIA/Assets/XR/Stages/Indoor/Warehouse_XR.usd'
INDOOR='omniverse://localhost/NVIDIA/Assets/XR/Stages/Indoor/Modern_House_XR.usd'
# Prop Sets
INDOOR_PROPS = 'omniverse://localhost/Projects/FollowMe/Indoor'
OUTDOOR_PROPS='omniverse://localhost/Projects/FollowMe/Outdoor'
INDUSTRIAL_PROPS='omniverse://localhost/Projects/FollowMe/Industrial'

PROPS=INDUSTRIAL_PROPS
ENVS=WAREHOUSE

# Define randomizer function for Base assets. This randomization includes placement and rotation of the assets on the surface.
def env_props(size=50):
instances = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS, True), size=size, mode='point_instance')
with instances:
rep.modify.pose(
position=rep.distribution.uniform((-1000, 0, -1000), (1000, 0, 1000)),
rotation=rep.distribution.uniform((-90,-180, 0), (-90, 180, 0)),
)
return instances.node

def tracker():
tracker = rep.create.from_usd(TRACKER, semantics=[('class', 'tracker')])

with tracker:
rep.modify.pose(
position=rep.distribution.uniform((-300, 100, -300), (300, 300, 300)),
rotation=rep.distribution.uniform((-90,-90, 0), (-90, 90, 0)),
)
return tracker

# Register randomization
rep.randomizer.register(env_props)
rep.randomizer.register(tracker)

# Rotate the world so it is correct
env = rep.create.from_usd(ENVS)
with env:
rep.modify.pose(
position=(0,0,0),
rotation=(-90,0, 0),
)
# Make the surface tiny so you can't see it in renders, and move it around so the shots are more varied
surface = rep.create.from_usd(SURFACE)
with surface:
rep.modify.pose(
position=rep.distribution.uniform((0, 100, 0), (0, 250, 0)),
scale=(0.001, 0.001, 0.001),
)

# Setup camera and attach it to render product
camera = rep.create.camera(
focus_distance=800,
f_stop=1.8
)
render_product = rep.create.render_product(camera, resolution=(1920, 1080))

# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir="Warehouse", rgb=True, bounding_box_2d_tight=True)
writer.attach([render_product])

with rep.trigger.on_frame(num_frames=500):
rep.randomizer.env_props(15)
rep.randomizer.tracker()
with camera:
rep.modify.pose(position=rep.distribution.uniform((-1000, 20, -1000), (1000, 500, 1000)), look_at=surface)

0 comments on commit 4974af3

Please sign in to comment.