Isaac Sim 利用Python实现虚拟现实仿真,并输出语义数据全流程

没写完呢:( 拽走开会去了

在 Isaac Sim 中,使用 Python 实现虚拟现实的仿真,并输出语义分割等数据,可以应用于ai模型训练等场景。注:我打算将传感器发布Ros话题的部分放到小车中。控制一个物体,对这个物体的状态发布imu等,觉得这样比较实际一点。

主要分为以下几个步骤点:

1.确定使用的模型文件,做好分类,写明调用路径。

2.对场景Stage做初步的设置,比如设定单位m或cm,重力的大小及方向,对场景添加物理等。

3.camera的角度设置,这是获取语义数据和rgb等数据的相机角度,多方位,全方面,不这样做的话图片数据相似度太高了。

4.对每个模型进行大小,缩放,角度等精细设置。

5.设置随机化帧数等。

6.设置获取的渲染图像的大小和类别,输出路径。

目前 Isaac Sim 的使用过程中遇到的Bug们:

1.小车刚体连接错误,没有形成闭合链。前一天晚上用着还好好的,第二天就报错不能用了,我人麻了。

2.时间戳为无效浮点值。

3.无法更新保存USD文件。

4.缓存更新失败。

  1. Nucleus 加载错误。

(问题1~4:卸载isaacsim重新下载。问题5:卸载Nucleus重新下载。sim论坛里的解决方法没有一点用,啧)

个人随机化代码:

注释部分按个人需要看看要不要开

python 复制代码
import omni.replicator.core as rep
import omni.usd
import asyncio
import numpy as np
from omni.isaac.core.world import World
from omni.isaac.core.prims import RigidPrimView
from omni.isaac.core.objects import DynamicCuboid
from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
import os
from PIL import Image
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import json
import omni.usd
from pxr import Usd, UsdGeom, UsdLux
import random
import time

stage = omni.usd.get_context().get_stage()

async def example():
    if World.instance():
        World.instance().clear_instance()
    world = World()

    stage = omni.usd.get_context().get_stage()
    UsdGeom.SetStageUpAxis


with rep.new_layer():

    # 小车
    CAR = 'omniverse://localhost/model/car_0702.usd'

    # <-----树木----->
    # 4.5m 树(绿色)
    PROPS_TREE = 'omniverse://localhost/Library/NVIDIA Package/Assets/Vegetation/Trees/Blue_Berry_Elder.usd'
    # 18m 树(绿色)
    TREE_BLACK_OAK = 'omniverse://localhost/Library/NVIDIA Package/Assets/Vegetation/Trees/Black_Oak.usd'

    # <-----草----->
    # 短草(绿色)
    PROPS_GRASS = 'omniverse://localhost/Library/NVIDIA Package/Assets/Vegetation/Shrub/Grass_Short_A.usd'
    # 中间带石头的条状草地 未配置
    ROCK_GRASS = 'omniverse://localhost/model/some_/Rocks_Grass_2/scene.usdc'

    # <-----灌木----->
    # 1.2m(高度到人类胸口) 灌木(绿色)
    PROPS_SHRUB = 'omniverse://localhost/Library/NVIDIA Package/Assets/Vegetation/Shrub/Holly.usd'
    # 0.9m(高度到人类腰部) 灌木(绿色)
    FOUNTAIN_GRASS_SHORT = 'omniverse://localhost/Library/NVIDIA Package/Assets/Vegetation/Shrub/Fountain_Grass_Short.usd'
    # 0.75m(高度到人类大腿中段) 灌木(绿色)
    BOXWOOD = 'omniverse://localhost/Library/NVIDIA Package/Assets/Vegetation/Shrub/Boxwood.usd'

    # <-----花朵----->
    # 小花(白色)
    PROPS_FLOWER = 'omniverse://localhost/model/some_/Margarita_flower/scene.usdc'
    # 一簇小花(白色)
    DAISIES_FLOWERS = 'omniverse://localhost/model/some_/Margarita_flower_bush/scene.usdc'

    # <-----场景障碍物----->
    # 木质公园椅(浅黄色)
    PARK_BENCH = 'omniverse://localhost/model/some_/Park_Bench2/scene.usdc'
    # 铁质公园椅(橙色)
    PARK_BENCH_2 = 'omniverse://localhost/model/some_/Park_Bech_Low-poly/scene.usdc'
    # 帐篷
    TENT = 'omniverse://localhost/model/some_/Camping_tent/scene.usdc'
    # 铁质秋千
    SEESAW = 'omniverse://localhost/model/some_/Recreational_place_Play_Children_Seesaw/scene.usdc'
    # 铁质滑梯
    SLIDE = 'omniverse://localhost/model/some_/the_slide_Park_Play_Child/scene.usdc'
    # 消防栓(红色)
    FIRE_HYDRANT = 'omniverse://localhost/model/some_/Rusty_Fire_Hydrant/scene.usdc'
    # 公园草地灯(下黑上白)
    LIGHT = 'omniverse://localhost/Library/NVIDIA Package/Residential/Outdoors/Lighting/CircularBollard.usd'

    # 木质箱(黄)
    PILES = 'omniverse://localhost/Library/NVIDIA Package/Assets/ArchVis/Industrial/Piles/'
    # 货架和货物(蓝色框架,纸质箱子)
    RACKS = 'omniverse://localhost/Library/NVIDIA Package/Assets/ArchVis/Industrial/Racks/'
    # 货架(蓝色框架)
    SHELVES = 'omniverse://localhost/Library/NVIDIA Package/Assets/ArchVis/Industrial/Shelves/'

    # 栏杆(黄色)
    RAILING = 'omniverse://localhost/Library/NVIDIA Package/Assets/ArchVis/Industrial/Railing/'

    # 砖块 (淡灰色)
    BRICK_GREY = 'omniverse://localhost/model/some_/brick/Brick/scene.usdc'
    # 砖块 (红色)杂乱一堆
    BRICK_RED_PILE = 'omniverse://localhost/model/some_/brick/Heap_of_construction_old_debris_bricks/scene.usdc'
    # 砖块 (红色)工整一堆
    BRICK_RED_CUBEQILE = 'omniverse://localhost/model/some_/brick/Stacked_bricks/scene.usdc'
    # 砖块 (红色)一块
    BRICK_RED_ONE = 'omniverse://localhost/model/some_/brick/Red_Brick/scene.usdc'

    # 松果 (两个未配置)
    PINE = 'omniverse://localhost/model/some_/pine/Empty_pine_cone/scene.usdc'
    PINE_02 = 'omniverse://localhost/model/some_/pine/Pine_Cone/scene.usdc'

    # <-----材质----->
    GROUND_MATERIAL = 'omniverse://localhost/Library/NVIDIA Package/Assets/Vegetation/Shrub/materials/Pampas_grass_Mat.mdl'

ground = rep.create.plane(scale=33, semantics=[('class', 'grass')], visible=True, parent='/World')  # 单位:m

# 相机参数
# camera = rep.create.camera(
#     position=rep.distribution.uniform((0,0,0), (100, 100, 100)),
#     rotation=(-90, 0, 0),
#     focus_distance=rep.distribution.normal(400.0, 100),
#     f_stop=0.5,
# )

# 1
# camera1_pos = [(-5, -5, 0.5),(0, 5, 0.5)]
# # camera2_pos = [(0, -5, 0.5),(5, 5, 0.5)]
# # 相机位置及旋转角度
# camera_look_at = (0, 0, 0)
# camera = rep.create.camera(position=camera1_pos[0], look_at = camera_look_at)


# camera2 = rep.create.camera(position=camera2_pos[0], look_at=(0,0,0))

# light = rep.create.light(
#     light_type="Distant",
#     intensity=3000,  # 光强度
#     angle=1,  # 角度
#     position=light_position,
#     rotation=(0, 0, 0)  # 光源旋转
# )

# 获取当前的 USD stage
stage = omni.usd.get_context().get_stage()

async def example():
    if World.instance():
        World.instance().clear_instance()
    world = World()

    stage = omni.usd.get_context().get_stage()
    UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.z)

    # 单位(m)
    # UsdGeom.SetStageMetersPerUnit(stage, 0.01)
    UsdGeom.SetStageMetersPerUnit(stage, 1.0)
    # # 新建一个物理场景
    # scene = UsdPhysics.Scene.Define(stage, "/physicsScene")

    # # 重力方向,下;重力大小,9.81m/s^2
    # scene.CreateGravityDirectionAttr().Set(Gf.Vec3f(0.0, 0.0, -1.0))
    # scene.CreateGravityMagnitudeAttr().Set(981.0)

    # 获取当前的 USD stage
    stage = omni.usd.get_context().get_stage()

    if stage:
        default_light_path = "/Environment/defaultLight"
        default_light_prim = stage.GetPrimAtPath(default_light_path)

        # 确保 defaultLight 原语存在
        if default_light_prim:
            # 设置 defaultLight 的可见性为不可见
            # visibility_attr = default_light_prim.GetAttribute('visibility')
            # if not visibility_attr:
            #     visibility_attr = default_light_prim.CreateAttribute('visibility', Sdf.ValueTypeNames.Token)
            # visibility_attr.Set('invisible')

            # 设置defaultLight 的 intensity
            intensity_attr = default_light_prim.GetAttribute('inputs:intensity')
            if not intensity_attr:
                intensity_attr = default_light_prim.CreateAttribute('inputs:intensity', Sdf.ValueTypeNames.Float)
            intensity_attr.Set(200.0)  # 设置 intensity 的值为 150.0

    # 使用系统时间戳作为随机数种子
    random_seed = int(time.time())
    np.random.seed(random_seed)
    random.seed(random_seed)

# 随机化光源
    # def disk_lights():
    #     lights = rep.create.light(
    #         light_type="Disk",
    #         # temperature=rep.distribution.normal(6500, 500),
    #         # intensity=rep.distribution.normal(3000, 500),
    #         temperature = 65000,
    #         # intensity = 20000,
    #         intensity = 4500,
    #         # 位置 均匀分布,范围
    #         position = camera1_pos[0],  # 光源位置与相机位置相同
    #         rotation = [90, -10, 0],
    #         # 比例 均匀分布
    #         scale = (2.0, 2.0, 1.0)
    #     )
    #     return lights.node
    # rep.randomizer.register(disk_lights)

    def dome_lights():
        lights = rep.create.light(
            light_type="Dome",

            # 色温 正态分布,均值6500,标准差500
            # 刚开始日出日落:2000k-3000k  蓝天白光:6500k  北方平均太阳光:7500k  
            # 模拟太阳光:5000k  白中明显带蓝:7000k-8000k
            # 欧洲商店灯光:4000k(美国4100k)
            temperature=rep.distribution.normal(2700, 100),
                    
            # 光强 正态分布,均值35000,标准差5000
            # 赤道地区光强大,随着纬度的增加而减少
            # 夏季光强大,冬季少
            # 植株密度大,植株间光强小
            # intensity=rep.distribution.normal(200, 50),
            intensity=rep.distribution.normal(200, 10),

            rotation= (360,0,0),
            texture=rep.distribution.choice([
                'omniverse://localhost/NVIDIA/Assets/Skies/Cloudy/champagne_castle_1_4k.hdr',
                'omniverse://localhost/NVIDIA/Assets/Skies/Clear/qwantani_4k.hdr'
                ])
                )
        return lights.node
    rep.randomizer.register(dome_lights)

# 随机地面纹理
    def get_ground():
        with ground:
            rep.randomizer.texture(
                textures=[
                    'omniverse://localhost/model/some_/Grass_with_autumn_leaves/0/material_0_baseColor.jpg'
                ],
                texture_scale=rep.distribution.uniform((35.0,35.0), (35.0, 35.0))  # 缩放
            )
        return ground.node

    rep.randomizer.register(get_ground)


# 车
    def get_car(size):
        instance_car = rep.randomizer.instantiate(rep.utils.get_usd_files(CAR, recursive=True), size=size)
        with instance_car:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),                  # 区域
                rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0)),                        # 角度
                scale=rep.distribution.uniform((1.0, 1.0, 1.0), (1.0, 1.0, 1.0))                # 缩放
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            # rep.physics.rigid_body(
            #     velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
            #     angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))

        # 设置固定路径
        fixed_path = "/Replicator/SampledAssets/car"
        instance_car.set_path(fixed_path)

        return instance_car.node
    rep.randomizer.register(get_car)

# 树
    # 4.5m 树(绿色)
    def get_tree(size):
        instances_tree = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_TREE, recursive=True), size=size)
        with instances_tree:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0)),
                scale=rep.distribution.uniform((0.008, 0.008, 0.008), (0.013, 0.013, 0.013))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_tree.node
    rep.randomizer.register(get_tree)

    # 18m 树(绿色)
    def get_tree_02(size):
        instances_tree_02 = rep.randomizer.instantiate(rep.utils.get_usd_files(TREE_BLACK_OAK, recursive=True), size=size)
        with instances_tree_02:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0)),
                scale=rep.distribution.uniform((0.008, 0.008, 0.008), (0.013, 0.013, 0.013))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_tree_02.node
    rep.randomizer.register(get_tree_02)

# 草
    # 短草(绿色)
    def get_grass(size):
        instances_grass = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_GRASS, recursive=True), size=size)
        with instances_grass:
            rep.modify.semantics([('class', 'grass')])
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0)),
                scale=rep.distribution.uniform((0.01, 0.01, 0.01), (0.02, 0.02, 0.017))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            # rep.physics.rigid_body(
            #     velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
            #     angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_grass.node
    rep.randomizer.register(get_grass)

# 花
    # 小花(白色)
    def get_flower(size):
        instance_files = rep.utils.get_usd_files(PROPS_FLOWER, recursive=True)
        instances_flower = rep.randomizer.instantiate(instance_files, size=size)
        with instances_flower:
            rep.modify.semantics([('class', 'grass')])
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((85, -15, -10), (95, 15, 10)),
                scale=rep.distribution.uniform((0.00035, 0.00035, 0.00035), (0.00042, 0.00042, 0.00042))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((90, -35, -10), (90, 35, 10)),
                # scale=rep.distribution.uniform((0.05, 0.05, 0.05), (0.15, 0.15, 0.15))
            )
            # rep.physics.rigid_body(
            #     velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
            #     angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_flower.node
    rep.randomizer.register(get_flower)

    # 一簇小花(白色)
    def get_daisies_flower(size):
        instances_daisies_flower = rep.randomizer.instantiate(rep.utils.get_usd_files(DAISIES_FLOWERS, recursive=True), size=size)
        with instances_daisies_flower:
            rep.modify.semantics([('class', 'grass')])
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, -3.05), (17, 17, -3)),
                rotation=rep.distribution.uniform((90, 0, 0), (90, 0, 0)),
                scale=rep.distribution.uniform((0.001, 0.001, 0.001), (0.001, 0.001, 0.001))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((90, -35, -10), (90, 35, 10)),
                # scale=rep.distribution.uniform((0.05, 0.05, 0.05), (0.15, 0.15, 0.15))
            )
            # rep.physics.rigid_body(
            #     velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
            #     angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_daisies_flower.node
    rep.randomizer.register(get_daisies_flower)

# 灌木
    # 1.2m(高度到人类胸口) 灌木(绿色)
    def get_shrub(size):
        instances_shrub = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_SHRUB, recursive=True), size=size)
        with instances_shrub:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((0, 0, -90), (0, 0, 90)),
                scale=rep.distribution.uniform((0.005, 0.005, 0.005), (0.008, 0.008, 0.008))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            # rep.physics.rigid_body(
            #     velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
            #     angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_shrub.node
    rep.randomizer.register(get_shrub)

    # 0.9m(高度到人类腰部) 灌木(绿色)
    def get_Fountain_Grass_Short(size):
        Fountain_Grass_Short = rep.randomizer.instantiate(rep.utils.get_usd_files(FOUNTAIN_GRASS_SHORT, recursive=True), size=size)
        with Fountain_Grass_Short:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-2, -2, 0), (0, 0, 0)),
                rotation=rep.distribution.uniform((0, 0, -90), (0, 0, 90)),
                scale=rep.distribution.uniform((0.005, 0.005, 0.005), (0.008, 0.008, 0.008))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            # rep.physics.rigid_body(
            #     velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
            #     angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return Fountain_Grass_Short.node
    rep.randomizer.register(get_Fountain_Grass_Short)

    # 0.75m(高度到人类大腿中段) 灌木(绿色)
    def get_Boxwood(size):
        Boxwood = rep.randomizer.instantiate(rep.utils.get_usd_files(BOXWOOD, recursive=True), size=size)
        with Boxwood:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-5, -5, 0), (-5, 5, 0)),
                rotation=rep.distribution.uniform((0, 0, -90), (0, 0, 90)),
                scale=rep.distribution.uniform((0.005, 0.005, 0.005), (0.008, 0.008, 0.008))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            # rep.physics.rigid_body(
            #     velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
            #     angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return Boxwood.node
    rep.randomizer.register(get_Boxwood)

# 障碍物
    # 木质公园椅(浅黄色)
    def get_park_bench(size):
        instances_park_bench = rep.randomizer.instantiate(rep.utils.get_usd_files(PARK_BENCH, recursive=True), size=size)
        with instances_park_bench:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((90, 0, 0), (90, 0, 0)),
                scale=rep.distribution.uniform((0.002, 0.002, 0.002), (0.002, 0.002, 0.002))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_park_bench.node
    rep.randomizer.register(get_park_bench)

    # 铁质公园椅(橙色)
    def get_park_bench_02(size):
        instances_park_bench_02 = rep.randomizer.instantiate(rep.utils.get_usd_files(PARK_BENCH_2, recursive=True), size=size)
        with instances_park_bench_02:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((90, 0, 0), (90, 0, 0)),
                scale=rep.distribution.uniform((0.018, 0.018, 0.018), (0.018, 0.018, 0.018))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_park_bench_02.node
    rep.randomizer.register(get_park_bench_02)

    # 帐篷
    def get_park_tent(size):
        instances_park_tent = rep.randomizer.instantiate(rep.utils.get_usd_files(TENT, recursive=True), size=size)
        with instances_park_tent:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-12, -12, 0), (12, 12, 0)),
                rotation=rep.distribution.uniform((90, 0, 0), (90, 0, 0)),
                scale=rep.distribution.uniform((0.01, 0.01, 0.01), (0.01, 0.01, 0.01))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_park_tent.node
    rep.randomizer.register(get_park_tent)

    # 铁质秋千
    def get_park_seesaw(size):
        instances_park_seesaw = rep.randomizer.instantiate(rep.utils.get_usd_files(SEESAW, recursive=True), size=size)
        with instances_park_seesaw:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 1), (17, 17, 1)),
                rotation=rep.distribution.uniform((90, 0, 0), (90, 0, 0)),
                scale=rep.distribution.uniform((0.008, 0.008, 0.008), (0.008, 0.008, 0.008))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_park_seesaw.node
    rep.randomizer.register(get_park_seesaw)

    # 铁质滑梯
    def get_park_slide(size):
        instances_park_slide = rep.randomizer.instantiate(rep.utils.get_usd_files(SLIDE, recursive=True), size=size)
        with instances_park_slide:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((90, 0, 0), (90, 0, 0)),
                scale=rep.distribution.uniform((0.005, 0.005, 0.005), (0.005, 0.005, 0.005))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_park_slide.node
    rep.randomizer.register(get_park_slide)

    # 消防栓(红色)
    def get_park_fire_hydrant(size):
        instances_park_fire_hydrant = rep.randomizer.instantiate(rep.utils.get_usd_files(FIRE_HYDRANT, recursive=True), size=size)
        with instances_park_fire_hydrant:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((90, 0, -45), (90, 0, 45)),
                scale=rep.distribution.uniform((0.002, 0.002, 0.002), (0.002, 0.002, 0.002))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_park_fire_hydrant.node
    rep.randomizer.register(get_park_fire_hydrant)

    # 公园草地灯(下黑上白)
    def get_park_light(size):
        instances_park_light = rep.randomizer.instantiate(rep.utils.get_usd_files(LIGHT, recursive=True), size=size)
        with instances_park_light:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_park_light.node
    rep.randomizer.register(get_park_light)

    # 木质箱(黄)
    def get_piles(size):
        instances_piles = rep.randomizer.instantiate(rep.utils.get_usd_files(PILES, recursive=True), size=size, mode='point_instance')
        with instances_piles:
            rep.modify.pose(
                position=rep.distribution.uniform((-10, -10, 0), (10, 10, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_piles.node
    rep.randomizer.register(get_piles)

    # 货架和货物(蓝色框架,纸质箱子)
    def get_racks(size):
        instances_racks = rep.randomizer.instantiate(rep.utils.get_usd_files(RACKS, recursive=True), size=size, mode='point_instance')
        with instances_racks:
            rep.modify.pose(
                position=rep.distribution.uniform((-10, -10, 0), (10, 10, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.004, 0.004, 0.004), (0.004, 0.004, 0.004))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_racks.node
    rep.randomizer.register(get_racks)

    # 货架(蓝色框架)
    def get_shelves(size):
        instances_shelves = rep.randomizer.instantiate(rep.utils.get_usd_files(SHELVES, recursive=True), size=size, mode='point_instance')
        with instances_shelves:
            rep.modify.pose(
                position=rep.distribution.uniform((-10, -10, 0), (10, 10, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.004, 0.004, 0.004), (0.004, 0.004, 0.004))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_shelves.node
    rep.randomizer.register(get_shelves)

    # 栏杆(黄色)
    def get_railing(size):
        instances_railing = rep.randomizer.instantiate(rep.utils.get_usd_files(RAILING, recursive=True), size=size, mode='point_instance')
        with instances_railing:
            rep.modify.pose(
                position=rep.distribution.uniform((-10, -5, 0), (-9, 5, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.005, 0.005, 0.005), (0.005, 0.005, 0.005))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_railing.node
    rep.randomizer.register(get_railing)

    # 砖块 (淡灰色)
    def get_brick_grey(size):
        instances_brick_grey = rep.randomizer.instantiate(rep.utils.get_usd_files(BRICK_GREY, recursive=True), size=size, mode='point_instance')
        with instances_brick_grey:
            rep.modify.pose(
                position=rep.distribution.uniform((-1, -1, 0), (1, 1, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.005, 0.005, 0.005), (0.005, 0.005, 0.005))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_brick_grey.node
    rep.randomizer.register(get_brick_grey)

    # 砖块 (红色)杂乱一堆
    def get_brick_red_pile(size):
        instances_brick_red_pile = rep.randomizer.instantiate(rep.utils.get_usd_files(BRICK_RED_PILE, recursive=True), size=size, mode='point_instance')
        with instances_brick_red_pile:
            rep.modify.pose(
                position=rep.distribution.uniform((-4, -4, -0.4), (4, 4, -0.4)),
                rotation=rep.distribution.uniform((90, 0, -45), (90, 0, 45)),
                scale=rep.distribution.uniform((0.005, 0.005, 0.005), (0.005, 0.005, 0.005))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_brick_red_pile.node
    rep.randomizer.register(get_brick_red_pile)

    # 砖块 (红色)工整一堆
    def get_brick_red_cubepile(size):
        instances_red_cubepile2 = rep.randomizer.instantiate(rep.utils.get_usd_files(BRICK_RED_CUBEQILE, recursive=True), size=size, mode='point_instance')
        with instances_red_cubepile2:
            rep.modify.pose(
                position=rep.distribution.uniform((-2, -2, -2.2), (3, 3, -2.2)),
                rotation=rep.distribution.uniform((90, 0, -45), (90, 0, 45)),
                scale=rep.distribution.uniform((0.005, 0.005, 0.005), (0.005, 0.005, 0.005))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_red_cubepile2.node
    rep.randomizer.register(get_brick_red_cubepile)

    # 砖块 (红色)一块
    def get_brick_red_one(size):
        instances_brick_red_one = rep.randomizer.instantiate(rep.utils.get_usd_files(BRICK_RED_ONE, recursive=True), size=size, mode='point_instance')
        with instances_brick_red_one:
            rep.modify.pose(
                position=rep.distribution.uniform((-3.5, -3.5, 0.1), (-1, -1, 0.1)),
                rotation=rep.distribution.uniform((90, 0, -45), (90, 0, 45)),
                scale=rep.distribution.uniform((0.0002, 0.0002, 0.0002), (0.0002, 0.0002, 0.0002))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_brick_red_one.node
    rep.randomizer.register(get_brick_red_one)

# 分区域生成模型
    # 短草(绿色)
    def get_grass_area1(size):
        instances_grass_area1 = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_GRASS, recursive=True), size=size)
        with instances_grass_area1:
            rep.modify.semantics([('class', 'grass')])
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (-2, -2, 0)),
                rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0)),
                scale=rep.distribution.uniform((0.01, 0.01, 0.01), (0.02, 0.02, 0.01))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_grass_area1.node
    rep.randomizer.register(get_grass_area1)
    def get_grass_area2(size):
        instances_grass_area2 = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_GRASS, recursive=True), size=size)
        with instances_grass_area2:
            rep.modify.semantics([('class', 'grass')])
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, 2, 0), (-2, 17, 0)),
                rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0)),
                scale=rep.distribution.uniform((0.01, 0.01, 0.01), (0.02, 0.02, 0.01))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_grass_area2.node
    rep.randomizer.register(get_grass_area2)
    def get_grass_area3(size):
        instances_grass_area3 = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_GRASS, recursive=True), size=size)
        with instances_grass_area3:
            rep.modify.semantics([('class', 'grass')])
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((2, -17, 0), (17, -2, 0)),
                rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0)),
                scale=rep.distribution.uniform((0.01, 0.01, 0.01), (0.02, 0.02, 0.01))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_grass_area3.node
    rep.randomizer.register(get_grass_area3)
    def get_grass_area4(size):
        instances_grass_area4 = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_GRASS, recursive=True), size=size)
        with instances_grass_area4:
            rep.modify.semantics([('class', 'grass')])
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((2, 2, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0)),
                scale=rep.distribution.uniform((0.01, 0.01, 0.01), (0.02, 0.02, 0.01))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_grass_area4.node
    rep.randomizer.register(get_grass_area4)

    # 小花(白色)
    def get_flower_area1(size):
        instances_flower_area1 = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_FLOWER, recursive=True), size=size)
        with instances_flower_area1:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (-2, -2, 0)),
                rotation=rep.distribution.uniform((85, -15, -10), (95, 15, 10)),
                scale=rep.distribution.uniform((0.00035, 0.00035, 0.00035), (0.00042, 0.00042, 0.00042))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_flower_area1.node
    rep.randomizer.register(get_flower_area1)
    def get_flower_area2(size):
        instances_flower_area2 = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_FLOWER, recursive=True), size=size)
        with instances_flower_area2:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, 2, 0), (-2, 17, 0)),
                rotation=rep.distribution.uniform((85, -15, -10), (95, 15, 10)),
                scale=rep.distribution.uniform((0.00035, 0.00035, 0.00035), (0.00042, 0.00042, 0.00042))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_flower_area2.node
    rep.randomizer.register(get_flower_area2)
    def get_flower_area3(size):
        instances_flower_area3 = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_FLOWER, recursive=True), size=size)
        with instances_flower_area3:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((2, -17, 0), (17, -2, 0)),
                rotation=rep.distribution.uniform((85, -15, -10), (95, 15, 10)),
                scale=rep.distribution.uniform((0.00035, 0.00035, 0.00035), (0.00042, 0.00042, 0.00042))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_flower_area3.node
    rep.randomizer.register(get_flower_area3)
    def get_flower_area4(size):
        instances_flower_area4 = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS_FLOWER, recursive=True), size=size)
        with instances_flower_area4:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((2, 2, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((85, -15, -10), (95, 15, 10)),
                scale=rep.distribution.uniform((0.00035, 0.00035, 0.00035), (0.00042, 0.00042, 0.00042))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_flower_area4.node
    rep.randomizer.register(get_flower_area4)


    # 木质箱(黄)
    def get_piles_area1(size):
        instances_piles_area1 = rep.randomizer.instantiate(rep.utils.get_usd_files(PILES, recursive=True), size=size)
        with instances_piles_area1:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-17, -17, 0), (-2, -2, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_piles_area1.node
    rep.randomizer.register(get_piles_area1)
    def get_piles_area2(size):
        instances_piles_area2 = rep.randomizer.instantiate(rep.utils.get_usd_files(PILES, recursive=True), size=size)
        with instances_piles_area2:
            rep.modify.pose(
                # 单位:m
                # position=rep.distribution.uniform((-17, 17, 0), (-2, 2, 0)),
                position=rep.distribution.uniform((-17, 2, 0), (-2, 17, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_piles_area2.node
    rep.randomizer.register(get_piles_area2)
    def get_piles_area3(size):
        instances_piles_area3 = rep.randomizer.instantiate(rep.utils.get_usd_files(PILES, recursive=True), size=size)
        with instances_piles_area3:
            rep.modify.pose(
                # 单位:m
                # position=rep.distribution.uniform((17, -17, 0), (2, -2, 0)),
                position=rep.distribution.uniform((2, -17, 0), (17, -2, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_piles_area3.node
    rep.randomizer.register(get_piles_area3)
    def get_piles_area4(size):
        instances_piles_area4 = rep.randomizer.instantiate(rep.utils.get_usd_files(PILES, recursive=True), size=size)
        with instances_piles_area4:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((2, 2, 0), (17, 17, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_piles_area4.node
    rep.randomizer.register(get_piles_area4)

    # 0.9m(高度到人类腰部) 灌木(绿色)
    def get_Fountain_area1(size):
        instances_Fountain_area1 = rep.randomizer.instantiate(rep.utils.get_usd_files(FOUNTAIN_GRASS_SHORT, recursive=True), size=size)
        with instances_Fountain_area1:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-5, -5, 0), (-2, -2, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_Fountain_area1.node
    rep.randomizer.register(get_Fountain_area1)
    def get_Fountain_area2(size):
        instances_Fountain_area2 = rep.randomizer.instantiate(rep.utils.get_usd_files(FOUNTAIN_GRASS_SHORT, recursive=True), size=size)
        with instances_Fountain_area2:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-5, 2, 0), (-2, 5, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_Fountain_area2.node
    rep.randomizer.register(get_Fountain_area2)
    def get_Fountain_area3(size):
        instances_Fountain_area3 = rep.randomizer.instantiate(rep.utils.get_usd_files(FOUNTAIN_GRASS_SHORT, recursive=True), size=size)
        with instances_Fountain_area3:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((2, -5, 0), (5, -2, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_Fountain_area3.node
    rep.randomizer.register(get_Fountain_area3)
    def get_Fountain_area4(size):
        instances_Fountain_area4 = rep.randomizer.instantiate(rep.utils.get_usd_files(FOUNTAIN_GRASS_SHORT, recursive=True), size=size)
        with instances_Fountain_area4:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((2, 2, 0), (5, 5, 0)), 
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_Fountain_area4.node
    rep.randomizer.register(get_Fountain_area4)

    # 0.75m(高度到人类大腿中段) 灌木(绿色)
    def get_Boxwood_area1(size):
        instances_Boxwood_area1 = rep.randomizer.instantiate(rep.utils.get_usd_files(BOXWOOD, recursive=True), size=size)
        with instances_Boxwood_area1:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-5, -10, 0), (-5, -5, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_Boxwood_area1.node
    rep.randomizer.register(get_Boxwood_area1)
    def get_Boxwood_area2(size):
        instances_Boxwood_area2 = rep.randomizer.instantiate(rep.utils.get_usd_files(BOXWOOD, recursive=True), size=size)
        with instances_Boxwood_area2:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((-10, 5, 0), (-5, 5, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_Boxwood_area2.node
    rep.randomizer.register(get_Boxwood_area2)
    def get_Boxwood_area3(size):
        instances_Boxwood_area3 = rep.randomizer.instantiate(rep.utils.get_usd_files(BOXWOOD, recursive=True), size=size)
        with instances_Boxwood_area3:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((5, -5, 0), (10, -5, 0)),
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_Boxwood_area3.node
    rep.randomizer.register(get_Boxwood_area3)
    def get_Boxwood_area4(size):
        instances_Boxwood_area4 = rep.randomizer.instantiate(rep.utils.get_usd_files(BOXWOOD, recursive=True), size=size)
        with instances_Boxwood_area4:
            rep.modify.pose(
                # 单位:m
                position=rep.distribution.uniform((5, 5, 0), (5, 10, 0)), 
                rotation=rep.distribution.uniform((0, 0, -45), (0, 0, 45)),
                scale=rep.distribution.uniform((0.007, 0.007, 0.007), (0.007, 0.007, 0.007))
                # 单位:cm
                # position=rep.distribution.uniform((-1000, -1000, 0), (1000, 1000, 0)),
                # rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 0))
            )
            rep.physics.rigid_body(
                velocity=rep.distribution.uniform((-0,0,-0),(0,0,0)),
                angular_velocity=rep.distribution.uniform((-0,0,-100),(0,0,0)))
        return instances_Boxwood_area4.node
    rep.randomizer.register(get_Boxwood_area4)

# 随机化
    with rep.trigger.on_frame(num_frames=1):
    # with rep.trigger.on_frame(num_frames=100,interval=10):
        # rep.randomizer.disk_lights()                    # 随机化光源
        rep.randomizer.dome_lights()                    # 随机穹顶
        rep.randomizer.get_ground()                     # 随机地面纹理
        # rep.randomizer.get_car(1)                       # 小车

        rep.randomizer.get_tree(15)                     # 4.5m 树(绿色)
        # rep.randomizer.get_tree_02(1)                   # 18m 树(绿色)

        rep.randomizer.get_grass(1200)                  # 短草(绿色)

        rep.randomizer.get_flower(450)                  # 小花(白色)
        rep.randomizer.get_daisies_flower(50)           # 一簇小花(白色)

        # rep.randomizer.get_shrub(10)                    # 1.2m(高度到人类胸口) 灌木(绿色)
        # rep.randomizer.get_Fountain_Grass_Short(10)     # 0.9m(高度到人类腰部) 灌木(绿色)
        # rep.randomizer.get_Boxwood(10)                  # 0.75m(高度到人类大腿中段) 灌木(绿色)

        # rep.randomizer.get_park_bench(3)                # 木质公园椅(浅黄色)
        # rep.randomizer.get_park_bench_02(3)             # 铁质公园椅(橙色)
        # rep.randomizer.get_park_tent(2)                 # 帐篷
        # rep.randomizer.get_park_seesaw(4)               # 铁质秋千
        # rep.randomizer.get_park_slide(4)                # 铁质滑梯
        # rep.randomizer.get_park_fire_hydrant(10)        # 消防栓(红色)

        # rep.randomizer.get_park_light(20)               # 公园草地灯(下黑上白)

        # rep.randomizer.get_piles(10)                    # 木质箱(黄)
        # rep.randomizer.get_racks(5)                     # 货架和货物(蓝色框架,纸质箱子)
        # rep.randomizer.get_shelves(5)                   # 货架(蓝色框架)
        # rep.randomizer.get_railing(10)                  # 栏杆(黄色)

        # rep.randomizer.get_brick_grey(10)               # 砖块 淡灰色  
        # rep.randomizer.get_brick_red_pile(3)            # 砖块 (红色)杂乱一堆
        # rep.randomizer.get_brick_red_cubepile(2)        # 砖块 (红色)工整一堆
        # rep.randomizer.get_brick_red_one(10)            # 砖块 (红色)一块


# 分区域进行随机化
# 在isaacsim中,俯视角,横轴x水平向右,纵轴y垂直向上
# 左下角为1区域,左上角为2区域,右下角为3区域,右上角为4区域
        # rep.randomizer.get_grass_area1(400)             # 短草(绿色)
        # rep.randomizer.get_grass_area2(400)
        # rep.randomizer.get_grass_area3(400)
        # rep.randomizer.get_grass_area4(400)

        # rep.randomizer.get_flower_area1(100)            # 小花(白色)
        # rep.randomizer.get_flower_area2(100)
        # rep.randomizer.get_flower_area3(100)
        # rep.randomizer.get_flower_area4(100)

        # rep.randomizer.get_piles_area1(10)              # 木质箱(黄)
        # rep.randomizer.get_piles_area2(10)
        # rep.randomizer.get_piles_area3(10)
        # rep.randomizer.get_piles_area4(10)

        # rep.randomizer.get_Fountain_area1(10)           # 0.9m(高度到人类腰部) 灌木(绿色)
        # rep.randomizer.get_Fountain_area2(10)
        # rep.randomizer.get_Fountain_area3(10)
        # rep.randomizer.get_Fountain_area4(10)

        # rep.randomizer.get_Boxwood_area1(15)            # 0.75m(高度到人类大腿中段) 灌木(绿色)
        # rep.randomizer.get_Boxwood_area2(15)
        # rep.randomizer.get_Boxwood_area3(15)
        # rep.randomizer.get_Boxwood_area4(15)

        # Initialize and attach writer

    # writer = rep.WriterRegistry.get("BasicWriter")
    # writer.initialize(
    #     output_dir= "/home/lxy/Desktop/Semantic_data/test",
    #     rgb=True,
    #     semantic_segmentation=True,
    #     colorize_semantic_segmentation=True,
    # )

# 2
    # writer.attach([render_product])
#         with camera:
#             rep.modify.pose(look_at=(0,0,0), position=rep.distribution.uniform(camera1_pos))
#         # with camera2:
#         #     rep.modify.pose(look_at=(0,0,0), position=rep.distribution.uniform(camera2_pos))
#         await asyncio.sleep(1)

# # 渲染图像大小
# # render_product = rep.create.render_product(camera, (1920, 1080))
# render_product = rep.create.render_product(camera, (640, 480))

# basic_writer = rep.WriterRegistry.get("BasicWriter")
# basic_writer.initialize(
#     output_dir= "/home/lxy/Desktop/Semantic_data/0704",
#     rgb=True,                               # RGB
#     semantic_segmentation=True,             # 语义分割
#     # bounding_box_2d_loose=True,             # 2D检测框(松散)
#     # bounding_box_2d_tight=True,             # 2D检测框(紧密)
#     # bounding_box_3d=True,                   # 3D检测框
#     # distance_to_camera=True,                # 到相机距离
#     # distance_to_image_plane=True,           # 到图像平面的距离
#     # instance_segmentation=True,             # 实例分割
#     # normals=True,                           # 法线
#     # bbox_height_threshold=5,                # 边界框高度阈值
#     # fully_visible_threshold=0.75,           # 视觉检测对象可见阈值
#     # omit_semantic_type=True                 # 是否忽略特定语义类型的对象或信息
# )

# basic_writer.attach([render_product])
rep.orchestrator.run()

asyncio.ensure_future(example())
相关推荐
yuwinter4 分钟前
鸿蒙HarmonyOS学习笔记(2)
笔记·学习·harmonyos
Bruce小鬼5 分钟前
QT文件基本操作
开发语言·qt
2202_7544215410 分钟前
生成MPSOC以及ZYNQ的启动文件BOOT.BIN的小软件
java·linux·开发语言
我只会发热17 分钟前
Java SE 与 Java EE:基础与进阶的探索之旅
java·开发语言·java-ee
LZXCyrus18 分钟前
【杂记】vLLM如何指定GPU单卡/多卡离线推理
人工智能·经验分享·python·深度学习·语言模型·llm·vllm
Enougme21 分钟前
Appium常用的使用方法(一)
python·appium
red_redemption26 分钟前
自由学习记录(23)
学习·unity·lua·ab包
懷淰メ27 分钟前
PyQt飞机大战游戏(附下载地址)
开发语言·python·qt·游戏·pyqt·游戏开发·pyqt5
hummhumm41 分钟前
第 22 章 - Go语言 测试与基准测试
java·大数据·开发语言·前端·python·golang·log4j
宁静@星空1 小时前
006-自定义枚举注解
java·开发语言