I am initially spawning a forklift after main() and then spawn other objects every frame around it.
So, now, I am interested in changing the location of spawn forklift every frame too.
Could you guide me how to fix this?
The code is:
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()
floor_prims = [x.GetPath() for x in stage.Traverse() if "SM_floor" in x.GetName() and prims_utils.get_prim_type_name(x.GetPath()) == "Xform"]
bb_cache = bounds_utils.create_bbox_cache()
combined_range_arr = bounds_utils.compute_combined_aabb(bb_cache, prim_paths=floor_prims)
margin = 0.5
min_x, min_y, min_z, max_x, max_y, max_z = combined_range_arr
position = (np.random.uniform(min_x + margin, max_x - margin), # x
np.random.uniform(min_y + margin, max_y - margin), # y
0) # z
scope = UsdGeom.Scope.Define(stage, SCOPE_NAME) # mona score is not used anywhere!!!
# Spawn a custom forklift at a random pose
forklift_prim = prims.create_prim(
prim_path=f"{SCOPE_NAME}/Custom_Forklift",
position = position,
orientation=euler_angles_to_quat([0, 0, random.uniform(0, math.pi)]), random.uniform(0, math.pi)]),
usd_path=CUSTOM_FORKLIFT_URL,
semantic_label="Forklift",
)
with rep.trigger.on_frame(num_frames=CONFIG["num_frames"]):
position = (np.random.uniform(min_x + margin, max_x - margin), # x
np.random.uniform(min_y + margin, max_y - margin), # y
0) # z
rep.randomizer.scatter_boxes()
rep.randomizer.randomize_lights()
rep.randomizer.randomize_color()
with forklift_prim:
rep.modify.pose(
position=position,
rotation=rep.distribution.uniform((-90,-180, 0), (-90, 180, 0)),
)
The error is:
2023-02-21 18:16:26 [24,074ms] [Warning] [omni.physx.plugin] PhysicsUSD: Parse collision - triangle mesh collision (approximation None/MeshSimplifixation) without SDF cannot be a part of a dynamic body, falling back to convexHull approximation: /MyScope/SimulatedCardbox_44/SM_CardBoxD_04. To enable SDF collisions, sdfResolution should be > 0.
2023-02-21 18:16:26 [24,074ms] [Warning] [omni.physx.plugin] PhysicsUSD: Parse collision - triangle mesh collision (approximation None/MeshSimplifixation) without SDF cannot be a part of a dynamic body, falling back to convexHull approximation: /MyScope/SimulatedCardbox_45/SM_CardBoxD_04. To enable SDF collisions, sdfResolution should be > 0.
2023-02-21 18:16:26 [24,074ms] [Warning] [omni.physx.plugin] PhysicsUSD: Parse collision - triangle mesh collision (approximation None/MeshSimplifixation) without SDF cannot be a part of a dynamic body, falling back to convexHull approximation: /MyScope/SimulatedCardbox_46/SM_CardBoxD_04. To enable SDF collisions, sdfResolution should be > 0.
2023-02-21 18:16:26 [24,074ms] [Warning] [omni.physx.plugin] PhysicsUSD: Parse collision - triangle mesh collision (approximation None/MeshSimplifixation) without SDF cannot be a part of a dynamic body, falling back to convexHull approximation: /MyScope/SimulatedCardbox_47/SM_CardBoxD_04. To enable SDF collisions, sdfResolution should be > 0.
2023-02-21 18:16:26 [24,074ms] [Warning] [omni.physx.plugin] PhysicsUSD: Parse collision - triangle mesh collision (approximation None/MeshSimplifixation) without SDF cannot be a part of a dynamic body, falling back to convexHull approximation: /MyScope/SimulatedCardbox_48/SM_CardBoxD_04. To enable SDF collisions, sdfResolution should be > 0.
2023-02-21 18:16:26 [24,074ms] [Warning] [omni.physx.plugin] PhysicsUSD: Parse collision - triangle mesh collision (approximation None/MeshSimplifixation) without SDF cannot be a part of a dynamic body, falling back to convexHull approximation: /MyScope/SimulatedCardbox_49/SM_CardBoxD_04. To enable SDF collisions, sdfResolution should be > 0.
Simulation stopped after 217 steps
2023-02-21 18:16:29 [26,988ms] [Warning] [carb.flatcache.plugin] UsdRelationship /Replicator/SDGPipeline/OgnGroup_08.inputs:prims has multiple targets, which is not supported
/buildAgent/work/f25a4639a4b1bdc1/source/foundation/FdFoundation.cpp (162) : invalid operation : Foundation object exists already. Only one instance per process can be created.
inspect.signature(rep.randomizer.scatter_2d): (surface_prims: Union[omni.replicator.core.scripts.utils.utils.ReplicatorItem, List[str]], seed: int = None, offset: int = 0, check_for_collisions: bool = False, input_prims: Union[omni.replicator.core.scripts.utils.utils.ReplicatorItem, List[str]] = None)
2023-02-21 18:16:37 [35,141ms] [Error] [__main__] Exception: __enter__
Traceback (most recent call last):
File "/home/mona/SDG/omniverse-sdg/offline_generation.py", line 752, in <module>
main()
File "/home/mona/SDG/omniverse-sdg/offline_generation.py", line 599, in main
with forklift_prim:
AttributeError: __enter__
[35.521s] Simulation App Shutting Down