Files
chenlin c32df70326
Checks / Layout, translation and Colab checks (push) Has been cancelled
Checks / Ruff (push) Has been cancelled
Checks / Framework tests (native backend, CPU) (push) Has been cancelled
Checks / Portable Rust controller (push) Has been cancelled
release: v0.1 generic robot training and application platform
2026-11-05 11:05:01 +08:00

81 lines
3.4 KiB
Python

"""High-friction rubber preset for comparison with the ice scene.
The terrain uses sliding friction 1.8 with explicit priority=2. These are
illustrative simulation parameters, not measurements of an imported robot.
MuJoCo takes all contact parameters from the higher-priority geom. The helper
preserves authored terrain solref and solimp; inspect robot/terrain priorities
and stiffness before interpreting this as a controlled friction experiment.
Foot-friction randomization cannot affect contacts where the ground priority
wins. This scene does not model the deformation of a real rubber mat.
"""
from __future__ import annotations
from typing import Any
from .registry import GROUND, Headlight, Scene, set_ground_contact
#: Illustrative sliding friction; calibrate for the target surface.
RUBBER_SLIDING = 1.8
#: Illustrative torsional and rolling friction for the mat preset.
RUBBER_TORSIONAL = 0.015
RUBBER_ROLLING = 0.015
def _lay_the_mat(spec: Any) -> None:
"""Apply mat friction while preserving authored terrain stiffness."""
set_ground_contact(
spec, "rubber",
friction=(RUBBER_SLIDING, RUBBER_TORSIONAL, RUBBER_ROLLING),
)
def scene() -> Scene:
from mjlab.utils import spec_config as sc
return Scene(
# A mat is an indoor surface, so the light is flat and from above rather
# than the low hard sun the outdoor scenes use: no long shadows, and the
# tread read through its own contrast instead. Slightly warm, because a
# bare grey under a neutral light photographs as a void.
headlight=Headlight(ambient=(0.22, 0.21, 0.20), diffuse=(0.42, 0.41, 0.40)),
textures=(
# A tight checker is a tread pattern at this scale. `texrepeat` below
# puts the cell at roughly a centimetre, which is a third of the foot
# -- fine enough to read as texture, coarse enough that the eye can
# see the foot move across it. The two greys are far enough apart to
# be visible and close enough not to strobe when the camera moves.
sc.TextureCfg(
name="rubber_floor", type="2d", builtin="checker",
rgb1=(0.20, 0.20, 0.21), rgb2=(0.27, 0.27, 0.28),
width=512, height=512,
),
sc.TextureCfg(
name="rubber_sky", type="skybox", builtin="gradient",
rgb1=(0.30, 0.30, 0.32), rgb2=(0.17, 0.17, 0.18),
width=256, height=256,
),
),
materials=(
# **`reflectance=0.0` is the visual claim.** Rubber is the matte
# surface; anything above zero reads as wet or as painted concrete,
# which is the opposite of what this scene is for -- and `ice.py`'s
# 0.4 is exactly the contrast that makes the pair legible side by
# side.
sc.MaterialCfg(
name="rubber_floor", texture="rubber_floor", texuniform=True,
texrepeat=(60.0, 60.0), reflectance=0.0, geom_names_expr=GROUND,
),
),
lights=(
sc.LightCfg(name="overhead", type="directional", pos=(0.0, 0.0, 4.0),
dir=(-0.15, -0.15, -1.0), diffuse=(0.70, 0.69, 0.67)),
sc.LightCfg(name="fill", type="directional", pos=(2.0, -2.0, 2.0),
dir=(-0.5, 0.5, -1.0), diffuse=(0.22, 0.22, 0.23),
castshadow=False),
),
decorate=_lay_the_mat,
)