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())
相关推荐
ZhengEnCi4 小时前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器
python·matlab·数据可视化
ZhengEnCi5 小时前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器
python·matlab
曲幽5 小时前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南
python·fastapi·web·graphql·route·cors·rest·strawberry
用户8358086187916 小时前
基于 Self-RAG 与列表级重排序的进阶 RAG 系统设计与实现
python
Warson_L1 天前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅1 天前
海天线算法的前世今生
python·计算机视觉
韩师傅1 天前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L1 天前
LangGraph的MessageState and HumanMessage
python
韩师傅1 天前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉
Warson_L1 天前
python的类&继承
python