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.缓存更新失败。

        5. Nucleus 加载错误。

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

个人随机化代码:

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

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 timestage = 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.SetStageUpAxiswith 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 stagestage = 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 的 intensityintensity_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.noderep.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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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.noderep.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.noderep.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.noderep.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.noderep.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.noderep.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.noderep.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.noderep.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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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.noderep.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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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(# 单位:mposition=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.noderep.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())

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/41778.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

vue3 + 百度地图 实现多坐标生成轨迹的两种种方式

本次依然是关于百度地图中常见的一个问题&#xff0c;此次共使用了两种方式并做了一些分析及处理&#xff0c;希望有所帮助。如有问题可以评论或私信。 一、便捷方式 优点&#xff1a;便捷&#xff0c;所用的api方法是根据坐标进行计算后绘制路线&#xff0c;所以路线相对准确…

马尔可夫决策过程

马尔可夫决策过程&#xff08;Markov Decision Process&#xff0c;MDP&#xff09;是一种数学框架&#xff0c;用于建模决策者在不确定环境中的序列决策问题。MDP 的核心思想是基于马尔可夫性质&#xff0c;即未来的状态只依赖于当前状态和所采取的行动&#xff0c;而与过去的…

面试题006-Java-JVM(下)

面试题006-Java-JVM(下) 目录 面试题006-Java-JVM(下)题目自测题目答案1. 为什么需要GC&#xff1f;2. 有哪些常见的GC&#xff1f;3. Minor GC 和 Full GC有什么区别&#xff1f;4. 如何判断一个对象是否死亡&#xff1f;5. 讲一下可达性分析算法的流程&#xff1f;6. 如何判断…

CentOS修复OpenSSH漏洞升级到openssh 9.7 RPM更新包

在做政府和学校单位网站时&#xff0c;经常需要服务器扫描检测&#xff0c;经常被OpenSSH Server远程代码执行漏洞&#xff08;CVE-2024-6387&#xff09;安全风险通告&#xff0c;出了报告需要升级OpenSSH。 使用yum update openssh是无法更新到最新的&#xff0c;因为系统里的…

VS code修改底部的行号的状态栏颜色

VSCode截图 相信很多小伙伴被底部的蓝色状态栏困扰很久了 处理的方式有两种&#xff1a; 1、隐藏状态栏 2、修改其背景颜色 第一种方法大伙都会&#xff0c;今天就使用第二种方法。 1、点击齿轮进入setting 2、我现在用的新版本&#xff0c;设置不是以前那种json格式展示&…

17-JS封装:工具类方法

目录 一、extend方法 二、添加一些工具类方法&#xff1a;$.xxx() 实现1&#xff1a; 实现2&#xff1a; 一、extend方法 jQuery.fn.extend jQuery.extend function(...args){let target,source[];source[...args];//判断2种情况 //$.extend({}) -->给$添加属性//$.…

计算机提示由于找不到concrt140.dll怎么办,7种解决方法可以对比

在电脑中打开游戏或许软件出现找不到concrt140.dll无法继续执行代码怎么办&#xff1f;concrt140.dll是什么&#xff1f;丢失要怎么解决&#xff1f;下面给大家分析一下concrt140.dll文件是什么与concrt140.dll丢失的多种解决方法&#xff01;相信对你有帮助&#xff01; 一、c…

hdu物联网硬件实验2 GPIO亮灯

学院 班级 学号 姓名 日期 成绩 实验题目 GPIO亮灯 实验目的 点亮三个灯闪烁频率为一秒 硬件原理 无 关键代码及注释 const int ledPin1 GREEN_LED; // the number of the LED pin const int ledPin2 YELLOW_LED; const int ledPin3 RED…

Spring Boot与Spring Cloud Config的集成

Spring Boot与Spring Cloud Config的集成 大家好&#xff0c;我是免费搭建查券返利机器人省钱赚佣金就用微赚淘客系统3.0的小编&#xff0c;也是冬天不穿秋裤&#xff0c;天冷也要风度的程序猿&#xff01; 一、Spring Cloud Config简介与背景 在微服务架构中&#xff0c;配…

FPGA开发笔试1

1. 流程简介 我是两天前有FPGA公司的HR来问我实习的事情&#xff0c;她当时问我距离能不能接受&#xff0c;不过确实距离有点远&#xff08;地铁通勤要将近一个半小时&#xff09;&#xff0c;然后她说给我约个时间&#xff0c;抽空做1个小时的题目&#xff08;线上做&#xf…

2024年【金属非金属矿山(地下矿山)安全管理人员】考试报名及金属非金属矿山(地下矿山)安全管理人员模拟考试题

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 2024年金属非金属矿山&#xff08;地下矿山&#xff09;安全管理人员考试报名为正在备考金属非金属矿山&#xff08;地下矿山&#xff09;安全管理人员操作证的学员准备的理论考试专题&#xff0c;每个月更新的金属非…

CTF常用sql注入(三)无列名注入

0x06 无列名 适用于无法正确的查出结果&#xff0c;比如把information_schema给过滤了 join 联合 select * from users;select 1,2,3 union select * from users;列名被替换成了1,2,3&#xff0c; 我们再利用子查询和别名查 select 2 from (select 1,2,3 union select * f…

Go语言--工程管理、临时/永久设置GOPATH、main函数以及init函数

工作区 Go 代码必须放在工作区中。工作区其实就是一个对应于特定工程的目录&#xff0c;它应包含3个子目录:src 目录、pkg目录和bin 目录。 src 目录:用于以代码包的形式组织并保存 Go源码文件。(比如:.go.chs等)pkg 目录:用于存放经由 go install 命令构建安装后的代码包(包…

芯片基识 | 掰开揉碎讲 FIFO(同步FIFO和异步FIFO)

文章目录 一、什么是FIFO二、为什么要用FIFO三、什么时候用FIFO四、FIFO分类五、同步FIFO1. 同步FIFO电路框图2. 同步FIFO空满判断3. 同步FIFO设计代码4. 同步FIFO仿真结果 六、异步FIFO1、异步FIFO的电路框图2 、亚稳态3、打两拍4、格雷码5、如何判断异步FIFO的空满&#xff0…

react v18 less使用(craco)

方案一、弹出配置&#xff08;不推荐&#xff09; 安装依赖&#xff1a;yarn add less less-loader 首先 执行 yarn eject 弹出配置项文件&#xff08;注意&#xff1a;弹出配置不可逆&#xff01;&#xff09; 在 config 文件夹中 找到 webpack.config.js&#xff0c;在如图…

Spring Boot自动配置详解

Spring Boot自动配置详解 大家好&#xff0c;我是免费搭建查券返利机器人省钱赚佣金就用微赚淘客系统3.0的小编&#xff0c;也是冬天不穿秋裤&#xff0c;天冷也要风度的程序猿&#xff01;今天我们来详细探讨Spring Boot的自动配置机制。Spring Boot自动配置是其核心特性之一…

爆破片和安全阀

一、爆破片介绍 爆破片是一种用于安全释放压力的结构&#xff0c;通常应用于压力容器、管道和设备中&#xff0c;以防止由于压力过高而导致的灾难性故障。在压力超过设定值时&#xff0c;爆破片会破裂&#xff0c;从而迅速将过压泄放&#xff0c;保护设备和人员安全 爆破片通常…

Java并发编程详解

在现代软件开发中&#xff0c;多线程和并发编程是提高应用程序性能的关键技术之一。Java提供了丰富的并发编程工具&#xff0c;使得开发者能够高效地实现多线程应用。本文将详细介绍Java中的线程和并发工具&#xff0c;探讨线程安全的概念&#xff0c;并分享实现线程安全的方法…

java Web 优秀本科毕业论文系统用eclipse定制开发mysql数据库BS模式java编程jdbc

一、源码特点 JSP 优秀本科毕业论文系统是一套完善的web设计系统&#xff0c;对理解JSP java serlvet 编程开发语言有帮助&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用B/S模式开发。开发环境为TOMCAT7.0,eclipse开发&#xff0c;数据库为Mysql5.0&a…

Selenium的这些自动化测试技巧你知道几个?

Selenium自动化测试技巧 与以前瀑布式开发模式不同&#xff0c;现在软件测试人员具有使用自动化工具执行测试用例套件的优势&#xff0c;而以前&#xff0c;测试人员习惯于通过测试脚本执行来完成测试。 但自动化测试的目的不是完全摆脱手动测试&#xff0c;而是最大程度地减少…