The current code:
def main():
# Open the environment in a new stage
print(f"Loading Stage {ENV_URL}")
open_stage(prefix_with_isaac_asset_server(ENV_URL))
# Create a custom scope for newly added prims
stage = get_current_stage()
scope = UsdGeom.Scope.Define(stage, SCOPE_NAME)
# Spawn a new forklift at a random pose
forklift_prim = prims.create_prim(
prim_path=f"{SCOPE_NAME}/Forklift",
position=(random.uniform(-20, -2), random.uniform(-1, 3), 0),
#position=(random.uniform(-50, -4), random.uniform(-1, 3), 0),
orientation=euler_angles_to_quat([0, 0, random.uniform(0, math.pi)]),
usd_path=prefix_with_isaac_asset_server(FORKLIFT_URL),
semantic_label="Forklift",
)
Spawns the forklift in a random location in the factory in the beginning and then in the trigger below, the rest of objects are randomized around it every frame. How can I do this for the initial forklift so that for example every 100 frames the forklift is spawn in a different and more diverse location of the warehouse?
Also, is there an opportunity for the cameras to take photos mid air or is it only able to take photos when objects are rested to the ground? I wasn’t able to find a code example for capturing thrown objects mid air.
with rep.trigger.on_frame(num_frames=CONFIG["num_frames"]):
# rep.randomizer.forklift_placement()
rep.randomizer.scatter_boxes()
#rep.randomizer.place_cones()
rep.randomizer.randomize_lights()
rep.randomizer.randomize_color()
pos_min = (pallet_pos_gf[0] - 2, pallet_pos_gf[1] - 2, 2)
pos_max = (pallet_pos_gf[0] + 2, pallet_pos_gf[1] + 2, 4)
with pallet_cam:
rep.modify.pose(position=rep.distribution.uniform(pos_min, pos_max), look_at=str(pallet_prim.GetPrimPath()))
#May be I should change this mona
with top_view_cam:
rep.modify.pose(
position=rep.distribution.uniform(
(foklift_pos_gf[0], foklift_pos_gf[1], 9), (foklift_pos_gf[0], foklift_pos_gf[1], 11)
),
rotation=rep.distribution.uniform((0, -90, 0), (0, -90, 180)),
)
I tried following how randomized scatter boxes is for forklift but I couldn’t make it work and I am not sure if it would apply anyway since forklift is the objects other objects are scattered around.
Here’s the error I kept getting with that setup:
2023-02-08 16:33:00 [10,739ms] [Warning] [rtx.neuraylib.plugin] Compiler Core: omniverse://localhost/NVIDIA/Assets/Isaac/2022.2.0/Isaac/Environments/Simple_Warehouse/Materials/MaterialInstanceDynamic_1220.mdl?watch=00007f114dc4ba70(61,8): C181 unused variable 'Local15'
2023-02-08 16:33:00 [10,739ms] [Warning] [rtx.neuraylib.plugin] Compiler Core: omniverse://localhost/NVIDIA/Assets/Isaac/2022.2.0/Isaac/Environments/Simple_Warehouse/Materials/MaterialInstanceDynamic_1220.mdl?watch=00007f114dc4ba70(61,8): C181 unused variable 'Local15'
2023-02-08 16:33:01 [11,611ms] [Warning] [omni.isaac.core.simulation_context.simulation_context] A new stage was opened, World or Simulation Object are invalidated and you would need to initialize them again before using them.
2023-02-08 16:33:01 [11,622ms] [Error] [__main__] Exception: 'Prim' object has no attribute 'get_attributes'
Traceback (most recent call last):
File "/home/mona/omniverse-sdg/offline_generation.py", line 791, in <module>
main()
File "/home/mona/omniverse-sdg/offline_generation.py", line 520, in main
forklift_prim = rep.randomizer.forklift_placement()
File "/home/mona/.local/share/ov/pkg/isaac_sim-2022.2.0/extscache/omni.replicator.core-1.6.4+104.1.lx64.r.cp37/omni/replicator/core/scripts/utils/utils.py", line 324, in __call__
return ReplicatorItem(self.__fn, *args, **kwargs)
File "/home/mona/.local/share/ov/pkg/isaac_sim-2022.2.0/extscache/omni.replicator.core-1.6.4+104.1.lx64.r.cp37/omni/replicator/core/scripts/utils/utils.py", line 351, in __init__
if is_execution_node(self.node, on_input_only=True):
File "/home/mona/.local/share/ov/pkg/isaac_sim-2022.2.0/extscache/omni.replicator.core-1.6.4+104.1.lx64.r.cp37/omni/replicator/core/scripts/utils/utils.py", line 254, in is_execution_node
for attribute in node.get_attributes():
AttributeError: 'Prim' object has no attribute 'get_attributes'
[11.707s] Simulation App Shutting Down