Isaac Sim Docker 中使用 Python 脚本

笔记,记录个人尝试过程

主要目的:

  1. 直接在代码中运行仿真程序,并对某传感器帧率进行固定化设置,添加噪声等操作。

  2. 试多个场景的并行处理,和多用户/账户在远程Docker中的并行使用。

  3. 对车辆模型、车辆动力学等进行精细化处理。

原因:

  1. 当前设备不支持多场景多小车多传感器同时运行,硬件不足,需要远程使用别的服务器。

  2. 若不支持同时多场景同时运行,可以远程服务器中开一个仿真地图,本机开一个仿真地图。

  3. 我觉得不会不支持的...先试试看

尝试了用python独立脚本开启直播流和打开场景,但其它脚本无法同步使用。改,换使用扩展。

Isaac Sim教程07 拓展编程Extension_isaac sim extension-CSDN博客

大佬的博客中,很多代码中的意义都翻译了。

在扩展的ui_builder.py中,只有_setup_scene函数是对场景的具体设置,其它都是些ui界面的设置,和重置场景等功能,场景中已经有了完善的内容,不需要在此处添加机器人和一些执行逻辑,全都注释掉。

python 复制代码
    def _setup_scene(self):
        """
        LOAD 可加载此实例
        """
        usd_file = "/usd_path"

        # 加载已有场景
        open_stage(usd_path = usd_file)
        world = World()

        # # 加载ur10e模型
        # robot_prim_path = "/ur10e"
        # path_to_robot_usd = "omniverse://localhost/NVIDIA/Assets/Isaac/4.1/Isaac/Robots/UniversalRobots/ur10e/ur10e.usd"
        # # Do not reload assets when hot reloading.  This should only be done while extension is under development.
        # if not is_prim_path_valid(robot_prim_path):
        #     create_new_stage()
        #     add_reference_to_stage(path_to_robot_usd, robot_prim_path)
        # else:
        #     print("Robot already on Stage")
        # # 创建新的舞台
        # create_new_stage()
        # # 添加光源到舞台
        # self._add_light_to_stage()
        # # 将ur10e机械臂的USD参考添加到舞台
        # add_reference_to_stage(path_to_robot_usd, robot_prim_path)

        # # 创建固定的立方体
        # self._cuboid = FixedCuboid(
        #     "/Scenario/cuboid", position=np.array([0.3, 0.3, 0.5]), size=0.05, color=np.array([255, 0, 0])
        # ) 
        # # 实例化ur10e机械臂的Articulation
        # self._articulation = Articulation(robot_prim_path)

        # 获取世界实例
        # world = World.instance()

        # # 添加Articulation和Cuboid到世界中
        # world.scene.add(self._articulation)
        # world.scene.add(self._cuboid)

在原本的_setup_scenario函数中,调用了scenario.py中的逻辑,我将此处机械臂的运动逻辑改为了差速驱动轮的计算逻辑。

python 复制代码
    def _setup_scenario(self):
        """
        原本用来控制机械臂做循环移动(圆周)
        改成了轮式里程计的发布
        """
        None

        self._reset_scenario()

        # UI management
        self._scenario_state_btn.reset()
        self._scenario_state_btn.enabled = True
        self._reset_btn.enabled = True

isaac sim 扩展仅支持异步发布 rostopic,这里可看官方教程:在扩展中使用ros:
Custom Message --- Omniverse IsaacSim

python 复制代码
import asyncio
import rospy

try:
    rospy.init_node("hello", anonymous=True, disable_signals=True, log_level=rospy.ERROR)
except rospy.exceptions.ROSException as e:
    print("Node has already been initialized, do nothing")

async def my_task():
    from std_msgs.msg import String
    pub = rospy.Publisher("/hello_topic", String, queue_size=10)

    for frame in range(10):
        pub.publish("hello world " + str(frame))
        await asyncio.sleep(1.0)
    pub.unregister()
    pub = None

asyncio.ensure_future(my_task())
相关推荐
Csvn1 小时前
Python 两大经典坑点 —— 可变默认参数 & 闭包延迟绑定
后端·python
曲幽2 小时前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
用户556918817534 小时前
#从脚本到独立程序:Python + Playwright 批量抓取的完整踩坑记录
python·自动化运维
兵慌码乱18 小时前
基于 MediaPipe 与 PySide2 的手势交互音乐控制系统实现:轻量化视觉交互全流程解析
python·opencv·计算机视觉·人机交互·手势识别·mediapipe·pyside2
luckdewei21 小时前
FastAPI 资产管理系统实战:复杂 ORM 关联、Alembic 迁移与 N+1 查询优化
python
aqi001 天前
15天学会AI应用开发(八)使用向量数据库实现RAG功能
人工智能·python·大模型·ai编程·ai应用
Csvn1 天前
`functools.lru_cache` —— 一行代码搞定缓存加速
后端·python
金銀銅鐵2 天前
[Python] 从《千字文》中随机挑选汉字
后端·python
武子康2 天前
调查研究-183 Apple container:Mac 上用轻量 VM 跑 Linux 容器,Swift 会改写本地容器体验吗?
docker·容器·apple