isaaclab资产打包的一种方式

通过manager创建的资产如果特别多的话 这个配置就显得特别长不方便查看代码结构

可以通过一下方式

bash 复制代码
import numpy as np

def get_wxyz(target_point:tuple[float,float,float]):
    # 起始向量: Z轴 (0,0,1)
    v1 = np.array([0,0,1])
    # 目标向量: X轴 (1,0,0)
    v2 = np.array(target_point)

    # 自动计算旋转四元数
    dot = np.dot(v1, v2)
    axis = np.cross(v1, v2)
    angle = np.arccos(np.clip(dot, -1.0, 1.0))
    half = angle/2
    w = np.cos(half)
    x,y,z = axis * np.sin(half)
    
    return (float(w), float(x), float(y), float(z))

def acan_aseets_zip():
    
    Axis_x = AssetBaseCfg(
            prim_path="{ENV_REGEX_NS}/Axis_x",
            spawn=sim_utils.CylinderCfg(
                radius=0.05,
                height=1,
                visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(1.0, 0.0, 0.0)),
            ),
            init_state=AssetBaseCfg.InitialStateCfg(
                pos=(0.5,0,5),
                rot=(0.7071, 0.0000, 0.7071, 0.0000)
            )
        )

    Axis_y = AssetBaseCfg(
            prim_path="{ENV_REGEX_NS}/Axis_y",
            spawn=sim_utils.CylinderCfg(
                radius=0.05,
                height=1,
                visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 0.0, 1.0)),
            ),
            init_state=AssetBaseCfg.InitialStateCfg(
                pos=(0,0.5,5.0),
                rot=get_wxyz((0,1,0))
            )
        )
    
    Axis_z = AssetBaseCfg(
            prim_path="{ENV_REGEX_NS}/Axis_z",
            spawn=sim_utils.CylinderCfg(
                radius=0.05,
                height=1,
                visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 1.0, 0.0 )),
            ),
            init_state=AssetBaseCfg.InitialStateCfg(
                pos=(0,0,5.5),
                rot=get_wxyz((0,0,2))
            )
        )
    # return empty_line
    # ✅ 打包成字典:键是变量名,值是资产配置
    return {
        # "asset_axis": asset_axis,
        "Axis_x": Axis_x,
        "Axis_y": Axis_y,
        "Axis_z": Axis_z
    }

##
# Scene definition
##

@configclass
class Exp1SceneCfg(InteractiveSceneCfg):
    """Configuration for a cart-pole scene."""

    # ground plane
    ground = AssetBaseCfg(
        prim_path="/World/ground",
        spawn=sim_utils.GroundPlaneCfg(size=(100.0, 100.0)),
    )

    # # robot
    # robot: ArticulationCfg = CARTPOLE_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot")
    robot: ArticulationCfg = TRACTOR_CONFIG.replace(prim_path="{ENV_REGEX_NS}/Robot")
    # robot: ArticulationCfg = ROSOrinMecanumCfg.replace(prim_path="{ENV_REGEX_NS}/Robot")
    

    # lights
    dome_light = AssetBaseCfg(
        prim_path="/World/DomeLight",
        spawn=sim_utils.DomeLightCfg(color=(0.9, 0.9, 0.9), intensity=500.0),
    )

    wall_north = RigidObjectCfg(
        prim_path="{ENV_REGEX_NS}/wall_north",
        spawn=sim_utils.CuboidCfg(
            size=(10.2, 0.2, 2.5),  # 10.2m长以覆盖整个宽度
            rigid_props=sim_utils.RigidBodyPropertiesCfg(kinematic_enabled=True),
            collision_props=sim_utils.CollisionPropertiesCfg(),
            visual_material=sim_utils.PreviewSurfaceCfg(
                diffuse_color=(0.9, 0.9, 0.85),
                roughness=0.9,
            ),
        ),
        init_state=RigidObjectCfg.InitialStateCfg(pos=(0.0, 5.1, 1.25)),  # 外移到y=5.1
    )
   
    locals().update(acan_aseets_zip())
相关推荐
泡海椒23 分钟前
JQuick-Excel 多字段 TRANSFORM:让当前行字段、JContext 与展示列各归其位
开发语言·python·excel
高洁0129 分钟前
智能博弈背景下中国AI国防建设的战略价值
人工智能·python·深度学习·django·tornado
han688936 分钟前
selenium之实战
笔记·python·selenium·测试工具·自动化
yumgpkpm42 分钟前
(CDH 7)CDP Private Cloud Base 7.3.1 → Acceldata ODP 3.3.6.4 引擎迁移风险评估表
服务器·人工智能·hadoop·python·华为·zookeeper·hbase
刘天远1 小时前
Agent成本核算实现:事件表、状态分布与Python归集
前端·数据库·人工智能·python
成都方航科技1 小时前
FA6无人巡逻机器人 L4级无人驾驶安保巡逻车 AI摄像头劝导系统解决方案
机器人
Python图像识别1 小时前
40-【2027毕设】YOLO11面部口罩检测识别系统 - Python完整源码+PyQt5界面+训练模型+数据集
python·qt·课程设计
赵大仁1 小时前
开源清单怎么维护才不烂掉?GitHub Actions 每周查死链 + 软 404 检测实录
python·ci/cd·自动化·开源项目·踩坑·github actions·json schema
Vex2une1 小时前
PowerShell ISE 到 VS Code 迁移史:从集成脚本环境到现代编辑器工作流
windows·vscode·powershell·powershell ise·powershell 扩展·powershell 7·脚本编辑器
玩AI的奶茶1 小时前
24GB 显存能跑多大的模型?参数量、精度与显存占用对照表
人工智能·python·算法·ai·aigc·gpu算力·算力租赁