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

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

相关推荐
m0_736034852 小时前
1.28笔记
前端·chrome·笔记
丝斯20112 小时前
AI学习笔记整理(63)——大模型对齐与强化学习
人工智能·笔记·学习
奥特曼_ it9 小时前
【数据分析+机器学习】基于机器学习的招聘数据分析可视化预测推荐系统(完整系统源码+数据库+开发笔记+详细部署教程)✅
笔记·数据挖掘·数据分析
四维碎片10 小时前
QSettings + INI 笔记
笔记·qt·算法
zzcufo11 小时前
多邻国第5阶段17-18学习笔记
笔记·学习
BlackWolfSky11 小时前
鸿蒙中级课程笔记4—应用程序框架进阶1—Stage模型应用组成结构、UIAbility启动模式、启动应用内UIAbility
笔记·华为·harmonyos
中屹指纹浏览器11 小时前
指纹浏览器性能优化实操——多实例并发与资源占用管控
经验分享·笔记
了一梨12 小时前
SQLite3学习笔记5:INSERT(写)+ SELECT(读)数据(C API)
笔记·学习·sqlite
jrlong13 小时前
DataWhale大模型基础与量化微调task5学习笔记(第 3 章:大模型训练与量化_模型量化实战)
笔记·学习
Sarvartha13 小时前
Routing(路由与分支)学习笔记
笔记·学习