refactor: merge motor sysid into unified sysid module
Unified the two separate sysid codepaths (motor-only and full-system) into a single module that optimizes all 28 parameters jointly: - 13 motor params (asymmetric gear, damping, friction, deadzone, Stribeck boost, action bias, filter tau, armature, ctrl_limit) - 15 pendulum/arm params (mass, CoM, inertia, joint dynamics) Key changes: - Added stribeck_friction_boost, stribeck_vel, action_bias to ActuatorConfig (robot.py) and MJX runner - Created shared src/sysid/preprocess.py (SG velocity recomputation) - Rewrote src/sysid/rollout.py with unified MOTOR_PARAMS + PENDULUM_PARAMS spec and PARAM_SETS dict for flexible subset optimization - Updated optimize.py, export.py, visualize.py to use unified params (removed all LOCKED_MOTOR_PARAMS references) - Removed src/sysid/motor/ module and scripts/motor_sysid.py Net: -1383 lines, zero code duplication between motor and full-system sysid.
This commit is contained in:
39
tests/test_sim2real.py
Normal file
39
tests/test_sim2real.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""Unit tests for MuJoCoRunner domain randomization."""
|
||||
|
||||
import dataclasses
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from src.runners.mujoco import DomainRandConfig, MuJoCoRunnerConfig
|
||||
|
||||
|
||||
class TestDomainRandConfig:
|
||||
def test_default_all_zero(self) -> None:
|
||||
cfg = DomainRandConfig()
|
||||
assert cfg.mass_frac == 0.0
|
||||
assert cfg.friction_frac == 0.0
|
||||
assert cfg.gear_frac == 0.0
|
||||
|
||||
def test_from_dict(self) -> None:
|
||||
d = {"mass_frac": 0.15, "gear_frac": 0.1}
|
||||
cfg = DomainRandConfig(**d)
|
||||
assert cfg.mass_frac == 0.15
|
||||
assert cfg.gear_frac == 0.1
|
||||
assert cfg.damping_frac == 0.0 # not set
|
||||
|
||||
|
||||
class TestMuJoCoRunnerConfig:
|
||||
def test_default_dr_disabled(self) -> None:
|
||||
cfg = MuJoCoRunnerConfig()
|
||||
assert isinstance(cfg.domain_rand, DomainRandConfig)
|
||||
assert cfg.domain_rand.mass_frac == 0.0
|
||||
|
||||
def test_domain_rand_from_dict(self) -> None:
|
||||
"""Hydra passes nested configs as dicts — test __post_init__ converts."""
|
||||
cfg = MuJoCoRunnerConfig(
|
||||
domain_rand={"mass_frac": 0.2, "friction_frac": 0.3}, # type: ignore[arg-type]
|
||||
)
|
||||
assert isinstance(cfg.domain_rand, DomainRandConfig)
|
||||
assert cfg.domain_rand.mass_frac == 0.2
|
||||
assert cfg.domain_rand.friction_frac == 0.3
|
||||
Reference in New Issue
Block a user