main
Drew Owens Add native Isaac Lab 3.0 + Newton MJWarp 16384-env port, 3-engine sim2sim validation, and full-RoM electronics clearanc… f3db101
# Copyright (c) 2022-2026, The Isaac Lab Project Developers.
# SPDX-License-Identifier: BSD-3-Clause

"""Configuration for Microgoose with 15 Dynamixel XL330-M288-T BAM servos.

The following configurations are available:

* :data:`MICROGOOSE_CFG`: the 15-joint CAD-exact walking robot (sole colliders enabled for fast MJWarp stepping).
* :data:`MICROGOOSE_ALLCOLLISIONS_CFG`: the 15-joint CAD-exact robot with full body, leg, neck, head, and beak colliders.
"""

from __future__ import annotations

import os
from pathlib import Path

from isaaclab_newton.sim.schemas import NewtonArticulationCfg

import isaaclab.sim as sim_utils
from isaaclab.actuators import BamActuatorCfg, BamMotorCfg
from isaaclab.assets import ArticulationCfg
from isaaclab.utils import clone

_DEFAULT_REPO_ROOT = os.environ.get(
    "MICROGOOSE_REPO_ROOT",
    str(Path(__file__).resolve().parents[3]),
)
_WALK_USD_PATH = os.environ.get(
    "MICROGOOSE_USD_WALK",
    f"{_DEFAULT_REPO_ROOT}/rl/assets/usd_walk/microgoose_walk/microgoose_walk.usda",
)
_ALLCOLLISIONS_USD_PATH = os.environ.get(
    "MICROGOOSE_USD_ALLCOLLISIONS",
    f"{_DEFAULT_REPO_ROOT}/rl/assets/usd_allcollisions/microgoose_allcollisions/microgoose_allcollisions.usda",
)

_XL330_MOTOR_CFG = BamMotorCfg(
    model="m6",
    kt=0.36601349688984386,
    resistance=2.8113923539223227,
    error_gain=0.0028773775022263564,
    max_pwm=1.0,
    max_current=1.75,
    friction_base=0.004771183165566,
    friction_viscous=0.005359668274599504,
    friction_stribeck=0.004676345799486616,
    dtheta_stribeck=2.890372094130307,
    alpha=8.683259907618984,
    load_friction_motor=0.2667860954283698,
    load_friction_external=8.515871897059342e-06,
    load_friction_motor_stribeck=1.0722918395099123e-05,
    load_friction_external_stribeck=0.08077928978935671,
    load_friction_motor_quad=0.009972471242139415,
    load_friction_external_quad=0.004902565732332559,
)
"""XL330-M288-T m6 fit from Rhoban BAM revision ``62bd8ce12154340be97e06f7f41a0ca8f116d967``."""

MICROGOOSE_JOINT_NAMES: list[str] = [
    "left_hip_yaw",
    "left_hip_roll",
    "left_hip_pitch",
    "left_knee_pitch",
    "left_ankle_pitch",
    "right_hip_yaw",
    "right_hip_roll",
    "right_hip_pitch",
    "right_knee_pitch",
    "right_ankle_pitch",
    "neck_pitch",
    "head_pitch",
    "head_yaw",
    "head_roll",
    "beak_pitch",
]
"""All 15 XL330-M288-T servos in hardware ``dxlId`` 1..15 order (left leg 1..5, right leg 6..10, neck/head/beak 11..15)."""

MICROGOOSE_HEAD_JOINT_NAMES: list[str] = ["neck_pitch", "head_pitch", "head_yaw", "head_roll"]
"""The 4 neck and head tracking servos, matching the 4-D ``head_pose`` command vector."""

MICROGOOSE_LEG_JOINT_NAMES: list[str] = [
    "left_hip_yaw",
    "left_hip_roll",
    "left_hip_pitch",
    "left_knee_pitch",
    "left_ankle_pitch",
    "right_hip_yaw",
    "right_hip_roll",
    "right_hip_pitch",
    "right_knee_pitch",
    "right_ankle_pitch",
]
"""The 10 leg servos in ``dxlId`` 1..10 order."""

MICROGOOSE_CFG = ArticulationCfg(
    spawn=sim_utils.UsdFileCfg(
        usd_path=_WALK_USD_PATH,
        activate_contact_sensors=True,
        articulation_props=NewtonArticulationCfg(self_collision_enabled=True),
    ),
    init_state=ArticulationCfg.InitialStateCfg(
        pos=(0.0, 0.0, 0.135),
        joint_pos={
            ".*hip_yaw": 0.0,
            ".*hip_roll": 0.0,
            "left_hip_pitch": -0.35,
            "right_hip_pitch": -0.35,
            "left_knee_pitch": 0.70,
            "right_knee_pitch": 0.70,
            "left_ankle_pitch": -0.35,
            "right_ankle_pitch": -0.35,
            "neck_pitch": 0.0,
            "head_pitch": 0.0,
            "head_yaw": 0.0,
            "head_roll": 0.0,
            "beak_pitch": 0.0,
        },
        joint_vel={".*": 0.0},
    ),
    soft_joint_pos_limit_factor=0.9,
    actuators={
        "servos": BamActuatorCfg(
            joint_names_expr=[".*"],
            motor=_XL330_MOTOR_CFG,
            kp_fw=200.0,
            vin=7.4,
            vin_range=(6.0, 8.4),
            vin_drop_gain_range=(0.0, 0.2),
            vin_min=6.0,
            min_delay=1,
            max_delay=3,
        ),
    },
)
"""CAD-exact 15-DoF Microgoose with BAM voltage control, 2S Li-Ion 6.0 to 8.4 V sag, and 1 to 3 step command latency."""

MICROGOOSE_ALLCOLLISIONS_CFG = clone(MICROGOOSE_CFG)
MICROGOOSE_ALLCOLLISIONS_CFG.spawn.usd_path = _ALLCOLLISIONS_USD_PATH
"""CAD-exact Microgoose with full torso, leg, neck, head, and beak collision geometry."""