IsaacLab笔记(1)利用standalone python创建场景

IsaacSim主要有三种工作流:GUI界面,Extension以及standalone方式,对于python编程,一般使用Extension以及standalone,Extension一般依托交互界面,standalone模式直接调用IsaacSim的Core API,不依赖界面交互,更加适合平时的大规模仿真任务。

下面采用standalone的方式进行简单的场景设置

python 复制代码
from isaacsim import SimulationApp
simulation_app = SimulationApp({"headless": False})

import omni.usd
from pxr import UsdLux, Sdf, Gf

from isaacsim.core.api import World
from isaacsim.core.api.objects import DynamicCuboid
import numpy as np

world = World(stage_units_in_meters=1.0)
world.scene.add_default_ground_plane()

# stage = omni.usd.get_context().get_stage()
# sun_light = UsdLux.DistantLight.Define(stage, Sdf.Path("/World/SunLight"))
# sun_light.CreateIntensityAttr(500.0) 
# sun_light.CreateColorAttr(Gf.Vec3f(1.0, 1.0, 0.95))  

fancy_cube = world.scene.add(
    DynamicCuboid(
        prim_path="/World/random_cube",
        name="fancy_cube",
        position=np.array([0, 0, 2.000]),
        scale=np.array([0.5015, 0.505, 0.5015]),
        size=1.0,
        color=np.array([0, 0, 1.0]),
    )
)


for i in range(2000):
    position, orientation = fancy_cube.get_world_pose()
    linear_velocity = fancy_cube.get_linear_velocity()
    print("Cube position is : " + str(position))
    print("Cube's orientation is : " + str(orientation))
    print("Cube's linear velocity is : " + str(linear_velocity))
    # we have control over stepping physics and rendering in this workflow
    # things run in sync
    world.step(render=True)  # execute one physics step and one rendering step
world.reset()
simulation_app.close()

该代码通过DynamicCuboid类添加一个动态立方体,并仿真获取其位姿,速度信息。

运行一下指令,切换成你自己创建的代码路径

bash 复制代码
./python.sh /home/sun/isaac-sim/standalone_examples/api/isaacsim.aa.pick_cube/enviroment.py

点击运行会发现蓝色方块掉落,终端输出信息

相关推荐
AA陈超2 小时前
ASC学习笔记0022:在不打算修改属性集时访问生成的属性集
c++·笔记·学习·ue5·虚幻引擎·unreal engine
01100001乄夵3 小时前
第六课:仿真进阶与调试技巧
经验分享·笔记·学习方法
kanimito3 小时前
大语言模型入门指南:从科普到实战的技术笔记(2)
人工智能·笔记·语言模型
Bin二叉3 小时前
南京大学cpp复习——面向对象第一部分(构造函数,拷贝构造函数,析构函数,移动构造函数,友元)
c++·笔记·学习
爱奥尼欧3 小时前
【QT笔记】常用控件——QWidget 核⼼属性
数据库·笔记·qt
摇滚侠3 小时前
Vue 项目实战《尚医通》,获取挂号医生的信息展示,笔记43
前端·javascript·vue.js·笔记·html5
智者知已应修善业4 小时前
【proteus数电74LS175+74LS48抢答器仿真扩展为矩阵键盘16路】2022-9-1
驱动开发·经验分享·笔记·硬件架构·proteus·硬件工程
LBuffer4 小时前
破解入门学习笔记题四十七
java·笔记·学习
p66666666685 小时前
【☀Linux驱动开发笔记☀】linux下led驱动(非设备树)_03
linux·驱动开发·笔记·嵌入式硬件·学习