Isaac Gym | physics_engine=SimType.SIM_PHYSX, NameError: name ‘SimType‘ is not defined

SimType.SIM_PHYSX is 'isaacgym._bindings.linux-x86_64.gym_38.SimType' object

但是如果直接

 from isaacgym._bindings.linux-x86_64.gym_38 import SimType

会报错:from isaacgym._bindings.linux-x86_64.gym_38 import SimType ^ SyntaxError: invalid syntax

因为模块路径不符合 Python 的语法规则。由于模块路径中包含了像 -. 这样的特殊字符,这些字符通常不符合 Python 的命名规则,所以直接导入会导致语法错误。

使用 动态导入:

import importlib

# 使用 importlib 动态导入具有特殊字符的模块
module_name = 'isaacgym._bindings.linux-x86_64.gym_38'
isaacgym_module = importlib.import_module(module_name)

# 从模块中导入 SimType
SimType = getattr(isaacgym_module, 'SimType')

# 设置物理引擎为 PHYSX
physics_engine = SimType.SIM_PHYSX

# 使用 physics_engine 作为参数
create_sim(self, 0, 0, physics_engine, sim_params)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值