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

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

相关推荐
左左右右左右摇晃8 小时前
计算机网络笔记整理
笔记·计算机网络
不吃西红柿的858 小时前
[职场] 内容运营求职简历范文 #笔记#职场发展
笔记·职场和发展·内容运营
似水明俊德8 小时前
02-C#.Net-反射-学习笔记
开发语言·笔记·学习·c#·.net
智者知已应修善业9 小时前
【51单片机独立按键控制数码管移动反向,2片74CH573/74CH273段和位,按键按下保持原状态】2023-3-25
经验分享·笔记·单片机·嵌入式硬件·算法·51单片机
C羊驼9 小时前
C语言:两天打鱼,三天晒网
c语言·经验分享·笔记·算法·青少年编程
sheeta19989 小时前
苍穹外卖Day04笔记
笔记
今儿敲了吗13 小时前
46| FBI树
数据结构·c++·笔记·学习·算法
苦瓜小生14 小时前
【黑马点评学习笔记 | 实战篇 】| 6-Redis消息队列
redis·笔记·后端
sheeta199815 小时前
LeetCode 每日一题笔记 日期:2025.03.19 题目:3212.统计X和Y频数相等的子矩阵数量
笔记·leetcode·矩阵
巧克力味的桃子16 小时前
国名排序题笔记(字符串函数 + fgets 详解)
笔记