From 75d3c9a3561862c56e58fd676ab7e8c137b88a39 Mon Sep 17 00:00:00 2001 From: xiemenghong Date: Thu, 17 Sep 2026 09:48:58 +0800 Subject: [PATCH 1/4] feat(sim): default Newton rigid simulation to MJVBD V2 --- agent_context/MAP.yaml | 2 +- .../motion-planning/collision-worlds.md | 5 +- .../simulation-system/simulation-system.md | 96 ++++++++++++------- embodichain/lab/sim/cfg/robot.py | 4 +- embodichain/lab/sim/cfg/simulation.py | 32 ++++--- embodichain/lab/sim/objects/articulation.py | 2 +- .../lab/sim/objects/backends/collision.py | 4 +- .../lab/sim/objects/backends/newton.py | 15 ++- embodichain/lab/sim/physics/newton.py | 2 +- embodichain/lab/sim/sim_manager.py | 14 ++- embodichain/lab/sim/spawn/descriptors.py | 10 +- .../trajectory_open_loop_slow.yaml | 29 ++++++ .../manipulation/open_drawer/env.newton.yaml | 18 ++-- .../open_drawer/task.ur5.newton.yaml | 2 +- .../repeated_pick_place/env.newton.yaml | 18 ++-- .../repeated_pick_place/task.ur5.newton.yaml | 2 +- examples/sim/demo/grasp_cup_to_caffe.py | 8 +- examples/sim/demo/scoop_ice.py | 7 +- .../sim/motion/planners/curobo_planner.py | 12 ++- .../motion/trajectory_velocity_tracking.py | 3 +- .../atomic_action/move_held_object.py | 9 +- scripts/tutorials/atomic_action/pour.py | 12 +-- .../tutorials/atomic_action/tutorial_utils.py | 29 +++--- scripts/tutorials/gym/modular_env.py | 2 +- scripts/tutorials/sim/open_drawer.py | 25 +++-- tests/sim/test_cfg.py | 3 +- tests/sim/test_sim_manager_cfg.py | 16 ++-- 27 files changed, 241 insertions(+), 140 deletions(-) create mode 100644 embodichain_tasks/configs/components/execution_policies/trajectory_open_loop_slow.yaml diff --git a/agent_context/MAP.yaml b/agent_context/MAP.yaml index 8086c4a5f8..24734f43a8 100644 --- a/agent_context/MAP.yaml +++ b/agent_context/MAP.yaml @@ -11,7 +11,7 @@ topics: aliases: [simulation system, simulation manager, Newton physics backend, motion module, sim motion, camera attachment, 运动能力模块, 仿真系统, 仿真管理器] keywords: [SimulationManager, SimulationManagerCfg, RenderCfg, DLSSCfg, DLSS, frame_time_delta_ms, offscreen_dlss_enabled, explicit physics stepping, arena, DexSim, PhysicsBackendCfg, - DefaultPhysicsCfg, NewtonPhysicsCfg, AutoSolverCfg, DexUniSolverCfg, DexUni, runtime control, deformable, particle set, + DefaultPhysicsCfg, NewtonPhysicsCfg, AutoSolverCfg, DexUniSolverCfg, DexUni, MJVBDV2SolverCfg, mjvbd_v2, mjvbd2, runtime control, deformable, particle set, ArticulationJointKinematics, get_parent_joint_chain, asset_physics_mode, joint_drive_props, enable_gravity, fixed-cadence playback, quaternion, xyzw] paths: [topics/simulation-system/simulation-system.md] diff --git a/agent_context/topics/motion-planning/collision-worlds.md b/agent_context/topics/motion-planning/collision-worlds.md index ac240779fb..b380bc8898 100644 --- a/agent_context/topics/motion-planning/collision-worlds.md +++ b/agent_context/topics/motion-planning/collision-worlds.md @@ -17,7 +17,10 @@ mapping key is the authoritative logical/source obstacle ID used by the content-cache key, `collision_world_entity_ids`, generated obstacle-name prefix, dynamic update key, and registry validation. Scene generation reads physical collision descriptors through `RigidObject.get_collision_shapes()` and emits a -mixed tensor-backed cuRobo scene. A compound source expands to physical names +mixed tensor-backed cuRobo scene. Geometry snapshots retain authored collision +shapes even when physical contact response is disabled, matching native shape +queries; a moving planner obstacle can therefore avoid exerting impulses on +the robot. A compound source expands to physical names such as `registry_id__shape_0`; cache and full-world identity remain keyed by the unexpanded `registry_id`, and dynamic updates fan out through the physical shapes' local poses. A registry mapping whose source lacks physical collision diff --git a/agent_context/topics/simulation-system/simulation-system.md b/agent_context/topics/simulation-system/simulation-system.md index 04c0a74f5a..8872a5dbd3 100644 --- a/agent_context/topics/simulation-system/simulation-system.md +++ b/agent_context/topics/simulation-system/simulation-system.md @@ -136,6 +136,8 @@ before closing the Spawn result, environment, and World. Default backends use the no-op hook. Newton synchronizes its resolved Warp CUDA device and clears its render bridge while Spawn still owns the parent skeletons, so cached link views cannot be destructed after their native parents. +Asset material and reset-baseline material caches are also cleared before +closing the Scene, so OptiX material wrappers cannot outlive the renderer. After backend materialization, dynamic `RigidObject`, `Articulation`, and `RigidObjectGroup` facades capture their resolved mass, inertia diagonal, and @@ -466,18 +468,52 @@ are both absent. Thus a config-backed launcher preserves the backend default, while an explicit CPU override remains authoritative even for Newton. Environment tensors derive from `sim.device`; do not introduce a second tensor-device selector. -Leaving `NewtonPhysicsCfg.solver_cfg=None` preserves DexSim's -`AutoSolverCfg` default. A DexSim build exporting `AutoSolverCfg` is required; -EmbodiChain does not substitute a concrete solver. DexSim resolves that -placeholder from the complete Spawn scene during finalization: rigid-only -scenes select XPBD, scenes with an articulation select MuJoCo Warp, and -supported particle families select their matching particle/deformable solver. -A mapping with `solver_type: auto` or -`class_type: AutoSolverCfg` is the explicit equivalent. Gradient mode must -still select `semi_implicit` explicitly because AutoSolver does not choose a -differentiable solver. Before finalization, EmbodiChain treats `auto` as -unresolved; after finalization, `NewtonPhysicsBackend.solver_type` reads the -concrete type from DexSim's World-owned backend. +`NewtonPhysicsCfg()` selects `mjvbd_v2` by default for rigid bodies and +articulations. V2 owns collision detection, so conversion omits the external +pipeline even when `collision_cfg` contains its default settings. Other +solvers retain the external pipeline unless explicitly disabled. +Explicit `solver_cfg=None`, `solver_type: auto`, or `class_type: AutoSolverCfg` +opts into DexSim's scene-aware selection: rigid-only scenes select XPBD, +articulation scenes select MuJoCo Warp, and supported particle families select +their matching solver. Gradient mode still requires explicit `semi_implicit`. +Before finalization, explicit `auto` is unresolved; after finalization, +`NewtonPhysicsBackend.solver_type` reads the concrete World-owned solver. +Explicit rigid/articulation V2 configurations select `mjvbd_v2` (aliases +`mjvbd2`, `mjvbdv2`, or `MJVBDV2SolverCfg`). Keep `joint_mode: dynamic` for +ordinary robot control, put existing MuJoCo options under `mujoco_options`, +and set `collision_cfg: null` because V2 owns collision detection. Joint +targets, state access, mimic compliance, and whole-world articulation reset +use the existing Scene/Batch path. V2's compact MuJoCo indices are translated +by DexSim for contact queries and by its index map for mimic equality rows. +Runtime FK updates only MuJoCo-owned articulation trees; replaying FK for +VBD-owned FREE joints would overwrite simulated rigid-body poses with stale +generalized coordinates. Reset completeness checks count Scene articulations, +not the internal FREE-joint trees used to represent standalone rigid bodies. +The pure MuJoCo branch exposes contact geometry, impulses, and friction on +CUDA. VBD contacts expose geometry without MuJoCo impulse reporting. + +V2 selects MuJoCo for articulations with active scalar joints and VBD for +unselected free rigid bodies. Its current mixed dynamic branch is one-way: +VBD contacts do not push back on the MuJoCo robot, and MuJoCo contacts are +disabled in that branch. Therefore switching an existing locomotion or +manipulation scene to V2 does not by itself guarantee equivalent contact +dynamics. In particular, adding a VBD-owned free rigid body switches a floating +robot out of the articulation-only branch and removes its MuJoCo ground +support, even if the new body is far away. Explicit `mujoco_articulations` or +`mujoco_articulation_paths` can select complete joint trees; these are ownership +choices, not automatic EmbodiChain rewrites. This integration does not extend +deformable support. + +The UR5 `repeated_pick_place` and `open_drawer` deployments provide +`task.ur5.newton.yaml` and matching `env.newton.yaml` components using V2. They share the +existing embodiment, controller gains, and Task Programs, with the timed +`trajectory_open_loop_slow.yaml` execution policy (80 control points). The +40-point drawer reference allocates only five samples to pulling; at 25 Hz its +0.2-second pull is shorter than the time needed for 18 cm at the drawer's +authored 0.35 m/s speed limit. Evaluate measured lift, placement, and drawer +travel separately from projected Task Program completion; a completed program +alone is not evidence of physical success. + Explicit coupled articulation/deformable configurations use `dexuni` or `DexUniSolverCfg`. DexUni owns collision detection and its particle-shape contacts, so explicit configurations set `collision_cfg=None` instead of @@ -491,28 +527,16 @@ The `open_drawer.py` tutorial combines this option with 20 Newton substeps per 10 ms control step, while keeping its authored robot gains, collision geometry, pull trajectory, success criteria, and push trajectory identical to Default. Atomic-action tutorials configure their shared Newton simulation in -`scripts/tutorials/atomic_action/tutorial_utils.py` with 20 solver substeps -per 10 ms physics step (0.5 ms solver intervals). They select `mujoco_warp` with -`use_mujoco_contacts=True` and set the external `collision_cfg` to `None`. -MuJoCo-Warp then generates and solves contacts internally at every solver -substep; external-pipeline settings such as `update_interval`, contact -reduction, and the external `rigid_contact_max` do not apply. DexSim derives -the native per-world contact capacity from the finalized scene, avoiding the -oversized fixed buffers formerly inherited from external-pipeline examples. -The shared factory leaves the Default backend configuration unchanged. For -parallel-jaw manipulation, the tutorial and packaged task components add a -Newton-only contact overlay (`condim=4`, `ke=4e4`, `kd=4e2`, torsional friction -`0.1`, rolling friction `0.01`) to the gripper and directly manipulated object -contact links. `condim=4` activates torsional friction in MuJoCo-Warp; rolling -friction is retained for solvers/`condim=6` that support it. This is a scoped -contact/force-closure candidate profile, not a replacement for Newton's scene-aware -`AutoSolverCfg`; rigid-only scenes still resolve to XPBD and articulation -scenes to MuJoCo-Warp. Keep -backend-specific overlays sparse so the Default adapter continues to use its -existing portable contact envelope. -The package dependency must identify the exact DexSim dev build containing -this API; a base `==0.4.3` requirement also accepts older local-version wheels -that do not export `AutoSolverCfg` and is therefore insufficient. +`scripts/tutorials/atomic_action/tutorial_utils.py` with `mjvbd_v2`, retaining +20 solver substeps per 10 ms physics step (0.5 ms solver intervals) and the +existing articulation tuning under `mujoco_options`. The direct drawer +tutorial and rigid manipulation examples use the same native V2 ownership. +The shared factory leaves the Default backend configuration unchanged. +Parallel-jaw manipulation keeps its Newton-only contact overlay (`condim=4`, +`ke=4e4`, `kd=4e2`, torsional friction `0.1`, rolling friction `0.01`) on the +gripper and manipulated objects. MuJoCo options affect articulation-owned +contacts; free rigid-body contacts use VBD and need not have identical effects. +Explicit cloth, softbody, and differentiable examples keep their selected solvers. Newton's `suppress_warp_kernel_logs=True` suppresses Warp's one-time runtime banner plus module compile/load chatter during manager startup, build, facade initialization, and physics updates, then restores the process-wide setting. @@ -721,6 +745,10 @@ only the generic `newton` and `default` alternatives are eligible; do not guess a solver-specific preset before DexSim has inspected the complete scene. This is the only robot preset selection boundary; do not add a second backend selector to robot configs. +For explicit `mjvbd_v2`, preset priority is `newton_mjvbd_v2`, then +`newton_mujoco_warp` / `newton_mjwarp`, then generic `newton` / `default`. +This preserves established articulation drive tuning while allowing a V2 +override. File-backed rigid objects and articulations share one source-independent physics policy: `asset_physics_mode="preserve"` keeps properties resolved from diff --git a/embodichain/lab/sim/cfg/robot.py b/embodichain/lab/sim/cfg/robot.py index c26dac1325..13f63395d4 100644 --- a/embodichain/lab/sim/cfg/robot.py +++ b/embodichain/lab/sim/cfg/robot.py @@ -349,7 +349,7 @@ def resolve( solver_type = str( solver_cfg.get("solver_type") or solver_cfg.get("class_type") - or "auto" + or "mjvbd_v2" ) else: solver_type = str(getattr(solver_cfg, "solver_type")) @@ -357,6 +357,8 @@ def resolve( solver_candidates = [] if solver_type != "auto": solver_candidates.append(f"newton_{solver_type}") + if solver_type == "mjvbd_v2": + solver_candidates.extend(("newton_mujoco_warp", "newton_mjwarp")) if solver_type == "mujoco_warp": solver_candidates.append("newton_mjwarp") candidates = (*solver_candidates, "newton", "default") diff --git a/embodichain/lab/sim/cfg/simulation.py b/embodichain/lab/sim/cfg/simulation.py index cb0803e1f6..5ace2c3ed1 100644 --- a/embodichain/lab/sim/cfg/simulation.py +++ b/embodichain/lab/sim/cfg/simulation.py @@ -530,14 +530,16 @@ class NewtonPhysicsCfg(PhysicsBackendCfg): Genuine Newton/Warp warnings and errors are not suppressed. """ - solver_cfg: Mapping[str, Any] | NewtonSolverCfg | None = None + solver_cfg: Mapping[str, Any] | NewtonSolverCfg | None = field( + default_factory=lambda: {"solver_type": "mjvbd_v2"} + ) """Optional Newton solver configuration. A mapping is converted to the matching DexSim Newton solver config. Include ``solver_type`` or ``class_type`` to select the solver, then add any - parameters accepted by that DexSim solver config. If omitted, EmbodiChain - preserves DexSim's scene-aware ``AutoSolverCfg`` default. A DexSim build - exporting ``AutoSolverCfg`` is required; no concrete-solver fallback is used. + parameters accepted by that DexSim solver config. The default is + ``mjvbd_v2`` for rigid bodies and articulations. Explicit ``None`` or + ``solver_type="auto"`` preserves DexSim's scene-aware ``AutoSolverCfg``. """ collision_cfg: NewtonCollisionPipelineCfg | Mapping[str, Any] | None = field( @@ -545,10 +547,10 @@ class NewtonPhysicsCfg(PhysicsBackendCfg): ) """Optional external collision-pipeline configuration. - The default preserves external contact generation for ordinary rigid-body - scenes. Set to ``None`` to avoid constructing or executing the external - pipeline, for example when particle solvers use rigid shapes solely as - one-way SDF boundaries. + MJVBD V2 owns collision detection and does not construct this pipeline. + Other solvers use these settings unless explicitly set to ``None``, for + example when particle solvers use rigid shapes solely as one-way SDF + boundaries. """ def __post_init__(self) -> None: @@ -566,6 +568,7 @@ def to_dexsim_cfg( DexUniSolverCfg, FeatherstoneSolverCfg, MJWarpSolverCfg, + MJVBDV2SolverCfg, NewtonCfg, NewtonCollisionPipelineCfg as DexsimNewtonCollisionPipelineCfg, SemiImplicitSolverCfg, @@ -586,6 +589,7 @@ def to_dexsim_cfg( "auto": AutoSolverCfg, "dexuni": DexUniSolverCfg, "mujoco_warp": MJWarpSolverCfg, + "mjvbd_v2": MJVBDV2SolverCfg, "xpbd": XPBDSolverCfg, "semi_implicit": SemiImplicitSolverCfg, "featherstone": FeatherstoneSolverCfg, @@ -606,7 +610,9 @@ def to_dexsim_cfg( ) collision_pipeline_cfg = None - if self.collision_cfg is not None: + if self.collision_cfg is not None and ( + solver_cfg is None or solver_cfg.solver_type != "mjvbd_v2" + ): collision_values = { item.name: getattr(self.collision_cfg, item.name) for item in fields(self.collision_cfg) @@ -655,6 +661,10 @@ def _normalize_newton_solver_type(solver_type: str) -> str: "mujocowarp": "mujoco_warp", "mujocowarpsolver": "mujoco_warp", "mujocowarpsolvercfg": "mujoco_warp", + "mjvbd2": "mjvbd_v2", + "mjvbdv2": "mjvbd_v2", + "mjvbd_v2": "mjvbd_v2", + "mjvbdv2solvercfg": "mjvbd_v2", "dexuni": "dexuni", "dexunisolver": "dexuni", "dexunisolvercfg": "dexuni", @@ -677,7 +687,7 @@ def _normalize_newton_solver_type(solver_type: str) -> str: if key not in aliases: logger.log_error( f"Unsupported Newton solver type '{solver_type}'. " - "Expected one of 'auto', 'dexuni', 'mjwarp', 'xpbd', 'semi_implicit', " + "Expected one of 'auto', 'dexuni', 'mjwarp', 'mjvbd_v2', 'xpbd', 'semi_implicit', " "'featherstone', or 'vbd'." ) return aliases[key] @@ -703,7 +713,7 @@ def _newton_solver_cfg_to_dexsim( configured_solver_type = ( solver_cfg_data.pop("solver_type", None) or solver_cfg_data.pop("class_type", None) - or "auto" + or "mjvbd_v2" ) normalized_solver_type = _normalize_newton_solver_type(str(configured_solver_type)) solver_cfg_type = solver_cfg_map[normalized_solver_type] diff --git a/embodichain/lab/sim/objects/articulation.py b/embodichain/lab/sim/objects/articulation.py index 23c78fcefa..a960831d12 100644 --- a/embodichain/lab/sim/objects/articulation.py +++ b/embodichain/lab/sim/objects/articulation.py @@ -1021,7 +1021,7 @@ def root_link_name(self) -> str: Returns: str: The name of the root link. """ - return self.entities[0].get_root_link_name() + return self._entities[0].get_root_link_name() @cached_property def joint_names(self) -> List[str]: diff --git a/embodichain/lab/sim/objects/backends/collision.py b/embodichain/lab/sim/objects/backends/collision.py index a39a35775a..1f2889669e 100644 --- a/embodichain/lab/sim/objects/backends/collision.py +++ b/embodichain/lab/sim/objects/backends/collision.py @@ -184,9 +184,9 @@ def _from_descriptor(entity: object) -> list[CollisionShapeDesc] | None: dtype=torch.float32, ).reshape(3) shapes: list[CollisionShapeDesc] = [] + # Match native shape queries: disabling contact response keeps geometry + # available to planners, including moving obstacles that exert no impulses. for shape_idx, collision in enumerate(collisions): - if getattr(collision, "enable_collision", True) is False: - continue geometry_type = getattr(collision, "geometry_type", None) geometry_type = getattr(geometry_type, "value", geometry_type) local_pose = torch.as_tensor( diff --git a/embodichain/lab/sim/objects/backends/newton.py b/embodichain/lab/sim/objects/backends/newton.py index 33b1644044..e6a8b94f26 100644 --- a/embodichain/lab/sim/objects/backends/newton.py +++ b/embodichain/lab/sim/objects/backends/newton.py @@ -204,11 +204,14 @@ def _configure_newton_mimic_compliance( backend = get_newton_backend(result.world) if ( backend is None - or backend.solver_type != "mujoco_warp" + or backend.solver_type not in {"mujoco_warp", "mjvbd_v2"} or backend.cfg.requires_grad or (backend.model is not None and backend.model.requires_grad) ): return False + solver = backend.mujoco_solver + if solver is None: + return False relation_names = [ (state_joint_names[child_id], state_joint_names[parent_id]) @@ -284,13 +287,21 @@ def _configure_newton_mimic_compliance( f"Newton model has no mimic constraint for joint pair {error.args[0]}." ) from error - solver = runtime.solver mapping = getattr(solver, "mjc_eq_to_newton_mimic", None) mjw_model = getattr(solver, "mjw_model", None) if mapping is None or mjw_model is None: raise RuntimeError("MuJoCo-Warp did not materialize Newton mimic rows.") mapping_values = np.asarray(mapping.numpy()) + if backend.solver_type == "mjvbd_v2": + from newton import Model + + scene_rows = backend.get_mujoco_index_map( + Model.AttributeFrequency.CONSTRAINT_MIMIC + ).numpy() + mapping_values = mapping_values.copy() + valid = mapping_values >= 0 + mapping_values[valid] = scene_rows[mapping_values[valid]] selected = np.isin(mapping_values, constraint_rows) if int(selected.sum()) != len(constraint_rows): raise RuntimeError( diff --git a/embodichain/lab/sim/physics/newton.py b/embodichain/lab/sim/physics/newton.py index 786ce98fb1..9fb74a16c0 100644 --- a/embodichain/lab/sim/physics/newton.py +++ b/embodichain/lab/sim/physics/newton.py @@ -204,6 +204,6 @@ def supports_contact_sensor(self) -> bool: if runtime_device is None: runtime_device = str(getattr(self._manager, "device", "")) return not ( - solver_type.endswith("mujoco_warp") + solver_type in {"mujoco_warp", "mjvbd_v2"} and runtime_device.lower().startswith("cpu") ) diff --git a/embodichain/lab/sim/sim_manager.py b/embodichain/lab/sim/sim_manager.py index 19d68cf313..3f70fc9dfc 100644 --- a/embodichain/lab/sim/sim_manager.py +++ b/embodichain/lab/sim/sim_manager.py @@ -537,7 +537,7 @@ def __init__( self._requested_renderer = sim_config.render_cfg.renderer solver_cfg = getattr(sim_config.physics_cfg, "solver_cfg", None) self._requested_solver = str( - solver_cfg.get("solver_type", solver_cfg.get("class_type", "auto")) + solver_cfg.get("solver_type", solver_cfg.get("class_type", "mjvbd_v2")) if isinstance(solver_cfg, Mapping) else getattr(solver_cfg, "solver_type", "auto") ) @@ -4427,6 +4427,7 @@ def reset_objects_state( None, "auto", "mujoco_warp", + "mjvbd_v2", } if ( use_coordinated_newton_clear @@ -4531,6 +4532,9 @@ def export_usd(self, fpath: str) -> bool: bool: True if export is successful, False otherwise. """ try: + # The optional USD kit registers the export methods on DexSim Env. + import dexsim.kit.usd + self._env.export_to_usd_file(fpath) logger.log_info(f"Simulation scene exported to USD file: {fpath}") return True @@ -4647,6 +4651,14 @@ def _deferred_destroy(self) -> None: "_robots", ): for asset in getattr(self, registry_name, {}).values(): + # Parsed material wrappers must die before their native renderer. + for material_attr in ( + "_visual_material", + "_original_visual_material", + "_original_visual_material_inst", + ): + if hasattr(asset, material_attr): + setattr(asset, material_attr, []) if hasattr(asset, "_data"): asset._data = None if hasattr(asset, "_spawn_result"): diff --git a/embodichain/lab/sim/spawn/descriptors.py b/embodichain/lab/sim/spawn/descriptors.py index beba18ddbc..ac596a0d62 100644 --- a/embodichain/lab/sim/spawn/descriptors.py +++ b/embodichain/lab/sim/spawn/descriptors.py @@ -1168,9 +1168,13 @@ def _compile_joint_properties( if newton_solver_type is None else newton_solver_type.replace("-", "_").lower() ) - if normalized_solver not in {None, "auto", "mujoco_warp", "mjwarp"} and any( - mode == 1 for mode in joint_target_modes.values() - ): + if normalized_solver not in { + None, + "auto", + "mujoco_warp", + "mjwarp", + "mjvbd_v2", + } and any(mode == 1 for mode in joint_target_modes.values()): warnings.warn( f"Newton solver {newton_solver_type!r} does not consume " "joint_target_mode. POSITION is emulated with its configured " diff --git a/embodichain_tasks/configs/components/execution_policies/trajectory_open_loop_slow.yaml b/embodichain_tasks/configs/components/execution_policies/trajectory_open_loop_slow.yaml new file mode 100644 index 0000000000..3ab4ee0fa9 --- /dev/null +++ b/embodichain_tasks/configs/components/execution_policies/trajectory_open_loop_slow.yaml @@ -0,0 +1,29 @@ +policy_id: trajectory_open_loop_slow_v1 +preset_id: trajectory + +requires: + embodiment_contract: single_arm_parallel_gripper + +motion: + strategy: ik_interp + velocity_targets: auto + # Allow velocity-limited articulated objects to follow before releasing. + sample_count: 80 + dynamic_collision_mode: "off" + +tracking: + kind: timed + +recovery: + max_replans: 0 + max_action_retries: 0 + +workflow_recovery: + max_recovery_attempts: 0 + +runner: + minimum_cycle_time: 0.0 + hold_on_completion: false + hold_during_effect_verification: false + +effect_assurance: projected diff --git a/embodichain_tasks/configs/tasks/manipulation/open_drawer/env.newton.yaml b/embodichain_tasks/configs/tasks/manipulation/open_drawer/env.newton.yaml index 083537e0cc..fd5905b07c 100644 --- a/embodichain_tasks/configs/tasks/manipulation/open_drawer/env.newton.yaml +++ b/embodichain_tasks/configs/tasks/manipulation/open_drawer/env.newton.yaml @@ -13,15 +13,15 @@ physics_config: num_substeps: 20 collision_cfg: null solver_cfg: - solver_type: mujoco_warp - solver: newton - integrator: implicitfast - iterations: 20 - ls_iterations: 100 - cone: elliptic - impratio: 1000.0 - use_mujoco_contacts: true - enable_multiccd: true + solver_type: mjvbd_v2 + mujoco_options: + solver: newton + integrator: implicitfast + iterations: 20 + ls_iterations: 100 + cone: elliptic + impratio: 1000.0 + enable_multiccd: true simulation: light: diff --git a/embodichain_tasks/configs/tasks/manipulation/open_drawer/task.ur5.newton.yaml b/embodichain_tasks/configs/tasks/manipulation/open_drawer/task.ur5.newton.yaml index 9783c94c9f..c1890df4ba 100644 --- a/embodichain_tasks/configs/tasks/manipulation/open_drawer/task.ur5.newton.yaml +++ b/embodichain_tasks/configs/tasks/manipulation/open_drawer/task.ur5.newton.yaml @@ -6,7 +6,7 @@ environment: task_program: program: task_program/program.yaml integration: task_program/integration.yaml - execution_policy: ../../../components/execution_policies/trajectory_open_loop.yaml + execution_policy: ../../../components/execution_policies/trajectory_open_loop_slow.yaml embodiment: component: ../../../components/embodiments/ur5_dh_pgi_140_80.yaml diff --git a/embodichain_tasks/configs/tasks/manipulation/repeated_pick_place/env.newton.yaml b/embodichain_tasks/configs/tasks/manipulation/repeated_pick_place/env.newton.yaml index 2bf2375612..10209b420f 100644 --- a/embodichain_tasks/configs/tasks/manipulation/repeated_pick_place/env.newton.yaml +++ b/embodichain_tasks/configs/tasks/manipulation/repeated_pick_place/env.newton.yaml @@ -15,15 +15,15 @@ physics_config: num_substeps: 20 collision_cfg: null solver_cfg: - solver_type: mujoco_warp - solver: newton - integrator: implicitfast - iterations: 20 - ls_iterations: 100 - cone: elliptic - impratio: 1000.0 - use_mujoco_contacts: true - enable_multiccd: true + solver_type: mjvbd_v2 + mujoco_options: + solver: newton + integrator: implicitfast + iterations: 20 + ls_iterations: 100 + cone: elliptic + impratio: 1000.0 + enable_multiccd: true simulation: light: diff --git a/embodichain_tasks/configs/tasks/manipulation/repeated_pick_place/task.ur5.newton.yaml b/embodichain_tasks/configs/tasks/manipulation/repeated_pick_place/task.ur5.newton.yaml index 429264f5a1..166663208f 100644 --- a/embodichain_tasks/configs/tasks/manipulation/repeated_pick_place/task.ur5.newton.yaml +++ b/embodichain_tasks/configs/tasks/manipulation/repeated_pick_place/task.ur5.newton.yaml @@ -6,7 +6,7 @@ environment: task_program: program: task_program/program.yaml integration: task_program/integration.yaml - execution_policy: ../../../components/execution_policies/trajectory_open_loop.yaml + execution_policy: ../../../components/execution_policies/trajectory_open_loop_slow.yaml embodiment: component: ../../../components/embodiments/ur5_dh_pgi_140_80.yaml diff --git a/examples/sim/demo/grasp_cup_to_caffe.py b/examples/sim/demo/grasp_cup_to_caffe.py index aa3fff4636..b542d1967a 100644 --- a/examples/sim/demo/grasp_cup_to_caffe.py +++ b/examples/sim/demo/grasp_cup_to_caffe.py @@ -92,13 +92,9 @@ def initialize_simulation(args) -> SimulationManager: """ physics_cfg = physics_cfg_for_backend(args.physics) if args.physics == "newton": - # This contact-heavy URDF scene needs Newton's collision pipeline; - # MuJoCo's native contact path is not reliable for these convex meshes. physics_cfg.solver_cfg = { - "solver_type": "mujoco_warp", - "use_mujoco_contacts": False, - "nconmax": 16384, - "njmax": 65536, + "solver_type": "mjvbd_v2", + "mujoco_options": {"nconmax": 16384, "njmax": 65536}, } config = SimulationManagerCfg( diff --git a/examples/sim/demo/scoop_ice.py b/examples/sim/demo/scoop_ice.py index 8b05f43a0e..a809ad6f65 100644 --- a/examples/sim/demo/scoop_ice.py +++ b/examples/sim/demo/scoop_ice.py @@ -79,9 +79,10 @@ def initialize_simulation(args): """ physics_cfg = physics_cfg_for_backend(args.physics) if args.physics == "newton": - # Hundreds of free bodies make dense Newton Hessian factorization - # expensive. CG avoids that factorization while retaining contacts. - physics_cfg.solver_cfg = {"solver_type": "mujoco_warp", "solver": "cg"} + physics_cfg.solver_cfg = { + "solver_type": "mjvbd_v2", + "mujoco_options": {"solver": "cg"}, + } config = SimulationManagerCfg( headless=True, device=args.device, diff --git a/examples/sim/motion/planners/curobo_planner.py b/examples/sim/motion/planners/curobo_planner.py index 11b7e3f373..a983deb940 100644 --- a/examples/sim/motion/planners/curobo_planner.py +++ b/examples/sim/motion/planners/curobo_planner.py @@ -502,9 +502,9 @@ def _build_scene( init_rot=(0.0, 0.0, 0.0), ) ) + sim.prepare() finally: demo_block_mesh_path.unlink(missing_ok=True) - sim.prepare() if robot_type == "w1": # Keep the W1-specific IK diagnostic batched so it remains useful when @@ -861,7 +861,10 @@ def main(args: argparse.Namespace | None = None) -> None: binding, motion_policy, ), - ) + ), + context=engine.initial_context( + control_dt=sim.sim_config.physics_dt * args.step_repeat, + ), ) success = compiled.plan_success trajectory = compiled.trajectory.positions @@ -899,7 +902,10 @@ def main(args: argparse.Namespace | None = None) -> None: binding, motion_policy, ), - ) + ), + context=engine.initial_context( + control_dt=sim.sim_config.physics_dt * args.step_repeat, + ), ) success = compiled.plan_success trajectory = compiled.trajectory.positions diff --git a/examples/sim/motion/trajectory_velocity_tracking.py b/examples/sim/motion/trajectory_velocity_tracking.py index 9d1145ad12..8772c98f67 100644 --- a/examples/sim/motion/trajectory_velocity_tracking.py +++ b/examples/sim/motion/trajectory_velocity_tracking.py @@ -396,8 +396,7 @@ def main(args: argparse.Namespace | None = None) -> None: robot: Robot = sim.add_robot( FrankaPandaCfg.from_dict({"uid": "tracking_franka"}) ) - if sim.is_use_gpu_physics: - sim.init_gpu_physics() + sim.prepare() if not args.headless: sim.open_window() common_initial_qpos = robot.get_qpos().clone() diff --git a/scripts/tutorials/atomic_action/move_held_object.py b/scripts/tutorials/atomic_action/move_held_object.py index 4341110e04..e53ca5a1ad 100644 --- a/scripts/tutorials/atomic_action/move_held_object.py +++ b/scripts/tutorials/atomic_action/move_held_object.py @@ -27,6 +27,7 @@ sys.path.insert(0, str(_REPO_ROOT)) import torch +import trimesh from embodichain.data import get_data_path from embodichain.lab.sim.atomic_actions import ( @@ -82,11 +83,16 @@ def parse_arguments() -> argparse.Namespace: def create_pick_object(sim) -> RigidObject: """Create and settle the paper cup used by the tutorial.""" + mesh = trimesh.load_mesh(get_data_path(OBJECT_MESH_PATH), process=False) + # Author cup proportions in the mesh; physical body scale must be uniform. + mesh.apply_scale((0.75, 0.75, 1.0)) obj = sim.add_rigid_object( cfg=RigidObjectCfg( uid="paper_cup", shape=MeshCfg( - fpath=get_data_path(OBJECT_MESH_PATH), + vertices=mesh.vertices, + triangles=mesh.faces, + normals=mesh.vertex_normals, collision=MeshCollisionCfg( approximation="convex_decomposition", max_hulls=16, @@ -99,7 +105,6 @@ def create_pick_object(sim) -> RigidObject: newton_contact=sim.is_newton_backend, ), init_pos=[*OBJECT_XY, OBJECT_INITIAL_Z], - body_scale=(0.75, 0.75, 1.0), ) ) sim.prepare() diff --git a/scripts/tutorials/atomic_action/pour.py b/scripts/tutorials/atomic_action/pour.py index 34c2ef0e4c..56a39b75cd 100644 --- a/scripts/tutorials/atomic_action/pour.py +++ b/scripts/tutorials/atomic_action/pour.py @@ -39,7 +39,6 @@ PourOptions, ) from embodichain.lab.sim.motion.planners import ( - TrapezoidalPlanOptions, ToppraPlanOptions, TrajectorySampleMethod, ) @@ -103,14 +102,9 @@ def _create_pick_motion_policy( sample_method=TrajectorySampleMethod.QUANTITY, sample_interval=PICK_MOTION_SAMPLE_COUNT, ) - elif planner == "trapezoidal": - plan_opts = TrapezoidalPlanOptions( - sample_method=TrajectorySampleMethod.QUANTITY, - sample_interval=PICK_MOTION_SAMPLE_COUNT, - ) - elif planner == "curobo": - # cuRobo owns its native sampling and does not use the joint-space - # sample-count options above. + elif planner in ("trapezoidal", "curobo"): + # Preserve native waypoints before PickUp resamples its two motion + # segments. A fixed quantity can be smaller than the Cartesian IK path. plan_opts = None else: raise ValueError(f"Unsupported tutorial planner {planner!r}.") diff --git a/scripts/tutorials/atomic_action/tutorial_utils.py b/scripts/tutorials/atomic_action/tutorial_utils.py index 1167510b11..76e07f553b 100644 --- a/scripts/tutorials/atomic_action/tutorial_utils.py +++ b/scripts/tutorials/atomic_action/tutorial_utils.py @@ -267,10 +267,8 @@ def _tutorial_physics_cfg( ) -> PhysicsBackendCfg: """Build the shared physics configuration for atomic-action tutorials. - Newton tutorials intentionally use MuJoCo Warp's native collision path. - It generates contacts inside every solver substep, so an external Newton - collision pipeline would be unused and would only allocate unnecessary - contact buffers. + MJVBD V2 owns collision detection and retains MuJoCo articulation drives. + Free rigid bodies use VBD with the solver's native one-way coupling. """ physics_cfg = physics_cfg_for_backend(backend) if isinstance(physics_cfg, NewtonPhysicsCfg): @@ -279,20 +277,21 @@ def _tutorial_physics_cfg( # contacts and fast-changing manipulator loads. DexSim sizes # contact/constraint buffers from the finalized scene, including the # contact dimensions authored on gripper and object surfaces. - # MultiCCD retains up to four contacts per gripper-mesh/object pair, - # which prevents a marginal two-finger grasp from sliding away. + # Retain the existing MuJoCo articulation tuning. Free-body contacts + # remain VBD-owned and do not inherit these MuJoCo contact options. physics_cfg.num_substeps = 20 physics_cfg.collision_cfg = None physics_cfg.solver_cfg = { - "solver_type": "mujoco_warp", - "solver": "newton", - "integrator": "implicitfast", - "iterations": 20, - "ls_iterations": 100, - "cone": "elliptic", - "impratio": 1_000.0, - "use_mujoco_contacts": True, - "enable_multiccd": True, + "solver_type": "mjvbd_v2", + "mujoco_options": { + "solver": "newton", + "integrator": "implicitfast", + "iterations": 20, + "ls_iterations": 100, + "cone": "elliptic", + "impratio": 1_000.0, + "enable_multiccd": True, + }, } return physics_cfg diff --git a/scripts/tutorials/gym/modular_env.py b/scripts/tutorials/gym/modular_env.py index f7d33c5d75..e33bdc33c4 100644 --- a/scripts/tutorials/gym/modular_env.py +++ b/scripts/tutorials/gym/modular_env.py @@ -211,7 +211,7 @@ class ExampleCfg(EmbodiedEnvCfg): shape=MeshCfg( fpath=get_data_path("TableWare/tableware/fork/standard_fork_scale.ply"), ), - body_scale=(0.75, 0.75, 1.0), + body_scale=(0.75, 0.75, 0.75), init_pos=(0.8, 0, 1.0), ), ] diff --git a/scripts/tutorials/sim/open_drawer.py b/scripts/tutorials/sim/open_drawer.py index 58f893e342..99c0a55242 100644 --- a/scripts/tutorials/sim/open_drawer.py +++ b/scripts/tutorials/sim/open_drawer.py @@ -530,22 +530,21 @@ def _tutorial_physics_cfg( """Build the physics configuration used by this tutorial.""" physics_cfg = physics_cfg_for_backend(backend) if isinstance(physics_cfg, NewtonPhysicsCfg): - # Keep the same MuJoCo-Warp solver/contact profile as the atomic-action - # tutorial and packaged Newton task. The finer drawer substep cadence - # is intentional; per-world capacities remain auto-sized by DexSim - # from the finalized scene. + # Share the V2 articulation profile with the atomic-action tutorials. + # Keep the finer drawer substep cadence and native contact ownership. physics_cfg.num_substeps = 20 physics_cfg.collision_cfg = None physics_cfg.solver_cfg = { - "solver_type": "mujoco_warp", - "solver": "newton", - "integrator": "implicitfast", - "iterations": 20, - "ls_iterations": 100, - "cone": "elliptic", - "impratio": 1_000.0, - "use_mujoco_contacts": True, - "enable_multiccd": True, + "solver_type": "mjvbd_v2", + "mujoco_options": { + "solver": "newton", + "integrator": "implicitfast", + "iterations": 20, + "ls_iterations": 100, + "cone": "elliptic", + "impratio": 1_000.0, + "enable_multiccd": True, + }, } return physics_cfg diff --git a/tests/sim/test_cfg.py b/tests/sim/test_cfg.py index 13d74f2f72..523e1b6ef8 100644 --- a/tests/sim/test_cfg.py +++ b/tests/sim/test_cfg.py @@ -529,7 +529,7 @@ def test_robot_preset_accepts_newton_solver_alias() -> None: preset = _NewtonSolverAliasRobotPresetCfg() assert preset.resolve(DefaultPhysicsCfg()).uid == "fallback" - assert preset.resolve(NewtonPhysicsCfg()).uid == "fallback" + assert preset.resolve(NewtonPhysicsCfg()).uid == "mjwarp" assert ( preset.resolve(NewtonPhysicsCfg(solver_cfg={"solver_type": "mjwarp"})).uid == "mjwarp" @@ -812,6 +812,7 @@ def test_robot_cfg_merge_preserves_grouped_overrides() -> None: def test_newton_physics_inherits_common_gravity_and_collision_config() -> None: cfg = NewtonPhysicsCfg( + solver_cfg=None, gravity=[0.0, 0.0, -1.5], collision_cfg=NewtonCollisionPipelineCfg( broad_phase="sap", diff --git a/tests/sim/test_sim_manager_cfg.py b/tests/sim/test_sim_manager_cfg.py index a96f8e93cf..d34f11f2d4 100644 --- a/tests/sim/test_sim_manager_cfg.py +++ b/tests/sim/test_sim_manager_cfg.py @@ -124,15 +124,15 @@ def test_newton_physics_cfg_uses_device() -> None: @pytest.mark.no_sim -def test_newton_physics_cfg_preserves_dexsim_auto_solver_default() -> None: - from dexsim.engine.newton_physics import AutoSolverCfg +def test_newton_physics_cfg_defaults_to_mjvbd_v2_solver() -> None: + from dexsim.engine.newton_physics import MJVBDV2SolverCfg cfg = NewtonPhysicsCfg() dexsim_cfg = cfg.to_dexsim_cfg(gpu_id=0) - assert isinstance(dexsim_cfg.solver_cfg, AutoSolverCfg) - assert dexsim_cfg.solver_cfg.solver_type == "auto" + assert isinstance(dexsim_cfg.solver_cfg, MJVBDV2SolverCfg) + assert dexsim_cfg.solver_cfg.solver_type == "mjvbd_v2" @pytest.mark.no_sim @@ -174,7 +174,7 @@ def test_newton_physics_cfg_requires_dexsim_auto_solver_api( @pytest.mark.no_sim def test_newton_gradient_mode_rejects_auto_solver() -> None: - cfg = NewtonPhysicsCfg(requires_grad=True) + cfg = NewtonPhysicsCfg(solver_cfg=None, requires_grad=True) with pytest.raises(RuntimeError, match="explicit.*semi_implicit"): cfg.to_dexsim_cfg(gpu_id=0) @@ -193,7 +193,9 @@ def test_newton_physics_cfg_passes_warp_log_suppression() -> None: def test_newton_physics_cfg_forwards_collision_pipeline_update_interval( update_interval: int | None, ) -> None: - cfg = NewtonPhysicsCfg(collision_cfg={"update_interval": update_interval}) + cfg = NewtonPhysicsCfg( + solver_cfg=None, collision_cfg={"update_interval": update_interval} + ) dexsim_cfg = cfg.to_dexsim_cfg(gpu_id=0) @@ -296,7 +298,7 @@ def test_newton_backend_reports_scene_resolved_auto_solver( manager = SimpleNamespace(_world=world) backend = NewtonPhysicsBackend(manager) world_config = SimpleNamespace(newton_cfg=None) - sim_config = SimulationManagerCfg(physics_cfg=NewtonPhysicsCfg()) + sim_config = SimulationManagerCfg(physics_cfg=NewtonPhysicsCfg(solver_cfg=None)) monkeypatch.setattr( "dexsim.engine.newton_physics.backend_registry.get_newton_backend", lambda candidate: native_backend if candidate is world else None, From 731a20d032a49051942f3cafa3d41cde670ab00b Mon Sep 17 00:00:00 2001 From: xiemenghong Date: Fri, 18 Sep 2026 10:27:22 +0800 Subject: [PATCH 2/4] fix(sim): tune MJVBD V2 manipulation examples and record limitations --- .../topics/atomic-actions/atomic-actions.md | 29 ++ .../simulation-system/simulation-system.md | 62 +++- examples/sim/demo/grasp_cup_to_caffe.py | 3 +- examples/sim/demo/scoop_ice.py | 2 + outputs/validation/mjvbd_v2/MJVBDV2_issues.md | 350 ++++++++++++++++++ scripts/tutorials/atomic_action/axis_align.py | 11 +- .../atomic_action/coordinated_pickment.py | 32 +- .../atomic_action/coordinated_placement.py | 3 +- scripts/tutorials/atomic_action/hand_over.py | 53 ++- .../atomic_action/move_held_object.py | 29 +- scripts/tutorials/atomic_action/pickup.py | 11 +- scripts/tutorials/atomic_action/place.py | 38 +- scripts/tutorials/atomic_action/pour.py | 41 +- .../tutorials/atomic_action/scenario_utils.py | 4 +- .../tutorials/atomic_action/tutorial_utils.py | 44 ++- .../sim/atomic_actions/test_tutorial_utils.py | 48 +-- 16 files changed, 702 insertions(+), 58 deletions(-) create mode 100644 outputs/validation/mjvbd_v2/MJVBDV2_issues.md diff --git a/agent_context/topics/atomic-actions/atomic-actions.md b/agent_context/topics/atomic-actions/atomic-actions.md index 6cfc208ed7..5694c474a6 100644 --- a/agent_context/topics/atomic-actions/atomic-actions.md +++ b/agent_context/topics/atomic-actions/atomic-actions.md @@ -92,6 +92,35 @@ repeated-pick/open-drawer environment components carry the same Newton-only overlays, while their declared Default backend continues to consume only the portable fields. +For UR5 with `mjvbd_v2`, the paper-cup `move_held_object.py` tutorial opts into +VBD contact history with `latest` collision matching, sliding friction 4 on the +gripper alone, and a 0.0115 m candidate close target. Transport orientation +is not yet repeatably aligned. The native contact alpha and the cup +and ground materials are unchanged. `create_tutorial_simulation` accepts +`newton_solver_options`, and `add_tutorial_robot` accepts +`newton_gripper_friction` and optional `arm_damping`; these are authored before +model construction. This +calibration also applies to the UR5-only `pour.py` tutorial with its 0.013 m +cube close target. The UR5 plastic-tray `coordinated_pickment.py` tutorial uses +the same contact settings with a 0.023 m close target; the dual-arm helper +`add_dual_tutorial_robot` also accepts `newton_gripper_friction`. +The UR5 vertical-can `hand_over.py` tutorial uses those contact settings with +left/right close targets of 0.007/0.0055 m and retains its original arm drives. +Its replay callback holds the current targets for one second immediately before +the compiled `receive_release` segment so the receiving arm can settle before +opening. The wait uses segment metadata, not a fixed waypoint index, and is +scoped to that same profile. This scene-specific calibration does not promise +identical final poses or stability across initial-state changes. Horizontal +objects and other robot families retain their prior configuration. +The UR5 V2 `place.py` profile uses a 0.013 m close target, gripper friction 4, +contact history with `latest` matching, contact alpha 0.5, and arm damping 1000. +The lower arm damping reduces tracking lag when the fingers open; finger +drives and authored release waypoints remain unchanged. Complete cached +replays preserve the grasp to release, but landing orientation still varies; +this is a scoped improvement, not a claim of full solver equivalence. +These explicit scene choices do not change world defaults +or establish a generic object-width-to-gripper-target mapping. + ## Semantic integration boundary `semantics` contains: diff --git a/agent_context/topics/simulation-system/simulation-system.md b/agent_context/topics/simulation-system/simulation-system.md index 8872a5dbd3..1f52ad696d 100644 --- a/agent_context/topics/simulation-system/simulation-system.md +++ b/agent_context/topics/simulation-system/simulation-system.md @@ -494,12 +494,19 @@ CUDA. VBD contacts expose geometry without MuJoCo impulse reporting. V2 selects MuJoCo for articulations with active scalar joints and VBD for unselected free rigid bodies. Its current mixed dynamic branch is one-way: -VBD contacts do not push back on the MuJoCo robot, and MuJoCo contacts are -disabled in that branch. Therefore switching an existing locomotion or -manipulation scene to V2 does not by itself guarantee equivalent contact -dynamics. In particular, adding a VBD-owned free rigid body switches a floating -robot out of the articulation-only branch and removes its MuJoCo ground -support, even if the new body is far away. Explicit `mujoco_articulations` or +VBD contacts do not push back on the MuJoCo robot. The local, uncommitted DexSim +patch enables a second MuJoCo-Warp collision/contact pipeline by default; explicitly setting +`mujoco_options.disable_contacts=True` still disables them. The compact +MuJoCo view contains owned links and world-attached static shapes, but excludes +VBD-owned free bodies and independent kinematic bodies. A stationary fixture +declared kinematic therefore does not provide robot contact reaction in this +view; use static for fixtures that never move. The stationary tables in +`examples/sim/demo/grasp_cup_to_caffe.py` and +`scripts/tutorials/atomic_action/coordinated_placement.py` use this declaration. +Moving kinematic obstacles and +dynamic-object reaction remain separate limitations. Mixed contact queries +still lack equivalent impulse reporting, even when robot ground support is +restored. Explicit `mujoco_articulations` or `mujoco_articulation_paths` can select complete joint trees; these are ownership choices, not automatic EmbodiChain rewrites. This integration does not extend deformable support. @@ -536,6 +543,33 @@ Parallel-jaw manipulation keeps its Newton-only contact overlay (`condim=4`, `ke=4e4`, `kd=4e2`, torsional friction `0.1`, rolling friction `0.01`) on the gripper and manipulated objects. MuJoCo options affect articulation-owned contacts; free rigid-body contacts use VBD and need not have identical effects. +The UR5 `pickup.py` and `axis_align.py` tutorials use a 0.013 m +DH-gripper close target for their 5 cm cube under V2 +(`MJVBD_V2_CUBE_CLOSE_QPOS` in `tutorial_utils.py`). The old +0.036 m target relies on contact feedback to stop the fingers; V2's one-way +proxies instead reach that target and squeeze the cube out. This calibration +is specific to that object and gripper, not a general grasp-width mapping. +These two cube tutorials retain native VBD defaults. Their calibrated target +does not make the original oversized command compatible with one-way contact. +The UR5 `move_held_object.py` paper-cup tutorial uses a 0.0115 m candidate close target, +gripper-only sliding friction 4, VBD contact history, and collision matching +`latest`, retaining the native contact alpha. The shared simulation helper +accepts scene-specific `newton_solver_options`; robot creation accepts +`newton_gripper_friction` before spawning. The cup candidate has not achieved repeatable orientation alignment. These are explicit tutorial choices, +not world defaults, and leave the cup and ground materials unchanged. The UR5-only `pour.py` tutorial uses the same contact history and gripper +friction with a 0.013 m cube close target; its V2 initial height includes the +ground's 1 mm contact margin. Other robot selections and physics solvers keep +their existing targets and materials. +The UR5 V2 `place.py` tutorial additionally uses contact alpha 0.5 and arm +damping 1000 with the same cube target, gripper friction, and contact history. +`add_tutorial_robot(arm_damping=...)` authors this drive override before spawn; +other callers retain their configured gains. Release waypoints are unchanged, +and landing orientation remains sensitive to contact variation. +The `examples/sim/demo/scoop_ice.py` scene sets +`vbd_options.rigid_body_contact_buffer_size=256` for dense ice contacts. +This per-body VBD capacity is independent of MuJoCo's `nconmax`/`njmax`; +overflow truncates the contacts used by each affected VBD body. The larger +scene-specific capacity does not establish stable friction grasping. Explicit cloth, softbody, and differentiable examples keep their selected solvers. Newton's `suppress_warp_kernel_logs=True` suppresses Warp's one-time runtime banner plus module compile/load chatter during manager startup, build, facade @@ -545,6 +579,10 @@ information is controlled separately by `dexsim_startup_info`. EmbodiChain-authored Newton collision shapes use a default margin and gap of `0.001 m` each only when no portable or Newton-native envelope is authored. +The Pour tutorial starts its cube center at half its height. Under V2, Pour +and Place add 1 mm initial clearance for the default ground's contact margin, +avoiding penetration recovery before grasp planning. The global ground +configuration stays unchanged to preserve the pure-MuJoCo locomotion path. `CollisionPropertiesCfg.contact_offset/rest_offset` are portable: Default uses them directly, while the Spawn compiler maps `rest_offset → margin` and `contact_offset - rest_offset → gap`. Both values must be present to derive a @@ -1049,3 +1087,15 @@ Default source-physics capture preserves each link's replication collision filter while filling mass/COM properties. Spawn articulation mass-property writes use the live handle's `set_link_inertia` and `set_link_com_pose`; native COM quaternions are converted from EmbodiChain `xyzw` to DexSim `wxyz`. + +## Current MJVBD V2 validation dependency + +The local mixed-scene validation uses an uncommitted DexSim patch that defaults +`mujoco_options.disable_contacts` to `False` while retaining +`use_mujoco_contacts=True`. This runs MuJoCo-Warp collision/contact solving for +its articulation/static compact view alongside Newton/VBD contacts. It differs +from native V2 mixed-mode contact configuration and is not an accepted final +architecture. Mixed locomotion alignment measurements depend on this patch; +they do not establish native single-pipeline mixed-mode equivalence. A second +local DexSim patch fixes convex mesh import coordinates. Neither patch is +contained in this EmbodiChain commit. diff --git a/examples/sim/demo/grasp_cup_to_caffe.py b/examples/sim/demo/grasp_cup_to_caffe.py index b542d1967a..7e07355534 100644 --- a/examples/sim/demo/grasp_cup_to_caffe.py +++ b/examples/sim/demo/grasp_cup_to_caffe.py @@ -213,7 +213,8 @@ def create_table(sim: SimulationManager) -> RigidObject: attrs=RigidBodyPhysicsCfg( mass_props=MassPropertiesCfg(mass=0.5), ), - body_type="kinematic", + # This fixture never moves; static shapes also enter V2's MuJoCo view. + body_type="static", init_pos=[1.1, -0.5, 0.08], init_rot=[0.0, 0.0, 0.0], ) diff --git a/examples/sim/demo/scoop_ice.py b/examples/sim/demo/scoop_ice.py index a809ad6f65..0f972e38c1 100644 --- a/examples/sim/demo/scoop_ice.py +++ b/examples/sim/demo/scoop_ice.py @@ -82,6 +82,8 @@ def initialize_simulation(args): physics_cfg.solver_cfg = { "solver_type": "mjvbd_v2", "mujoco_options": {"solver": "cg"}, + # Dense ice contacts exceed VBD's default per-body capacity of 64. + "vbd_options": {"rigid_body_contact_buffer_size": 256}, } config = SimulationManagerCfg( headless=True, diff --git a/outputs/validation/mjvbd_v2/MJVBDV2_issues.md b/outputs/validation/mjvbd_v2/MJVBDV2_issues.md new file mode 100644 index 0000000000..8f3e575569 --- /dev/null +++ b/outputs/validation/mjvbd_v2/MJVBDV2_issues.md @@ -0,0 +1,350 @@ +# MJVBDV2 接入问题记录 + +更新日期:2026-09-18 + +这份记录整理 MJVBDV2 接入 EmbodiChain 后遇到的问题:实际看到了什么、会影响什么、哪些已经修复、哪些还需要继续查。 + +这里的“与旧 solver 对齐”,指的是换 solver 后表现接近,不代表任务一定成功。例如,两边的抽屉都没有关上,仍可能是表现接近;两边程序都正常退出,也不代表物体的运动一致。文中的旧 solver 指 Newton 后端的 `mujoco_warp`。 + +本次保留 MJVBDV2 的物体所有权分工:带关节的机器人、门和抽屉由 MuJoCo 求解,自由运动的杯子、方块等刚体由 VBD 求解。布料、软体不在这次接入范围内。**但本轮 DexSim 补丁额外开启了混合模式的 MuJoCo 原生接触,实际运行两套碰撞管线,已经偏离原生混合模式的接触配置。详见文末更正。** + +本文链接的详细报告和原始数据是本地验证产物,未随这份问题记录提交到 GitHub。 + +**目前仍未完成全部动态刚体任务对齐。** 调参已恢复了一部分技能,但单次成功、停止后不掉落,都不能代表稳定替换。当前状态如下,后文保留问题的发现过程;详细试验以[第二轮调参记录](coupling_tuning/round2.md)为准。 + +| 场景 | 当前结论 | +| --- | --- | +| PickUp、Pour、Place、双臂抬托盘 | 已有完整改善结果和正式入口验证;仍缺跨初态稳定性证据。 | +| 纸杯 MoveHeldObject | 最新 11.5 mm 正式入口完整完成,位置误差 2.90 mm、姿态误差 11.32°;停止后基本稳定,但搬运转偏未解决。此前缓存的 3.57° 好结果未稳定复现。 | +| HandOver | 释放前等待一秒后,三次候选及正式入口均直立停稳;不代表新旧最终位姿完全一致,跨初态尚待验证。 | +| Assemble | alpha=0.5 的完整候选偏心 6.93 mm;重复及重新规划待结果。单纯延长释放等待无效,局部接触余量对照继续进行。 | +| 双臂放置 | 未恢复预期效果。已确认新旧 solver 在同轨迹下均被桌子挡住,右手偏差约 7–8 cm;安装位置对照待结果,抓持也仍需改善。 | +| 咖啡杯示例 | 新旧正常规划都没有稳定完成。已排队验证规划前自然落稳的影响,尚未证明等待有效。 | +| 舀冰 | 接触容量已修复;完整候选带出 5–6 块冰,但勺子姿态仍偏约 15–17°。摩擦、刚度对照继续运行;冰堆沉降差异也会影响结果,不能只比较一次带出数量。 | +| Locomotion | 已有约 1e-6 rad 量级的同动作状态对齐证据;混合模式结果依赖额外开启 MuJoCo 原生接触,不能证明原生单管线混合模式对齐,也不能替代完整训练验证。 | +| Twist | 按要求暂时跳过。 | + + +## 目前还有哪些问题 + +### 新发现:舀冰时 VBD 的接触列表装不下 + +**状态:容量 256 已完整运行,无溢出警告;舀冰例程已采用该容量,抓持稳定性继续调参。** + +抓持改善后的两次完整舀冰出现数千次接触溢出。一个动态刚体最多需要 170 / 183 个接触位置,但 VBD 默认只给每个刚体保留 64 个;超过容量的部分没有进入该刚体的接触求解。这与 MuJoCo 的接触、约束容量是两套设置,之前扩大 MuJoCo 容量不能解决它。 + +这是此前验证遗漏的一项,现予以更正:带出 1 / 3 块冰和滑转较大的结果真实存在,但接触已经被截断,不能据此判断单向耦合的能力上限。只把 VBD 容量提高到 256 后,已完整运行 3300 步,采样峰值 188、无溢出警告;最后带出 6 块冰,其中 5 块在保持前后采样中都位于勺碗范围。但勺子累计手内变化仍约 16.84 mm / 16.78°,说明排除截断后仍需改善抓持。随后原闭合目标也完整完成 3300 步,无溢出、采样峰值 192,末尾带出同一批 5 块冰;位置误差 22.62 mm、姿态误差 14.86°。原目标末尾保持更好,标定目标前段滑转更小,两者尚无全面胜出的配置。手部摩擦和接触刚度的首次独立对照都被临时记录器的法向量断言中断,尚无完整效果结论;记录器已改为保存异常原始值并明确标记不可计算的指标,两组按原物理参数重跑。对应 HandOver、双臂放置、咖啡杯和 Place 日志未发现同类警告,不能用这个问题解释所有未对齐任务。 + + +### 1. 混合场景的接触支持仍不完整,地面支撑已修复 + +**状态:本地小补丁已构建并安装到 embodichain 环境,恢复 MuJoCo 自有接触;接触力查询和动态物体反力仍有边界。补丁尚未提交或推送。** + +此前只有机器人和静态地面时,V2 使用纯 MuJoCo 分支,机器人可以正常行走。加入 VBD 动态刚体后切换到混合分支,却关闭了 MuJoCo 自身接触,连远处方块也会间接导致机器人失去地面支撑。这是已经确认的接入问题,不必通过重写双向耦合解决。 + +修正后,混合分支默认保留机器人与 MuJoCo 可见静态环境的接触,自由刚体仍归 VBD,反力仍不回传。直接加载补丁源码的四环境 GPU 对照完整运行 1500 步及五次重置,无容量溢出,关节最大差约 1.13e-6 rad,终止标志一致。随后正式 wheel 已安装,正常安装包入口的 CPU 混合落地及纯分支检查均通过。GPU 安装包任务回归仍在进行。 + +这项修正恢复地面支撑,但不代表混合场景的接触力查询已经与旧 MuJoCo 一致。若任务依赖动态物体把反力传给机器人,仍受单向耦合限制。 + +补充确认:静止的桌子如果被配置成独立的 `kinematic` 物体,也不会自动进入混合分支的 MuJoCo 碰撞模型。咖啡杯示例中,旧 MuJoCo 有桌子的 8 个碰撞几何,V2 的 MuJoCo 模型里没有它们。杯子仍会碰到桌子,但机器人不会收到这部分接触反力。示例中的桌子从不移动,已将它改为 static,运行时确认两边 MuJoCo 模型均有 8 个桌子碰撞几何。修正桌子后,最初的新旧咖啡杯完整任务仍失败,说明这不是全部原因;随后手部接触调参才出现完整改善候选。真正会运动的 kinematic 物体不能用这种场景修正替代支持。 + +### 部分接触参数在 VBD 中的作用与旧配置不同 + +**状态:已核对源码及 CPU 接触力;这不是所有剩余失败的原因证明。** + +- 当前默认的刚体硬接触不使用 `friction_epsilon`。只改变它不会调整这条分支的摩擦;原计划的纸杯候选已在启动前撤销。 +- 相同的夹爪接触余量也未必有相同效果:当前 UR5 手指的 1 mm margin 在 MuJoCo 原生碰撞中被清零,在 VBD 中仍保留。双臂放置的局部零余量候选仍在旧缓存的协作段甩出面包,已明确记录后提前停止,未修改全局默认;这不代表所有任务都不适合零余量,Assemble 的独立对照仍待结果。 +- 当前 VBD 刚体接触没有读取独立的扭转、滚动摩擦系数。旧 MuJoCo 中有效的扭转摩擦配置,不会自动得到等价作用。多个接触点仍可能通过切向力抵抗旋转,因此不能直接推断所有抓持都不适用。 +- 手指和物体的滑动摩擦取几何平均。例如手指设为 4、杯子为 0.97,接触对约为 1.97;刚度和阻尼则取两侧的算术平均。调参应比较最终接触对,而不只看某一个配置字段。 +- 接触阻尼 `kd` 在硬接触中有效,但只抵抗接触面相互接近的法向运动,不是通用的止滑、止转参数。安装包 CPU 核对中,增大它能提高接近时的法向阻力,却没有同步提高该瞬间的切向摩擦上限;法向不再接近时,这项阻尼不生效。不能因此断言某个任务失败由它造成,但不应把增大 `kd` 当作普遍增强抓持的手段。 + +单点纯扭转的 CPU 核对显示,提高滑动摩擦无法产生缺失的独立抗扭项。它只说明该力模型的边界;具体技能是否依赖这项能力,还需要实际接触几何和完整任务证据。详细记录及原始数据见[第二轮调参记录](coupling_tuning/round2.md)。 + +全程关闭接触点黏着重放也不是通用解法:HandOver 的独立候选在最终松手前就提前脱手,完整运行后侧倒。当前保留该设置,优先重复验证释放前等待的候选。这个失败不能证明只在释放阶段关闭重放也一定无效。 + +### 调参时要注意:刚体的旧阻尼字段不会改变 Newton 运动 + +**状态:已核对当前构建和运行时赋值路径,并用安装包 CPU 模型检查确认;不是 MJVBDV2 独有的新问题。** + +例程给杯子、勺子等刚体设置的 `linear_damping` / `angular_damping`,在当前 Newton 路径中只保留为属性记录。读回数值变了,不代表运动真的受到了更强阻尼。安装包检查将两项都从 0 改成 100,质量、惯量、速度、关节阻尼及接触材料等相关模型数组完全相同。 + +这与已经用于 Place、Assemble 调参的机械臂驱动阻尼不同;后者通过关节驱动配置实际进入求解。旧 `mujoco_warp` 和新 `mjvbd_v2` 共用上述刚体构建路径,因此不能据此解释两者所有差异,也不应通过放大这些无效字段来“修复”滑转。 + +DexSim 另有显式施加角阻尼力矩的运行时控制,但它需要单独注册,系数是力矩阻尼系数,不能直接照搬这里的旧数值。目前没有把它叠加到任务候选中,仍先完成接触摩擦与刚度的独立验证。证据见 `coupling_tuning/raw/r2_rigid_damping_mapping_cpu.json`。 + +### 2. 部分抓取、搬运任务与旧 solver 表现不同 + +**状态:本轮调参后部分恢复,尚不能整体认定对齐。** + +第二轮已经取得几项改善: + +- 纸杯的抓起和搬运已经能完整执行,但姿态精度不稳定。最新 11.5 mm 正式入口误差为 2.90 mm / 11.32°,而同闭合量此前缓存为 5.01 mm / 3.57°,旧 MuJoCo 独立规划为 3.69 mm / 2.88°。因此不能把缓存的一次改善写成已经对齐;当前精确缓存重复用于定位差异,未增加新的物理参数组合。 +- 同一接触配置用于 PickUp 后,最终差约 1.9 mm / 2.1°;Pour 完整 2933 步后差约 3.4 mm / 0.52°,均没有掉落。AxisAlign 恢复了对齐目标轴的效果,但旧对照自身掉落,暂不称为严格对齐。 +- 双臂托盘使用手指摩擦 4 和接触历史后,26、22.5、23 mm 闭合目标均完成搬运及额外 4.8 秒保持,22 mm 则只抬起了一部分。选择 23 mm 接入 UR5 塑料托盘入口;该候选最终与旧 MuJoCo 相差约 3.7 mm / 4.4°,距任务目标约 7.2 mm,旧 MuJoCo 为 9.3 mm。正式入口重新规划后也完整完成 888 步,得到一致结果;仍不能推广到其他尺寸及所有物体。 +- Place 需要额外调整:保留原 mimic,使用接触 alpha=0.5,并把机械臂阻尼降至 1000。四次完整回放均保持到释放,水平落点误差约 0.52–3.77 mm,其中一次直接使用新安装包。配置已接入 UR5 V2 教程;落地朝向约在 82.1–94.8° 之间波动,姿态差异尚未消除。正式入口重新规划随后完成 778 步,水平误差 2.35 mm,yaw 85.31°,与旧低阻尼对照姿态差约 0.37°,末尾稳定;仍未覆盖初态扰动。 + +Place 的诊断过程也排除了一个过于简单的解释:降低 mimic 阻尼虽然改善了手指跟随,却没有消除掉落;接触参数和机械臂驱动响应都参与了结果。详细试验保留在调参记录中。 + +换手原无等待配置不稳定,重复曾侧倒。保留左手 7 mm/右手 5.5 mm、手指摩擦 4、接触历史和原机械臂驱动,增加释放前一秒等待后,三次完整运行均直立停稳,水平误差约 13–16 mm。等待已接入 UR5 竖直罐子的教程,正式源代码入口随后完整完成 1776 步,水平误差 12.36 mm、直立倾斜 0.020°,最后两秒稳定。最终朝向仍有波动,重新规划生成的指令也与缓存几乎相同,尚未证明不同初态下的稳定性。 + +推物也得到改善:接近距离保持 30 mm,将推进补偿从 18 mm 调到 30 mm 后,完整任务的水平误差为 8.59 mm、姿态误差 0.82°,均优于旧对照的 10.35 mm / 1.78°。38 mm 补偿虽然进一步减小位置误差,却使姿态误差升至 6.44°,暂不采用。30 mm 候选随后三次完整运行的水平误差为 8.59 / 6.79 / 8.95 mm,姿态误差为 0.82 / 2.62 / 7.07°;其中一次重新规划,位置改善但姿态仍有波动,不能直接推广为所有物体的默认值。 + +这些是完整固定轨迹回放的证据,仍需正式入口实时重新规划和重复验证,不能推广为全部任务已经对齐。Place 的旧 MuJoCo 重复运行也会出现不同落点,需要同时报告技能效果和新旧轨迹差异,不能只挑一次成功结果比较。 + +Pour 还有已确认的初始化错误:5 cm 方块中心原来在 z=0,一半体积穿地,使规划器读到被顶起后的错误位置。现在改为半边长高度,V2 再留出 1 mm 初始间隙。**当前全局地面参数保持原值。** 之前清零地面余量的尝试因 locomotion 回归而撤回,上述最新 Pour 结果不依赖这项修改。详见 [第二轮调参记录](coupling_tuning/round2.md)。 + +下文是第一轮历史结果,并不代表所有候选的最新状态。 + +2026-09-17 补充:对 UR5 的 DH 夹爪,把 5 cm 方块的闭合目标从 0.036 m 改为 0.013 m 后,PickUp 和 AxisAlign 已通过完整动作及最终保持。PickUp 的最终物体中心与同轨迹 MuJoCo 对照相差约 1.9 mm;AxisAlign 最终目标轴误差约 0.75°。Place 的候选仍在搬运途中提前掉落,最终落点接近目标不能算成功,候选改动已撤回。单独增加迭代、启用接触历史或改变刚度等尝试没有恢复原来过大的闭合目标。MoveHeldObject 的 0.0115 m 候选完整跑完后没有掉落,但最终位置误差约 11.4 mm、姿态误差约 23.8°,尚未恢复目标位姿,未设为默认。 + +原因是旧 MuJoCo 的接触反力会把手指挡在约 0.012 m,V2 单向耦合则让手指真的闭合到 0.036 m。对已知物体标定闭合目标可以改善效果,但不能当作原始控制命令完全不变的替换。 + +补充几何核对:DH 夹爪原始碰撞网格在采样抓持区域的开口约 73.5–75.1 mm,不是规划模型填写的 100 mm。按关节运动计算,36 mm 目标会把间隙缩到约 1.5–3.1 mm,13 mm 目标则约为 47.5–49.1 mm。通用闭合适配必须使用实际夹爪标定,不能直接从规划模型最大开口换算。这是静态几何证据,尚未包含碰撞余量与求解过程。 + +第一轮 Pour 的无效固定轨迹在旧 MuJoCo 下也没抓住物体;第二轮已定位其初始化原因,并重新建立有效对照。第一轮筛选和验证边界见 [第一轮调参记录](coupling_tuning/report.md)。下面保留的是**上一轮沿用旧参数时的观察**,不是调参后的结果。 + +最常见的现象是:机器人按规划运动了,但物体没有被稳定夹住,抬起后滑落,或者没有到达预期位置。 + +| 场景 | MJVBDV2 的实际表现 | 旧 solver 的对照 | +| --- | --- | --- | +| PickUp | 方块短暂抬起后滑落,最终中心高度约 2.6 cm | 最终中心高度约 18.2 cm | +| MoveHeldObject | 杯子滑落,没有到达搬运目标 | 最终物体位置距目标约 3.7 mm | +| Pour | 方块没有保持夹持,倾倒动作未达到预期效果 | 对照中方块最终仍保持在约 18.1 cm 高处 | +| 双臂协作抬托盘 | 托盘只部分抬起,最终位置距目标约 6.6 cm | 距目标约 9.5 mm | + +这些场景涉及机器人与自由刚体的接触。V2 的求解方式和反力传递与旧 solver 不同,是需要重点检查的因素;目前没有逐项证明每个失败都只有这一个原因。 + +也不能据此认定所有 manipulation 都不能用。已有 UR5 抓放流程在一次运行中连续完成了三轮抓放,但那不是多次独立实验得出的成功率。 + +诊断时尽量固定初态和机械臂路径,逐项改变夹持指令、接触或驱动参数,观察物体从哪一阶段开始偏离。验收时再比较完整任务效果,并明确哪些参数或时序已经改变。放慢动作后成功可以是有效适配,但不能据此声称原时序直接替换已经对齐。 + +### 双臂放置的桌子:外观和碰撞形状没有对上 + +**状态:小补丁已构建并安装,正常安装入口检查通过,尚未提交或推送。** + +桌面看起来在 0.65 m 高,但实际碰撞网格最高只有约 0.553 m,横向也有偏移。旧 MuJoCo 和 V2 都受影响,面包与平底锅还没被抓住就掉下去了。这个现象不能用来判断 V2 的抓取能力。 + +原因是单凸包构建时重新用 Newton 读取 GLB,与 DexSim 渲染导入采用了不同坐标。改为使用已导入顶点后,桌子的碰撞坐标与外观恢复一致。面包还存在约 20 mm 的初始穿透;消除穿透后,两种 solver 的启动诊断都能让物体留在桌上。正式修正保持单凸包,不改变刚体所有权;没有增加新的仓库测试。几何修正后的旧 MuJoCo 完整动作已验证:前置抓取恢复,但面包仍在后续协作搬运中甩出;V2 候选继续验证。 协作放置源码中始终不动的桌子也已改成 static,确保它进入 V2 的 MuJoCo 接触模型;这不等于抓持问题已修复。 + +### 双臂放置:旧缓存不能代表正常规划,锅也没有准确到位 + +**状态:正常重新规划已完整运行,仍未达到预期落放效果;继续定位,不据此判定单向耦合不适用。** + +最新候选正常生成三段计划,前两段与旧缓存相同,第三段却明显不同:左手末端峰值速度约为旧缓存的六分之一。面包这次没有早早甩出,最后停在锅所在区域,但朝向几乎翻转,锅本身也偏离目标约 94 mm,不能只看“没有落地”就算成功。 + +释放前,右手离它应该到的位置约 78 mm,锅在手里的相对位移约 8 mm。这说明需要先查右臂为什么没走到位,继续提高夹爪摩擦并不对症。旧 MuJoCo 随后回放同一条新轨迹,右手同样偏离约 78 mm;协作阶段采样持续有右上臂与桌子的接触,驱动与约束力矩大幅对抗,两侧右臂实际关节最大差仅 2.15e-6 rad。这部分大误差并非 VBD 特有,需要先修正场景或路径。详细证据见[第二轮调参记录](coupling_tuning/round2.md)。 + +补充几何核对:右手目标姿态会让右上臂碰撞形状与桌子实体相交,并非只在桌下空隙中发生凸包假碰撞。这是需要先处理的场景/机械臂姿态问题,继续增大驱动力可能只会加深穿透。离线 IK 找到了其他不撞桌的终点姿态,但尚未验证完整路径;运行时接触对照已支持桌子阻挡这一判断;提高机器人安装位置的新旧正常规划对照仍待结果。当前没有为让示例通过而关闭桌子碰撞或改动规划框架。 + +仅把夹爪余量清零也没有解决双臂放置:面包在协作段被甩到工作区外约 4.9 m,确认剩余动作无法重新抓取后主动停止。该候选只运行了 2200 步,作为失败筛选记录,不计作完整验证。 + +### 3. Twist 是一个需要单独排查的例外 + +**状态:已观察到明显差异,原因尚未确定。** + +Twist 的默认场景是机器人与微波炉,主要对象都是带关节的结构,没有单独的动态自由刚体。因此,不能用“机器人和 VBD 物体之间缺少反力”来直接解释这个例子。 + +已有回放中,V2 的旋钮最终转角约为 **2.154 rad**,旧 solver 约为 **1.092 rad**,而且微波炉门也出现了不同程度的运动。 + +这说明“只要都是 articulation,就一定完全一致”还不能成立。不过,之前这组教程对照并没有严格锁定整段动作序列,规划和采样也不是完全受控的,所以目前记录的是待排查现象,还没有确定是哪一处物理实现出了问题。 + +本轮按要求跳过 Twist。若以后恢复排查,应使用同一段动作回放,并核对两边实际生效的接触、摩擦和关节参数。 + +### 4. Twist 启动时会打印大量 margin 警告,配置的 1 mm 没有生效 + +**状态:已确认,仍存在。警告背后的参数变化是真实的。** + +典型输出是: + +```text +authored margin=0.001... zeroed for NATIVECCD/MULTICCD compatibility +``` + +意思是:碰撞形状原本配置了约 1 mm 的接触提前量,但 solver 为兼容当前 MuJoCo-Warp 的原生接触算法,把它改成了 0。 + +Twist 教程启用了多接触点生成。夹爪有多个碰撞形状,每个相关形状都可能打印一条警告,因此启动时会看到很多行。仿真可以继续,但这 1 mm 的配置确实没有被保留,接触建立的时机可能受到影响。 + +这段逻辑在 MR 原始分支里就存在,不是本次 Contact Query 补丁新增的。目前也还没有证据证明它就是 Twist 新旧表现不同的原因。 + +**不能直接照警告建议,把 `use_mujoco_contacts` 改成 `False`。** 当前 V2 的纯 MuJoCo 分支要求这个选项为 `True`,直接修改会报错。警告里的建议适用于通用 MuJoCo solver,没有考虑 V2 的这一限制。 + +后续需要确认这类场景实际需要怎样的接触距离设置,并让警告给出适合 V2 的说明。只隐藏日志不会恢复被清零的参数。 + +### 5. Contact Query 能用,但混合场景还不能提供同样的力反馈 + +**状态:纯 MuJoCo 分支已接通并验证;混合分支的能力仍有限。** + +| 场景 | 当前能拿到什么 | +| --- | --- | +| 带关节机器人+静态地面,使用纯 MuJoCo 分支 | 接触对象、位置、法线、距离,以及法向冲量和摩擦冲量 | +| 包含 VBD 动态刚体的混合分支 | 接触几何信息;还没有与纯 MuJoCo 分支等价的接触冲量、力反馈 | + +因此,“能查到碰撞位置”和“能获得训练需要的接触力”需要分别确认。使用接触力作为 observation 或 reward 时,必须核对当前分支实际支持的字段。 + +此外,接口提供的冲量不是直接的力。本次足端力比较是用冲量除以对应的物理子步时间得到的,不能改用策略更新间隔来换算。 + +### 6. 位置控制下,`get_qf()` 不能当成实际电机输出力矩 + +**状态:已确认的现有 Newton 接口限制,不是本次证明出的 V2 独有问题。** + +在本次位置 PD 控制的行走验证中,`get_qf()` 读到的数组一直为 0。检查后确认,当前 Newton 路径读的是直接输入给关节的力矩命令,没有包含 PD 控制器实际产生的力矩。 + +**影响:不能拿这个全零数组来证明两边电机力矩一致,也不能直接用它计算实际力矩或能耗惩罚。** 如果训练任务需要这些奖励项,需要另行接通实际输出力矩,并确认它的含义。 + +## 接入过程中已经修复的问题 + +这些问题已经纳入补丁。下面保留记录,便于以后遇到类似现象时追查。 + +| 问题 | 当时的影响 | 当前处理 | +| --- | --- | --- | +| 接触查询和部分关节操作找不到 V2 内部的 MuJoCo solver | 原来直接访问 MuJoCo 的代码不能直接用于 V2,碰撞形状编号也需要转换 | 已接通内部 solver 的访问和编号转换;纯 MuJoCo 接触反馈已做数值对照 | +| 更新机器人姿态时,可能把自由刚体也写回旧位置 | VBD 已经算出的物体运动被旧关节数据覆盖 | 已限制更新范围,保留 VBD 计算出的自由刚体位置 | +| 瞬移物体后,物体会继续异常移动 | 零重力下把物体从 x=3 移到 x=4,之后两步却跑到 x=5 | 已同步求解器内部的历史状态;复测可以停在 x=4,并保留原有速度 | +| CUDA Graph 预热后,公开状态恢复了,内部历史没有恢复 | 正式仿真的第一步可能使用预热留下的状态,影响初始运动 | 已补齐内部状态恢复,并验证重建后继续步进 | +| VBD 中用于表示机器人的碰撞代理姿态处理不正确 | 代理可能使用回退后的姿态参与接触计算 | 已让不由 VBD 积分的代理保留传入姿态 | +| 混合分支关闭 MuJoCo 接触后,接触缓冲区容量为 0 | 某些摩擦计算路径会除零 | 已保留一个不使用的接触槽;没有因此重新启用 MuJoCo 接触 | +| reset 不能正确覆盖 V2,或把自由刚体的内部关节误算成机器人 | 环境复位可能报错或清理范围不正确 | 已适配;验证了单环境、部分环境和全部环境 reset | +| Gym reset 时删除并重建同名资产失败 | modular Gym 不能正常连续运行多个 episode | 已补齐同名替换:新对象使用新初值,其他对象保留原状态 | + +教程里还修复了几项与 solver 对接有关的问题,包括杯子缩放、Pour 的轨迹重采样、速度跟踪读取状态的时机,以及关闭物理碰撞后规划器丢失障碍物几何。这些修复让程序能正确执行,但不会自动解决抓取接触效果的差异。 + +## 行走已经确认到什么程度 + +在 **ANYmal-C+静态地面/平台** 范围内,当前适配版本与旧 solver 的行为接近。4 个环境分别执行前进、侧移和转弯,每个环境运行 30 秒,并覆盖了局部 reset。 + +相同动作输入下,正常行走时的关节位置最大差约为 **0.0000011 rad**,足端法向力分量最大差约为 **0.015 N**。旧 solver 自己重复运行也会有同量级差异;接触数量和接触/离地标记一致。 + +让两边各自运行策略时,转弯环境会出现步态相位差:机身位置最大差约 1.78 cm,旧 solver 自己重复运行约 1.92 cm。因此,可以说这组场景的行走效果接近,不能说逐帧完全一致。 + +把机器人强行移入地面的压力检查中,两种 solver 都出现了较大的接触力波动。这部分结果没有计入上面的正常行走指标。 + +**实际训练是否能达到相同效果还没有验证。** 本次没有进行 PPO 从零训练,也没有验证具体训练任务的完整 reward、done、域随机化或复杂地形。行走回放通过不等于学习曲线已经对齐。 + +## 一起发现、但不能归为 V2 新增的问题 + +- Press 的按钮行程在新旧 solver 中都出现越限;Slide 在两边都没有完全关上抽屉;OpenDoor 在两边都有打开后回摆。这些任务本身仍需改进,不能只按任务失败就判定 V2 不对齐。 +- 现有 Newton 后端尚未支持通用刚体约束,旧 solver 路径也没有这项能力。 +- USD 导出可以生成文件,但还没有完整写出 Newton 的刚体、关节等物理信息,不能当成可完整还原的仿真场景。 +- NeuralPlanner 缺少匹配的模型资源,尚未完成对应验证。 +- 有些入口不加 `--physics newton` 时会运行默认后端。比较结果前需要确认实际 backend 和 solver,不能只根据“安装了哪个 DexSim”判断运行路径。 + +## 这份记录对应哪一版 + +- EmbodiChain:[draft PR #645](https://github.com/DexForce/EmbodiChain/pull/645),代码提交 `75d3c9a3`。 +- DexSim:[MR !1345](http://192.168.3.16/Engine/dexsim/-/merge_requests/1345),适配补丁已提交到 `MJVBDV2` 分支,提交 `f7d60c2a2`。 +- 验证使用的是包含这些补丁的本地构建,不代表未经适配的早期分支也具备同样能力。 + +此前覆盖了 15 项内置原子技能、18 个原子教程和另外 26 个 Newton 示例入口,但没有穷举所有机器人、参数和规划器组合。最后一轮补丁后,只对受影响场景进行了针对性复测,没有把全部入口再跑一遍。操作任务的多数结果来自单次回放,不能当成统计成功率。 + +详细数据见[示例与原子技能验证报告](/home/oem/code/EmbodiChain/outputs/validation/mjvbd_v2/report.md)和[行走对齐验证报告](/home/oem/code/EmbodiChain/outputs/validation/mjvbd_v2/locomotion_alignment/report.md)。 + +## 最新补充:舀冰旧基线已经跑通 + +旧 MuJoCo 的接触和约束容量增到 8192 / 16384 后,完整完成了 3300 步舀冰与末尾保持,没有 CUDA 错误或容量溢出。勺子没有脱手,最后距目标约 5.6 mm / 1.7°,11 块冰块处于勺斗范围内并已抬升约 29–34 cm。之前“没有有效旧基线”的状态因此更新;具体指标及限制见第二轮记录。V2 的相同种子完整对照尚待运行,不能先宣布舀冰已经对齐。 + +### 2026-09-18 补充:舀冰的完整失败证据 + +新旧 solver 都完整运行到 3300 步,包含全部舀冰动作和末尾保持。旧 MuJoCo 保持勺子,并在勺碗区域带出 11 块冰;当前 MJVBDV2 在抬升时脱手,最终勺子落地,没有带出冰块。两侧手指、勺子的材料输入一致,但接触求解方式不同。此结果确认当前配置没有恢复任务效果,不足以证明单向耦合永远无法完成该任务。 + +正在验证的改进仅涉及手指摩擦、接触历史、闭合姿态和分段闭合指令。没有改变刚体归属,没有附着物体,没有增加仓库测试或 benchmark。分段闭合仍占原来的 100 个物理步,避免用额外等待掩盖差异。 + +### 交接的重复性仍不合格(2026-09-18 补充) + +交接不能只看最好的一次。正式安装包入口两次完整运行的水平落点误差分别为 31.60 mm 和 15.37 mm,两次指令几乎一致。此前表现较好的缓存候选再次完整运行时还出现侧倒,误差 45.91 mm。因此,当前夹爪和接触配置仍不足以稳定替换旧 solver,教程内的参数只能视为本地候选。 + +后续分别检查“机械臂尚未到位就松手”和接触历史中的黏着锚点。先前数据已把主要差异放大阶段定位到释放和落地,但尚未证明是哪一项机制造成失败;不能用未经验证的原因解释掉这些失败。 + +### 舀冰的旧对照也需要重新核实(2026-09-18 补充) + +当前安装包的旧 MuJoCo 补充运行在第 868 步出现冰块非有限位姿,接近阶段已可见飞散,未完成任务。此前成功的旧侧 3300 步记录早于本轮补丁安装,不能直接当作当前版本的严格基线。正在核对单凸包网格导入并补当前安装包的完整旧对照;尚无证据断言该发散由网格补丁造成。V2 此前抬升时丢勺子的失败仍然有效,并未因旧对照异常而撤销。 + +### 舀冰抓持已有改善,但没有提前判定任务通过(2026-09-18) + +正常安装包下,只将手部摩擦设为 4 并启用接触历史,原闭合目标不变,V2 完成了前 1200 步抓持和抬升:勺子抬高 33.7 cm,没有掉落。原闭合目标下相对手部仍有约 3.4 mm / 5.7° 的滑转;随后小幅标定六个手指目标,完整抬升的相对变化降至约 1.14 mm / 1.49°。两组均未脱手,但完整进入冰堆、舀出冰块和保持尚待验证。该结果支持继续调参,不能据此宣称舀冰已对齐。 + +另外,一个代表冰块在新旧网格导入路径下的凸包顶点、尺寸、体积,以及同一 CPU 算法计算的质量、质心和惯量均完全一致。目前没有证据把旧侧发散归因于该冰块的外形或惯量被补丁改坏。 + +### 舀冰盖子驱动是一个新的待验证因素 + +盖子初始是打开的,但配置的驱动没有生效,机械臂接近阶段盖子会明显转动。旧侧冰块飞散也发生在这一阶段,尚不能证明两者是因果关系;V2 中盖子同样转动,冰块却保持稳定。已准备新旧共同的对照,用有限力矩的位置驱动保持盖子打开,仍保留动态关节和碰撞。结果待运行,未把它当作已经修复的问题。 + +### 完整舀冰、双臂放置仍有实质差距 + +舀冰标定候选已经完整完成 3300 步,能带出 3 块冰;只改摩擦和接触历史、保留原闭合目标时为 1 块。但历史旧侧能带出 11 块,标定候选末尾目标误差仍有约 22.69 mm / 14.76°,抓持和末尾保持还不够稳定。分段闭合在修正诊断脚本后完成了阶段验证,反而比闭合姿态标定滑转更大,暂不采用。 + +双臂放置的右夹口修正后,抬锅明显稳定了,但面包仍在协作阶段脱手。放慢第三阶段两倍没有得到成功结果;其中 V2 在前面未改变时序的抓取阶段就掉面包,不能把这次失败归咎于减速。 + +保持容器盖子打开的旧侧舀冰对照已完整运行,没有再次数值发散,却没有带出冰块。因此,“不崩溃”和“完成任务”在这组场景中也是两回事,盖子驱动尚不是完整修复。 + + +### 舀冰旧基线也不稳定,同步开关不是修复(2026-09-18 补充) + +当前安装包中,旧 MuJoCo 显式关闭 CUDA 同步后完整跑完 3300 步,最后带出 5 块冰,但勺子在手里已滑转约 20.8°;显式开启同步的同配置运行则在第 700 步出现冰块非有限位姿。历史上开启同步曾带出 11 块,说明不能把这个开关当作解决办法,也不能把历史最好的一次当作稳定基准。两组仅各一次,尚不足以确定同步开关与失败的因果关系。 + +V2 扩大容量后完整带出 5–6 块冰的结果有效,但不能因为本次旧侧退化就宣布对齐。当前继续完成手部摩擦、刚度的独立验证,并保留完整动作和保持阶段的评价。详见第二轮记录中的同步对照及原始日志。 + + +### 张开夹爪后,接触余量仍可能妨碍释放(2026-09-18 补充) + +Assemble 中,张手后额外等一秒仍留下约 17.82 mm 偏心。等待结束时手指已基本全开,但罐子维持约 9.85° 倾斜;记录的手指接触点间隙约 0.81–0.94 mm,仍处于 VBD 的 1 mm 接触余量内,相关接触的法向约束乘子也没有归零。继续等待并没有让它脱离这些接触。 + +只改接触 alpha=0.5 的另一遍完整运行则正常落到底座,偏心 6.93 mm 并停稳,正在安排重复验证。另增加只改夹爪 margin 的完整对照,检查原 MuJoCo 中被清零、VBD 中仍保留的余量是否影响释放;尚未证明清零就能解决,未改正式默认值。这个线索来自已有接触点的几何与乘子记录,不是精确碰撞重算或完整力测量。 + + +### alpha 的改善不能跨任务直接推广(2026-09-18 补充) + +Assemble 使用 alpha=0.5 的单次结果改善到 6.93 mm 偏心,但同样调整在双臂放置中使面包第一次抬升就失败,最后仍留在桌上;锅的抓持反而更稳定。完整 3032 步正常退出也不能算任务成功。当前不将 alpha=0.5 设为通用默认,继续用完整任务验证每个候选。 + + +### 纸杯的较好参数仍未证明稳定(2026-09-18 补充) + +11.5 mm 闭合量曾在完整缓存回放中取得约 5.01 mm / 3.57° 的目标误差,但正式入口正常重新规划的一次运行中,杯子在手内的转动明显更大。两次记录到的材料、驱动和初态一致,机械臂命令几乎相同;到第 4587 步,杯子姿态已相差约 8.09°。本次仍在运行,不能当作完整失败,但之前一次好结果也不足以验收这套参数。 + +目前需要确认的是抓持对微小差异是否敏感,以及是否存在尚未记录的模型或执行差别。尚未证明是 GPU 非确定性,也未证明必须改双向耦合。详细对照见第二轮记录的纸杯 11.5 mm 小节。 + + +### 少量接触条目的法向量为零,部分诊断数值需作废(2026-09-18 补充) + +装配的一次完整运行中,三个采样点出现零法向接触。原诊断程序据此算出的“1 mm 穿透”没有物理意义,现已标为不可计算并保留原始数据。张手等待结束时的四个接触法向正常,因此先前关于释放余量的线索仍成立,但不能借这些零法向数据推断夹持力或穿透。 + +这是一项待定位的接触数据问题,尚未证明源于碰撞生成、记录时机或 solver 内部处理,也未证明是任务失败的原因。后续接触记录会显式标识有效性,避免继续误读。 + + +### 纸杯最新完整结果:停止后抓得住,搬运转偏尚未解决(2026-09-18 补充) + +11.5 mm 正式入口现已完整跑完 7460 步,最终位置误差 2.90 mm、姿态误差 11.32°;最后 4.8 秒只变化约 0.63 mm / 0.15°。主要偏差在搬运过程中形成,停止后没有继续明显滑动,也没有恢复正确朝向。 + +此前同闭合量缓存回放的姿态误差只有 3.57°,旧 MuJoCo 独立规划约 2.88°。因此当前不能认为纸杯已稳定对齐,也不能把单次缓存的好结果作为参数已经标定成功的证明。精确缓存重复已排队,仍未确定根因。 + + +### 双臂放置有明确的机器人—桌子冲突,不能全归因于 VBD(2026-09-18 补充) + +旧 MuJoCo 回放与 V2 相同的新轨迹后,右手同样偏离目标约 7–8 cm。协作阶段记录持续出现右上臂与桌子的接触,驱动和约束产生很大的反向力矩;两侧右臂实际关节最大差仅约 2.15e-6 rad。此前几何核对也发现目标姿态与桌子相交。 + +这说明应先处理安装位置或运动路径,继续加摩擦不能解决被桌子挡住的问题。提高安装位置的新旧完整对照已排队,仍需验证整段路径和最终任务效果。本次旧侧使用了和 V2 一样的标定夹爪命令,是定位原因的对照,不是原教程的成功基线;面包抓持问题也尚未解决。 + + +### 舀冰也已记录到真实零法向接触(2026-09-18 补充) + +观测器修复后的摩擦 8 重跑中,第 2360 步起保存到了勺子与手掌、手指之间的零法向接触,并带有非零约束乘子。新记录器不再据此中断任务,也不把这些乘子当成有效的法向/切向力,完整运行仍在继续。 + +这个现象需要继续定位,不能通过增加摩擦来解释或修复数据本身。但当前还不能证明它是滑转原因,更不能据此断言 MJVBDV2 不适合舀冰;已安排的碰撞生成后观测将帮助区分异常出现的环节。 + + +### 混合模式启用了两套碰撞管线,之前的对齐结论需要限定(2026-09-18 更正) + +本轮为了恢复机器人与地面的接触,把 DexSim 混合模式中的 `mujoco_options.disable_contacts` 从强制 `True` 改为默认 `False`,同时仍使用 `use_mujoco_contacts=True`。这会同时运行 MuJoCo-Warp 和 Newton 两套碰撞管线,并不是单纯保留关节求解。此前把它笼统称为“接触修复”不够准确:它改变了原生 V2 混合模式的接触分工。 + +当前修改后的分工是:MuJoCo-Warp 检测并求解其紧凑模型内的 articulation 与静态环境、允许的 articulation 之间的接触;Newton 检测 VBD 自由刚体相关接触,由 VBD 求解。自由刚体没有进入 MuJoCo 模型,机器人在 VBD 侧只是无动力学响应的运动代理,因此两套管线并不意味着同一物体被重复施加接触响应。不过,双管线的开销、接触参数差异和数据查询范围仍需分别处理。 + +原生混合模式关闭 MuJoCo 接触,又不把 VBD 反力传回机器人。这意味着 Newton 检测到机器人与地面接触,也不能仅靠这条单向路径给机器人提供支撑力。若要求混合模式只用 Newton 碰撞,同时保留动态 articulation 的接触响应,需要将合适的 Newton 接触映射给 MuJoCo 求解;当前 V2 没有接通这条路径,构造器还明确拒绝 `use_mujoco_contacts=False`。这不是只改一个开关就完成的适配。 + +因此,混合场景 locomotion 的约 1e-6 rad 级同动作对齐,是在额外开启 MuJoCo 原生接触之后得到的,不能当作原生 V2 单向混合模式已经对齐的证据。纯 articulation 路线的结果需要单独看待;两者都不能替代完整训练收敛验证。双臂放置中机器人受桌子阻挡的对照,同样依赖这项开启接触的修改。 + +本次提交保留现有实验结果和配置,但不把双管线方案视为已确认的最终架构。DexSim 的这项补丁及凸包导入坐标修复仍是本轮环境的额外依赖,未包含在 EmbodiChain 的 GitHub 提交中。仅拉取 EmbodiChain 代码,不能保证复现本轮结果。 + +### 本轮提交范围与参数适用边界(2026-09-18 补充) + +本轮提交包含按场景选择的夹爪闭合目标、部分夹爪摩擦系数 4、接触历史与 latest 匹配;Place 额外使用 alpha=0.5 和机械臂 damping=1000;HandOver 在释放前等待 1 秒;Pour/Place 修正初始高度;固定桌子使用 static;Scoop 将 VBD 单刚体接触容量提高到 256。夹爪数值是关节位置目标,不是夹口宽度。 + +这些调整有机器人和物体范围,尚不是通用参数。其中纸杯 0.0115 闭合目标仍是候选,完整运行的姿态误差达到 11.32°,不能称为稳定标定成功。提高摩擦、刚度、安装高度及额外沉降等待等临时对照没有全部写进正式示例。未新增仓库测试或 benchmark 文件,已有测试随配置修改;原始实验日志和临时诊断脚本未纳入本次提交。 diff --git a/scripts/tutorials/atomic_action/axis_align.py b/scripts/tutorials/atomic_action/axis_align.py index 912f73934d..c805e4d2fe 100644 --- a/scripts/tutorials/atomic_action/axis_align.py +++ b/scripts/tutorials/atomic_action/axis_align.py @@ -42,6 +42,8 @@ from embodichain.lab.sim.shapes import CubeCfg from embodichain.utils import logger from scripts.tutorials.atomic_action.tutorial_utils import ( + DEFAULT_GRIPPER_CLOSE_QPOS, + MJVBD_V2_CUBE_CLOSE_QPOS, add_ur5_gripper_robot, clone_local_pose_from_first_env, create_antipodal_semantics, @@ -149,7 +151,14 @@ def main() -> None: sim = create_tutorial_simulation(args) robot = add_ur5_gripper_robot(sim, tcp_z=0.15) obj = create_align_object(sim) - hand_open, hand_close = get_hand_open_close_qpos(robot) + hand_open, hand_close = get_hand_open_close_qpos( + robot, + close_qpos=( + MJVBD_V2_CUBE_CLOSE_QPOS + if args.robot == "ur5" and sim.physics.solver_type == "mjvbd_v2" + else DEFAULT_GRIPPER_CLOSE_QPOS + ), + ) initialize_pre_pick_robot_pose(robot, obj, hand_open) motion_gen = create_toppra_motion_generator( robot, diff --git a/scripts/tutorials/atomic_action/coordinated_pickment.py b/scripts/tutorials/atomic_action/coordinated_pickment.py index 33c62d5e03..9169edc36b 100644 --- a/scripts/tutorials/atomic_action/coordinated_pickment.py +++ b/scripts/tutorials/atomic_action/coordinated_pickment.py @@ -161,6 +161,8 @@ class PickmentObjectPreset: PICKMENT_HAND_INTERP_STEPS = 10 PICKMENT_HOLD_STEPS = 4 ROBOTIQ_2F_140_CLOSE_QPOS = 0.7 +# Calibrated for the plastic tray and UR5/DH PGI one-way contact. +MJVBD_V2_TRAY_CLOSE_QPOS = 0.023 TRAJECTORY_SIM_STEPS = 4 @@ -189,6 +191,8 @@ def parse_arguments() -> argparse.Namespace: def create_dual_robot( sim: SimulationManager, robot_type: TutorialRobot, + *, + newton_gripper_friction: float | None = None, ) -> Robot: """Create the selected dual-arm robot with its matching grippers.""" return add_dual_tutorial_robot( @@ -198,6 +202,7 @@ def create_dual_robot( urdf_name=f"dual_{robot_type}_coordinated_pickment", tcp_z=GRIPPER_TCP_Z, solver="pytorch", + newton_gripper_friction=newton_gripper_friction, ) @@ -395,6 +400,12 @@ def run_coordinated_pickment_demo( hand_close_qpos = ( ROBOTIQ_2F_140_CLOSE_QPOS if args.robot == "ur10" else preset.hand_close_qpos ) + if ( + args.robot == "ur5" + and args.object == "plastic_tray" + and sim.physics.solver_type == "mjvbd_v2" + ): + hand_close_qpos = MJVBD_V2_TRAY_CLOSE_QPOS left_open, left_close = get_hand_open_close_qpos( robot, hand_control_part="left_hand", @@ -527,8 +538,27 @@ def main() -> None: sim = create_tutorial_simulation( args, arena_space=3.0, + newton_solver_options=( + { + "vbd_options": {"rigid_contact_history": True}, + "collision_options": {"contact_matching": "latest"}, + } + if args.physics == "newton" + and args.robot == "ur5" + and args.object == "plastic_tray" + else None + ), + ) + use_vbd_grasp = ( + args.robot == "ur5" + and args.object == "plastic_tray" + and sim.physics.solver_type == "mjvbd_v2" + ) + robot = create_dual_robot( + sim, + args.robot, + newton_gripper_friction=4.0 if use_vbd_grasp else None, ) - robot = create_dual_robot(sim, args.robot) run_coordinated_pickment_demo(args, sim, robot) diff --git a/scripts/tutorials/atomic_action/coordinated_placement.py b/scripts/tutorials/atomic_action/coordinated_placement.py index 6bd7c08e3f..362ef304a3 100644 --- a/scripts/tutorials/atomic_action/coordinated_placement.py +++ b/scripts/tutorials/atomic_action/coordinated_placement.py @@ -235,7 +235,8 @@ def create_table(sim: SimulationManager) -> RigidObject: static_friction=0.95, restitution=0.01, ), - body_type="kinematic", + # This fixture never moves; static shapes also enter V2's MuJoCo view. + body_type="static", init_pos=list(TABLE_INIT_POS), init_rot=list(TABLE_INIT_ROT), ) diff --git a/scripts/tutorials/atomic_action/hand_over.py b/scripts/tutorials/atomic_action/hand_over.py index 8b06150de8..8a401fb1a6 100644 --- a/scripts/tutorials/atomic_action/hand_over.py +++ b/scripts/tutorials/atomic_action/hand_over.py @@ -19,6 +19,7 @@ from __future__ import annotations import argparse +import math import sys from pathlib import Path @@ -88,6 +89,9 @@ # --------------------------------------------------------------------------- HAND_CLOSE_QPOS = 0.04 +MJVBD_V2_CAN_LEFT_CLOSE_QPOS = 0.007 +MJVBD_V2_CAN_RIGHT_CLOSE_QPOS = 0.0055 +MJVBD_V2_RELEASE_SETTLE_DURATION = 1.0 HANDOVER_SAMPLE_INTERVAL = 220 HANDOVER_HAND_INTERP_STEPS = 10 HANDOVER_PRE_GRASP_DISTANCE = 0.08 @@ -119,6 +123,8 @@ def parse_arguments() -> argparse.Namespace: def create_dual_robot( sim: SimulationManager, robot_type: TutorialRobot, + *, + newton_gripper_friction: float | None = None, ) -> Robot: """Create the selected dual-arm robot with its matching grippers.""" return add_dual_tutorial_robot( @@ -131,6 +137,7 @@ def create_dual_robot( hand_stiffness=1e3, hand_damping=1e2, hand_max_effort=1e4, + newton_gripper_friction=newton_gripper_friction, ) @@ -204,11 +211,20 @@ def run_handover_demo( planner=getattr(args, "planner", "trapezoidal"), ) + use_vbd_grasp = ( + args.robot == "ur5" + and not args.is_horizontal + and sim.physics.solver_type == "mjvbd_v2" + ) left_open, left_close = get_hand_open_close_qpos( - robot, hand_control_part="left_hand", close_qpos=HAND_CLOSE_QPOS + robot, + hand_control_part="left_hand", + close_qpos=MJVBD_V2_CAN_LEFT_CLOSE_QPOS if use_vbd_grasp else HAND_CLOSE_QPOS, ) right_open, right_close = get_hand_open_close_qpos( - robot, hand_control_part="right_hand", close_qpos=HAND_CLOSE_QPOS + robot, + hand_control_part="right_hand", + close_qpos=MJVBD_V2_CAN_RIGHT_CLOSE_QPOS if use_vbd_grasp else HAND_CLOSE_QPOS, ) final_pose = torch.eye(4, dtype=torch.float32) @@ -285,6 +301,17 @@ def run_handover_demo( if wait_for_user: input("Press Enter to execute the handover...") + release_start = compiled.segment(0, "receive_release").start + + def settle_before_release(step_index: int, _total_steps: int) -> None: + if step_index == release_start - 1: + # Let the receiving arm stop before opening the gripper. + sim.update( + step=math.ceil( + MJVBD_V2_RELEASE_SETTLE_DURATION / sim.sim_config.physics_dt + ) + ) + replay_trajectory( sim, robot, @@ -293,6 +320,7 @@ def run_handover_demo( video_prefix="handover_auto_play", hold_steps=0, trajectory_sim_steps=TRAJECTORY_SIM_STEPS, + on_trajectory_step=settle_before_release if use_vbd_grasp else None, look_at=HANDOVER_RECORD_LOOK_AT, ) if wait_for_user: @@ -305,8 +333,27 @@ def main() -> None: sim = create_tutorial_simulation( args, arena_space=3.0, + newton_solver_options=( + { + "vbd_options": {"rigid_contact_history": True}, + "collision_options": {"contact_matching": "latest"}, + } + if args.physics == "newton" + and args.robot == "ur5" + and not args.is_horizontal + else None + ), + ) + use_vbd_grasp = ( + args.robot == "ur5" + and not args.is_horizontal + and sim.physics.solver_type == "mjvbd_v2" + ) + robot = create_dual_robot( + sim, + args.robot, + newton_gripper_friction=4.0 if use_vbd_grasp else None, ) - robot = create_dual_robot(sim, args.robot) run_handover_demo(args, sim, robot) serve_tutorial_scene(sim, args) diff --git a/scripts/tutorials/atomic_action/move_held_object.py b/scripts/tutorials/atomic_action/move_held_object.py index e53ca5a1ad..9c164e630a 100644 --- a/scripts/tutorials/atomic_action/move_held_object.py +++ b/scripts/tutorials/atomic_action/move_held_object.py @@ -44,6 +44,7 @@ from embodichain.lab.sim.shapes import MeshCfg, MeshCollisionCfg from embodichain.utils import logger from scripts.tutorials.atomic_action.tutorial_utils import ( + DEFAULT_GRIPPER_CLOSE_QPOS, add_tutorial_robot, broadcast_pose_batch, clone_local_pose_from_first_env, @@ -70,6 +71,8 @@ MOVE_HELD_OBJECT_SAMPLE_INTERVAL = 120 HAND_INTERP_STEPS = 12 POST_TRAJECTORY_STEPS = 240 +# Candidate for this cup and UR5/DH PGI; transport orientation remains unaligned. +MJVBD_V2_CUP_CLOSE_QPOS = 0.0115 def parse_arguments() -> argparse.Namespace: @@ -129,15 +132,35 @@ def make_object_target_pose(device: torch.device) -> torch.Tensor: def main() -> None: """Plan MoveEndEffector -> PickUp -> MoveHeldObject.""" args = parse_arguments() - sim = create_tutorial_simulation(args) - robot = add_tutorial_robot(sim, args.robot) + sim = create_tutorial_simulation( + args, + newton_solver_options=( + { + "vbd_options": {"rigid_contact_history": True}, + "collision_options": {"contact_matching": "latest"}, + } + if args.physics == "newton" and args.robot == "ur5" + else None + ), + ) + use_vbd_grasp = args.robot == "ur5" and sim.physics.solver_type == "mjvbd_v2" + robot = add_tutorial_robot( + sim, + args.robot, + newton_gripper_friction=4.0 if use_vbd_grasp else None, + ) obj = create_pick_object(sim) sim.prepare() motion_gen = create_curobo_motion_generator( robot, planner=getattr(args, "planner", "trapezoidal"), ) - hand_open, hand_close = get_hand_open_close_qpos(robot) + hand_open, hand_close = get_hand_open_close_qpos( + robot, + close_qpos=( + MJVBD_V2_CUP_CLOSE_QPOS if use_vbd_grasp else DEFAULT_GRIPPER_CLOSE_QPOS + ), + ) engine = create_simulation_atomic_action_engine( motion_generator=motion_gen, diff --git a/scripts/tutorials/atomic_action/pickup.py b/scripts/tutorials/atomic_action/pickup.py index e35bc902a5..1313bd3cbe 100644 --- a/scripts/tutorials/atomic_action/pickup.py +++ b/scripts/tutorials/atomic_action/pickup.py @@ -40,6 +40,8 @@ from embodichain.lab.sim.shapes import CubeCfg from embodichain.utils import logger from scripts.tutorials.atomic_action.tutorial_utils import ( + DEFAULT_GRIPPER_CLOSE_QPOS, + MJVBD_V2_CUBE_CLOSE_QPOS, add_tutorial_robot, clone_local_pose_from_first_env, create_antipodal_semantics, @@ -130,7 +132,14 @@ def main() -> None: robot = add_tutorial_robot(sim, args.robot, tcp_z=0.15) obj = create_pick_object(sim) sim.prepare() - hand_open, hand_close = get_hand_open_close_qpos(robot) + hand_open, hand_close = get_hand_open_close_qpos( + robot, + close_qpos=( + MJVBD_V2_CUBE_CLOSE_QPOS + if args.robot == "ur5" and sim.physics.solver_type == "mjvbd_v2" + else DEFAULT_GRIPPER_CLOSE_QPOS + ), + ) initialize_pre_pick_robot_pose(robot, obj, hand_open) motion_gen = create_curobo_motion_generator( robot, diff --git a/scripts/tutorials/atomic_action/place.py b/scripts/tutorials/atomic_action/place.py index f943bd2e13..973d999657 100644 --- a/scripts/tutorials/atomic_action/place.py +++ b/scripts/tutorials/atomic_action/place.py @@ -42,6 +42,8 @@ from embodichain.lab.sim.shapes import CubeCfg from embodichain.utils import logger from scripts.tutorials.atomic_action.tutorial_utils import ( + DEFAULT_GRIPPER_CLOSE_QPOS, + MJVBD_V2_CUBE_CLOSE_QPOS, add_tutorial_robot, broadcast_pose_batch, broadcast_waypoint_pose_batch, @@ -81,6 +83,8 @@ def parse_arguments() -> argparse.Namespace: def create_pick_object(sim) -> RigidObject: """Create a settled cube for the PickUp and Place sequence.""" + # Start outside the default ground's 1 mm VBD contact margin. + ground_clearance = 0.001 if sim.physics.solver_type == "mjvbd_v2" else 0.0 obj = sim.add_rigid_object( cfg=RigidObjectCfg( uid="cube", @@ -93,7 +97,7 @@ def create_pick_object(sim) -> RigidObject: angular_damping=0.2, newton_contact=sim.is_newton_backend, ), - init_pos=[*OBJECT_XY, 0.5 * OBJECT_SIZE[2]], + init_pos=[*OBJECT_XY, 0.5 * OBJECT_SIZE[2] + ground_clearance], ) ) sim.prepare() @@ -125,15 +129,41 @@ def make_place_eef_poses(device: torch.device) -> torch.Tensor: def main() -> None: """Plan and replay PickUp followed by a multi-waypoint Place.""" args = parse_arguments() - sim = create_tutorial_simulation(args) - robot = add_tutorial_robot(sim, args.robot, tcp_z=0.15) + sim = create_tutorial_simulation( + args, + newton_solver_options=( + { + "vbd_options": { + "rigid_contact_history": True, + "rigid_avbd_contact_alpha": 0.5, + }, + "collision_options": {"contact_matching": "latest"}, + } + if args.physics == "newton" and args.robot == "ur5" + else None + ), + ) + use_vbd_grasp = sim.physics.solver_type == "mjvbd_v2" and args.robot == "ur5" + robot = add_tutorial_robot( + sim, + args.robot, + tcp_z=0.15, + newton_gripper_friction=4.0 if use_vbd_grasp else None, + # Reach the release waypoint before the fingers finish opening. + arm_damping=1000.0 if use_vbd_grasp else None, + ) obj = create_pick_object(sim) sim.prepare() motion_gen = create_curobo_motion_generator( robot, planner=getattr(args, "planner", "trapezoidal"), ) - hand_open, hand_close = get_hand_open_close_qpos(robot) + hand_open, hand_close = get_hand_open_close_qpos( + robot, + close_qpos=( + MJVBD_V2_CUBE_CLOSE_QPOS if use_vbd_grasp else DEFAULT_GRIPPER_CLOSE_QPOS + ), + ) initialize_pre_pick_robot_pose(robot, obj, hand_open) engine = create_simulation_atomic_action_engine( diff --git a/scripts/tutorials/atomic_action/pour.py b/scripts/tutorials/atomic_action/pour.py index 56a39b75cd..e70fbe0123 100644 --- a/scripts/tutorials/atomic_action/pour.py +++ b/scripts/tutorials/atomic_action/pour.py @@ -44,11 +44,14 @@ ) from embodichain.utils import logger from scripts.tutorials.atomic_action.axis_align import ( + OBJECT_SIZE, create_align_object, create_axis_align_semantics, ) from scripts.tutorials.atomic_action.tutorial_utils import ( - add_ur5_gripper_robot, + DEFAULT_GRIPPER_CLOSE_QPOS, + MJVBD_V2_CUBE_CLOSE_QPOS, + add_tutorial_robot, create_parallel_jaw_grasp_pose_generator, create_toppra_motion_generator, create_tutorial_argument_parser, @@ -70,7 +73,8 @@ HAND_INTERP_STEPS = 12 POST_TRAJECTORY_STEPS = 240 PICK_MOTION_SAMPLE_COUNT = PICK_SAMPLE_INTERVAL - HAND_INTERP_STEPS -OBJ_POSITION = (-0.5, 0.0, 0.0) +# Start above the ground so penetration recovery does not move the grasp target. +OBJ_POSITION = (-0.5, 0.0, 0.5 * OBJECT_SIZE[2]) RECORD_LOOK_AT = ( (-1.5, 0.2, 1.2), (-0.4, 0.0, 0.4), @@ -118,13 +122,38 @@ def _create_pick_motion_policy( def main() -> None: """Plan and replay PickUp followed by Pour.""" args = parse_arguments() - sim = create_tutorial_simulation(args) - robot = add_ur5_gripper_robot(sim, tcp_z=0.15) + sim = create_tutorial_simulation( + args, + newton_solver_options=( + { + "vbd_options": {"rigid_contact_history": True}, + "collision_options": {"contact_matching": "latest"}, + } + if args.physics == "newton" + else None + ), + ) + use_vbd_grasp = sim.physics.solver_type == "mjvbd_v2" + robot = add_tutorial_robot( + sim, + "ur5", + tcp_z=0.15, + newton_gripper_friction=4.0 if use_vbd_grasp else None, + ) + obj_position = list(OBJ_POSITION) + if use_vbd_grasp: + # Start outside the default ground's 1 mm VBD contact margin. + obj_position[2] += 0.001 obj = create_align_object( sim, - obj_position=OBJ_POSITION, + obj_position=obj_position, + ) + hand_open, hand_close = get_hand_open_close_qpos( + robot, + close_qpos=( + MJVBD_V2_CUBE_CLOSE_QPOS if use_vbd_grasp else DEFAULT_GRIPPER_CLOSE_QPOS + ), ) - hand_open, hand_close = get_hand_open_close_qpos(robot) initialize_pre_pick_robot_pose(robot, obj, hand_open) planner = getattr(args, "planner", "trapezoidal") motion_gen = create_toppra_motion_generator(robot, planner=planner) diff --git a/scripts/tutorials/atomic_action/scenario_utils.py b/scripts/tutorials/atomic_action/scenario_utils.py index d52e6bd996..10cf327425 100644 --- a/scripts/tutorials/atomic_action/scenario_utils.py +++ b/scripts/tutorials/atomic_action/scenario_utils.py @@ -234,6 +234,7 @@ def add_dual_tutorial_robot( hand_stiffness: float = 1e3, hand_damping: float = 1e2, hand_max_effort: float = 1e4, + newton_gripper_friction: float | None = None, ) -> Robot: """Add a supported dual-arm tutorial robot to a simulation. @@ -254,6 +255,7 @@ def add_dual_tutorial_robot( hand_stiffness: Hand joint drive stiffness. hand_damping: Hand joint drive damping. hand_max_effort: Hand joint maximum effort. + newton_gripper_friction: Optional Newton gripper sliding friction. Returns: The added dual-arm robot instance. @@ -274,7 +276,7 @@ def add_dual_tutorial_robot( hand_damping=hand_damping, hand_max_effort=hand_max_effort, ) - configure_newton_gripper_contacts(sim, robot_cfg) + configure_newton_gripper_contacts(sim, robot_cfg, friction=newton_gripper_friction) return sim.add_robot(cfg=robot_cfg) diff --git a/scripts/tutorials/atomic_action/tutorial_utils.py b/scripts/tutorials/atomic_action/tutorial_utils.py index 76e07f553b..28fa6910c1 100644 --- a/scripts/tutorials/atomic_action/tutorial_utils.py +++ b/scripts/tutorials/atomic_action/tutorial_utils.py @@ -111,6 +111,9 @@ palm_depth=0.096, ) DEFAULT_GRIPPER_CLOSE_QPOS = 0.036 +# Calibrated for the UR5's DH-PGI gripper holding the tutorial's 5 cm cube. +# V2's one-way contacts cannot stop the fingers at an oversized close target. +MJVBD_V2_CUBE_CLOSE_QPOS = 0.013 NEWTON_GRASP_CONTACT_STIFFNESS = 4.0e4 NEWTON_GRASP_CONTACT_DAMPING = 4.0e2 # MuJoCo-Warp's default contact dimension (3) has no torsional friction. A @@ -301,6 +304,7 @@ def create_tutorial_simulation( *, arena_space: float = 2.5, sun_direction: Sequence[float] = DEFAULT_TUTORIAL_SUN_DIRECTION, + newton_solver_options: Mapping[str, object] | None = None, ) -> SimulationManager: """Create the shared simulation setup used by atomic-action tutorials. @@ -310,10 +314,17 @@ def create_tutorial_simulation( arena_space: Spacing between parallel simulation arenas in meters. sun_direction: Direction of the single global sun light. The vector points from the light toward the scene. + newton_solver_options: Scene-specific overrides for the Newton solver + configuration, such as VBD contact history and collision matching. Returns: A simulation manager with the tutorial key light configured. """ + physics_cfg = _tutorial_physics_cfg(getattr(args, "physics", "default")) + if newton_solver_options is not None: + if not isinstance(physics_cfg, NewtonPhysicsCfg): + raise ValueError("Newton solver options require the Newton backend.") + physics_cfg.solver_cfg = {**physics_cfg.solver_cfg, **newton_solver_options} sim = SimulationManager( SimulationManagerCfg( width=VIEWER_WIDTH, @@ -321,7 +332,7 @@ def create_tutorial_simulation( headless=True, num_envs=args.num_envs, device=args.device, - physics_cfg=_tutorial_physics_cfg(getattr(args, "physics", "default")), + physics_cfg=physics_cfg, render_cfg=RenderCfg(renderer=args.renderer), physics_dt=1.0 / 100.0, arena_space=arena_space, @@ -406,6 +417,9 @@ def add_tutorial_robot( robot_type: TutorialRobot, init_pos: Sequence[float] = (0.0, 0.0, 0.0), init_qpos: Sequence[float] | None = None, + *, + newton_gripper_friction: float | None = None, + arm_damping: float | None = None, **kwargs, ) -> Robot: """Add a selected tutorial robot with the shared PGI gripper. @@ -415,6 +429,9 @@ def add_tutorial_robot( robot_type: Tutorial robot family to construct. init_pos: Root position of the robot in its arena. init_qpos: Optional full robot joint configuration. + newton_gripper_friction: Optional sliding-friction coefficient for the + Newton gripper collision links; object materials are unaffected. + arm_damping: Optional drive damping for the arm control part. Returns: The added robot instance. @@ -428,7 +445,9 @@ def add_tutorial_robot( init_qpos=init_qpos, **kwargs, ) - configure_newton_gripper_contacts(sim, robot_cfg) + if arm_damping is not None: + robot_cfg.joint_drive_props.damping["arm"] = arm_damping + configure_newton_gripper_contacts(sim, robot_cfg, friction=newton_gripper_friction) return sim.add_robot(cfg=robot_cfg) @@ -617,9 +636,19 @@ def configure_newton_link_contacts( def configure_newton_gripper_contacts( sim: SimulationManager, robot_cfg: RobotCfg, + *, + friction: float | None = None, ) -> None: - """Configure Newton gripper contacts and recompute their source inertia.""" + """Configure Newton gripper contacts and recompute their source inertia. + + Args: + sim: Simulation manager that owns the robot. + robot_cfg: Robot configuration to update before spawning. + friction: Optional static and dynamic sliding-friction coefficient. + """ if not sim.is_newton_backend: + if friction is not None: + raise ValueError("Newton gripper friction requires the Newton backend.") return configure_newton_link_contacts( @@ -628,9 +657,11 @@ def configure_newton_gripper_contacts( group_name="newton_gripper_contacts", link_names_expr=[_GRIPPER_CONTACT_LINK_PATTERN], ) - robot_cfg.link_attrs["newton_gripper_contacts"].attrs.mass_props = ( - MassPropertiesCfg(recompute_inertia=True) - ) + attrs = robot_cfg.link_attrs["newton_gripper_contacts"].attrs + attrs.mass_props = MassPropertiesCfg(recompute_inertia=True) + if friction is not None: + attrs.material_props.static_friction = friction + attrs.material_props.dynamic_friction = friction def create_trapezoidal_motion_generator( @@ -1544,6 +1575,7 @@ def create_tutorial_robot_cfg( "DEFAULT_AXIS_LEN", "DEFAULT_AXIS_SIZE", "DEFAULT_GRIPPER_CLOSE_QPOS", + "MJVBD_V2_CUBE_CLOSE_QPOS", "DEFAULT_TUTORIAL_SUN_DIRECTION", "DEFAULT_TUTORIAL_SUN_INTENSITY", "GRIPPER_HAND_JOINT_PATTERN", diff --git a/tests/sim/atomic_actions/test_tutorial_utils.py b/tests/sim/atomic_actions/test_tutorial_utils.py index c967391725..1649196956 100644 --- a/tests/sim/atomic_actions/test_tutorial_utils.py +++ b/tests/sim/atomic_actions/test_tutorial_utils.py @@ -268,7 +268,7 @@ def _run_obstacle_animation(*, pace_wall_time: bool) -> tuple[MagicMock, MagicMo return obstacle, adapter -def test_atomic_action_tutorial_uses_native_mujoco_contact_settings() -> None: +def test_atomic_action_tutorial_uses_native_mjvbd_v2_settings() -> None: module = importlib.import_module("scripts.tutorials.atomic_action.tutorial_utils") default_cfg = module._tutorial_physics_cfg("default") @@ -279,29 +279,24 @@ def test_atomic_action_tutorial_uses_native_mujoco_contact_settings() -> None: assert newton_cfg.num_substeps == 20 assert newton_cfg.collision_cfg is None assert newton_cfg.solver_cfg == { - "solver_type": "mujoco_warp", - "solver": "newton", - "integrator": "implicitfast", - "iterations": 20, - "ls_iterations": 100, - "cone": "elliptic", - "impratio": 1_000.0, - "use_mujoco_contacts": True, - "enable_multiccd": True, + "solver_type": "mjvbd_v2", + "mujoco_options": { + "solver": "newton", + "integrator": "implicitfast", + "iterations": 20, + "ls_iterations": 100, + "cone": "elliptic", + "impratio": 1_000.0, + "enable_multiccd": True, + }, } dexsim_cfg = newton_cfg.to_dexsim_cfg(gpu_id=0) - assert dexsim_cfg.solver_cfg.solver_type == "mujoco_warp" - assert dexsim_cfg.solver_cfg.solver == "newton" - assert dexsim_cfg.solver_cfg.integrator == "implicitfast" - assert dexsim_cfg.solver_cfg.iterations == 20 - assert dexsim_cfg.solver_cfg.ls_iterations == 100 - assert dexsim_cfg.solver_cfg.nconmax is None - assert dexsim_cfg.solver_cfg.njmax is None - assert dexsim_cfg.solver_cfg.cone == "elliptic" - assert dexsim_cfg.solver_cfg.impratio == pytest.approx(1_000.0) - assert dexsim_cfg.solver_cfg.use_mujoco_contacts is True - assert dexsim_cfg.solver_cfg.enable_multiccd is True + assert dexsim_cfg.solver_cfg.solver_type == "mjvbd_v2" + assert ( + dexsim_cfg.solver_cfg.mujoco_options == newton_cfg.solver_cfg["mujoco_options"] + ) + assert dexsim_cfg.solver_cfg.vbd_options == {} assert dexsim_cfg.collision_pipeline_cfg is None @@ -1023,6 +1018,7 @@ def test_place_tutorial_registers_pick_object_with_simulation_engine_factory() - n_sample=1, no_vis_eef_axis=True, robot="ur5", + physics="default", ) sim = MagicMock() sim.device = torch.device("cpu") @@ -1316,9 +1312,13 @@ def test_pour_tutorial_uses_configured_pickup_and_local_rotation_axis() -> None: assert module.POUR_INTERNAL_AXIS == (1.0, 0.0, 0.0) pick_policy = module._create_pick_motion_policy() assert pick_policy.sample_count == module.PICK_SAMPLE_INTERVAL - assert isinstance(pick_policy.plan_opts, module.TrapezoidalPlanOptions) - assert pick_policy.plan_opts.sample_method is module.TrajectorySampleMethod.QUANTITY - assert pick_policy.plan_opts.sample_interval == module.PICK_MOTION_SAMPLE_COUNT + assert pick_policy.plan_opts is None + toppra_policy = module._create_pick_motion_policy("toppra") + assert isinstance(toppra_policy.plan_opts, module.ToppraPlanOptions) + assert ( + toppra_policy.plan_opts.sample_method is module.TrajectorySampleMethod.QUANTITY + ) + assert toppra_policy.plan_opts.sample_interval == module.PICK_MOTION_SAMPLE_COUNT def test_replay_timed_trajectory_uses_arrival_intervals() -> None: From 51af3224ac4c56dd586c32f965e66eed1e34e297 Mon Sep 17 00:00:00 2001 From: xiemenghong Date: Sun, 20 Sep 2026 17:00:33 +0800 Subject: [PATCH 3/4] fix(tutorial): align drawer damping across physics backends --- scripts/tutorials/atomic_action/slide.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/tutorials/atomic_action/slide.py b/scripts/tutorials/atomic_action/slide.py index 2970504f70..ddba7af78b 100644 --- a/scripts/tutorials/atomic_action/slide.py +++ b/scripts/tutorials/atomic_action/slide.py @@ -95,10 +95,16 @@ def create_drawer( init_pos=DRAWER_POSITION, init_rot=DRAWER_ORIENTATION, init_qpos=(0.0,), - joint_drive_props=JointDrivePropertiesCfg(drive_type="none"), + joint_drive_props=JointDrivePropertiesCfg( + drive_type="force", + target_mode="velocity", + stiffness=0.0, + damping=5.0, + ), attrs=create_tutorial_rigid_body_physics( static_friction=1.0, dynamic_friction=1.0, + linear_damping=0.0, ), ) configure_newton_link_contacts( From bc5369b089a332328867c87e6cf63340b815bb4b Mon Sep 17 00:00:00 2001 From: xiemenghong Date: Sun, 20 Sep 2026 17:50:02 +0800 Subject: [PATCH 4/4] docs(sim): clarify MJVBD V2 coupling and control limitations --- outputs/validation/mjvbd_v2/MJVBDV2_issues.md | 376 ++++-------------- 1 file changed, 70 insertions(+), 306 deletions(-) diff --git a/outputs/validation/mjvbd_v2/MJVBDV2_issues.md b/outputs/validation/mjvbd_v2/MJVBDV2_issues.md index 8f3e575569..56245a63af 100644 --- a/outputs/validation/mjvbd_v2/MJVBDV2_issues.md +++ b/outputs/validation/mjvbd_v2/MJVBDV2_issues.md @@ -1,350 +1,114 @@ # MJVBDV2 接入问题记录 -更新日期:2026-09-18 +更新日期:2026-09-20 -这份记录整理 MJVBDV2 接入 EmbodiChain 后遇到的问题:实际看到了什么、会影响什么、哪些已经修复、哪些还需要继续查。 +本文记录影响 MJVBDV2 替换现有 solver 的机制问题、证据和验证边界。布料、软体不在本次范围内。“对齐”指更换 solver 后行为接近,不等于程序正常退出,也不等于某个任务偶然成功。旧 solver 指 Newton 后端的 `mujoco_warp`;Default 后端的对照会单独注明。 -这里的“与旧 solver 对齐”,指的是换 solver 后表现接近,不代表任务一定成功。例如,两边的抽屉都没有关上,仍可能是表现接近;两边程序都正常退出,也不代表物体的运动一致。文中的旧 solver 指 Newton 后端的 `mujoco_warp`。 +**当前接入已打通主要接口和状态生命周期,但尚不能作为保持原有抓取控制方式不变的通用替代。最关键的限制是:VBD 物体的接触反力不回传给 articulation。** 针对物体标定夹爪目标可以改善部分任务,不能补齐这一机制。 -本次保留 MJVBDV2 的物体所有权分工:带关节的机器人、门和抽屉由 MuJoCo 求解,自由运动的杯子、方块等刚体由 VBD 求解。布料、软体不在这次接入范围内。**但本轮 DexSim 补丁额外开启了混合模式的 MuJoCo 原生接触,实际运行两套碰撞管线,已经偏离原生混合模式的接触配置。详见文末更正。** +## 1. 单向耦合改变了位置夹紧的工作方式 -本文链接的详细报告和原始数据是本地验证产物,未随这份问题记录提交到 GitHub。 +MJVBDV2 混合模式中,MuJoCo 推进机器人关节,VBD 推进自由刚体。机器人在 VBD 中是按给定姿态运动的碰撞代理,VBD 对物体计算的反力不会传回机器人。 -**目前仍未完成全部动态刚体任务对齐。** 调参已恢复了一部分技能,但单次成功、停止后不掉落,都不能代表稳定替换。当前状态如下,后文保留问题的发现过程;详细试验以[第二轮调参记录](coupling_tuning/round2.md)为准。 +在具有双向接触响应的系统中,夹爪位置驱动允许把目标设得比物体允许的开口更闭合。手指被物体挡住,位置误差继续产生驱动力,驱动力与接触反力形成平衡。因此,“没有到达夹爪目标”可以是正常夹紧状态,并非控制失败。 -| 场景 | 当前结论 | -| --- | --- | -| PickUp、Pour、Place、双臂抬托盘 | 已有完整改善结果和正式入口验证;仍缺跨初态稳定性证据。 | -| 纸杯 MoveHeldObject | 最新 11.5 mm 正式入口完整完成,位置误差 2.90 mm、姿态误差 11.32°;停止后基本稳定,但搬运转偏未解决。此前缓存的 3.57° 好结果未稳定复现。 | -| HandOver | 释放前等待一秒后,三次候选及正式入口均直立停稳;不代表新旧最终位姿完全一致,跨初态尚待验证。 | -| Assemble | alpha=0.5 的完整候选偏心 6.93 mm;重复及重新规划待结果。单纯延长释放等待无效,局部接触余量对照继续进行。 | -| 双臂放置 | 未恢复预期效果。已确认新旧 solver 在同轨迹下均被桌子挡住,右手偏差约 7–8 cm;安装位置对照待结果,抓持也仍需改善。 | -| 咖啡杯示例 | 新旧正常规划都没有稳定完成。已排队验证规划前自然落稳的影响,尚未证明等待有效。 | -| 舀冰 | 接触容量已修复;完整候选带出 5–6 块冰,但勺子姿态仍偏约 15–17°。摩擦、刚度对照继续运行;冰堆沉降差异也会影响结果,不能只比较一次带出数量。 | -| Locomotion | 已有约 1e-6 rad 量级的同动作状态对齐证据;混合模式结果依赖额外开启 MuJoCo 原生接触,不能证明原生单管线混合模式对齐,也不能替代完整训练验证。 | -| Twist | 按要求暂时跳过。 | - - -## 目前还有哪些问题 - -### 新发现:舀冰时 VBD 的接触列表装不下 - -**状态:容量 256 已完整运行,无溢出警告;舀冰例程已采用该容量,抓持稳定性继续调参。** - -抓持改善后的两次完整舀冰出现数千次接触溢出。一个动态刚体最多需要 170 / 183 个接触位置,但 VBD 默认只给每个刚体保留 64 个;超过容量的部分没有进入该刚体的接触求解。这与 MuJoCo 的接触、约束容量是两套设置,之前扩大 MuJoCo 容量不能解决它。 - -这是此前验证遗漏的一项,现予以更正:带出 1 / 3 块冰和滑转较大的结果真实存在,但接触已经被截断,不能据此判断单向耦合的能力上限。只把 VBD 容量提高到 256 后,已完整运行 3300 步,采样峰值 188、无溢出警告;最后带出 6 块冰,其中 5 块在保持前后采样中都位于勺碗范围。但勺子累计手内变化仍约 16.84 mm / 16.78°,说明排除截断后仍需改善抓持。随后原闭合目标也完整完成 3300 步,无溢出、采样峰值 192,末尾带出同一批 5 块冰;位置误差 22.62 mm、姿态误差 14.86°。原目标末尾保持更好,标定目标前段滑转更小,两者尚无全面胜出的配置。手部摩擦和接触刚度的首次独立对照都被临时记录器的法向量断言中断,尚无完整效果结论;记录器已改为保存异常原始值并明确标记不可计算的指标,两组按原物理参数重跑。对应 HandOver、双臂放置、咖啡杯和 Place 日志未发现同类警告,不能用这个问题解释所有未对齐任务。 - - -### 1. 混合场景的接触支持仍不完整,地面支撑已修复 - -**状态:本地小补丁已构建并安装到 embodichain 环境,恢复 MuJoCo 自有接触;接触力查询和动态物体反力仍有边界。补丁尚未提交或推送。** - -此前只有机器人和静态地面时,V2 使用纯 MuJoCo 分支,机器人可以正常行走。加入 VBD 动态刚体后切换到混合分支,却关闭了 MuJoCo 自身接触,连远处方块也会间接导致机器人失去地面支撑。这是已经确认的接入问题,不必通过重写双向耦合解决。 - -修正后,混合分支默认保留机器人与 MuJoCo 可见静态环境的接触,自由刚体仍归 VBD,反力仍不回传。直接加载补丁源码的四环境 GPU 对照完整运行 1500 步及五次重置,无容量溢出,关节最大差约 1.13e-6 rad,终止标志一致。随后正式 wheel 已安装,正常安装包入口的 CPU 混合落地及纯分支检查均通过。GPU 安装包任务回归仍在进行。 - -这项修正恢复地面支撑,但不代表混合场景的接触力查询已经与旧 MuJoCo 一致。若任务依赖动态物体把反力传给机器人,仍受单向耦合限制。 - -补充确认:静止的桌子如果被配置成独立的 `kinematic` 物体,也不会自动进入混合分支的 MuJoCo 碰撞模型。咖啡杯示例中,旧 MuJoCo 有桌子的 8 个碰撞几何,V2 的 MuJoCo 模型里没有它们。杯子仍会碰到桌子,但机器人不会收到这部分接触反力。示例中的桌子从不移动,已将它改为 static,运行时确认两边 MuJoCo 模型均有 8 个桌子碰撞几何。修正桌子后,最初的新旧咖啡杯完整任务仍失败,说明这不是全部原因;随后手部接触调参才出现完整改善候选。真正会运动的 kinematic 物体不能用这种场景修正替代支持。 - -### 部分接触参数在 VBD 中的作用与旧配置不同 - -**状态:已核对源码及 CPU 接触力;这不是所有剩余失败的原因证明。** - -- 当前默认的刚体硬接触不使用 `friction_epsilon`。只改变它不会调整这条分支的摩擦;原计划的纸杯候选已在启动前撤销。 -- 相同的夹爪接触余量也未必有相同效果:当前 UR5 手指的 1 mm margin 在 MuJoCo 原生碰撞中被清零,在 VBD 中仍保留。双臂放置的局部零余量候选仍在旧缓存的协作段甩出面包,已明确记录后提前停止,未修改全局默认;这不代表所有任务都不适合零余量,Assemble 的独立对照仍待结果。 -- 当前 VBD 刚体接触没有读取独立的扭转、滚动摩擦系数。旧 MuJoCo 中有效的扭转摩擦配置,不会自动得到等价作用。多个接触点仍可能通过切向力抵抗旋转,因此不能直接推断所有抓持都不适用。 -- 手指和物体的滑动摩擦取几何平均。例如手指设为 4、杯子为 0.97,接触对约为 1.97;刚度和阻尼则取两侧的算术平均。调参应比较最终接触对,而不只看某一个配置字段。 -- 接触阻尼 `kd` 在硬接触中有效,但只抵抗接触面相互接近的法向运动,不是通用的止滑、止转参数。安装包 CPU 核对中,增大它能提高接近时的法向阻力,却没有同步提高该瞬间的切向摩擦上限;法向不再接近时,这项阻尼不生效。不能因此断言某个任务失败由它造成,但不应把增大 `kd` 当作普遍增强抓持的手段。 - -单点纯扭转的 CPU 核对显示,提高滑动摩擦无法产生缺失的独立抗扭项。它只说明该力模型的边界;具体技能是否依赖这项能力,还需要实际接触几何和完整任务证据。详细记录及原始数据见[第二轮调参记录](coupling_tuning/round2.md)。 - -全程关闭接触点黏着重放也不是通用解法:HandOver 的独立候选在最终松手前就提前脱手,完整运行后侧倒。当前保留该设置,优先重复验证释放前等待的候选。这个失败不能证明只在释放阶段关闭重放也一定无效。 - -### 调参时要注意:刚体的旧阻尼字段不会改变 Newton 运动 - -**状态:已核对当前构建和运行时赋值路径,并用安装包 CPU 模型检查确认;不是 MJVBDV2 独有的新问题。** - -例程给杯子、勺子等刚体设置的 `linear_damping` / `angular_damping`,在当前 Newton 路径中只保留为属性记录。读回数值变了,不代表运动真的受到了更强阻尼。安装包检查将两项都从 0 改成 100,质量、惯量、速度、关节阻尼及接触材料等相关模型数组完全相同。 - -这与已经用于 Place、Assemble 调参的机械臂驱动阻尼不同;后者通过关节驱动配置实际进入求解。旧 `mujoco_warp` 和新 `mjvbd_v2` 共用上述刚体构建路径,因此不能据此解释两者所有差异,也不应通过放大这些无效字段来“修复”滑转。 - -DexSim 另有显式施加角阻尼力矩的运行时控制,但它需要单独注册,系数是力矩阻尼系数,不能直接照搬这里的旧数值。目前没有把它叠加到任务候选中,仍先完成接触摩擦与刚度的独立验证。证据见 `coupling_tuning/raw/r2_rigid_damping_mapping_cpu.json`。 - -### 2. 部分抓取、搬运任务与旧 solver 表现不同 - -**状态:本轮调参后部分恢复,尚不能整体认定对齐。** - -第二轮已经取得几项改善: - -- 纸杯的抓起和搬运已经能完整执行,但姿态精度不稳定。最新 11.5 mm 正式入口误差为 2.90 mm / 11.32°,而同闭合量此前缓存为 5.01 mm / 3.57°,旧 MuJoCo 独立规划为 3.69 mm / 2.88°。因此不能把缓存的一次改善写成已经对齐;当前精确缓存重复用于定位差异,未增加新的物理参数组合。 -- 同一接触配置用于 PickUp 后,最终差约 1.9 mm / 2.1°;Pour 完整 2933 步后差约 3.4 mm / 0.52°,均没有掉落。AxisAlign 恢复了对齐目标轴的效果,但旧对照自身掉落,暂不称为严格对齐。 -- 双臂托盘使用手指摩擦 4 和接触历史后,26、22.5、23 mm 闭合目标均完成搬运及额外 4.8 秒保持,22 mm 则只抬起了一部分。选择 23 mm 接入 UR5 塑料托盘入口;该候选最终与旧 MuJoCo 相差约 3.7 mm / 4.4°,距任务目标约 7.2 mm,旧 MuJoCo 为 9.3 mm。正式入口重新规划后也完整完成 888 步,得到一致结果;仍不能推广到其他尺寸及所有物体。 -- Place 需要额外调整:保留原 mimic,使用接触 alpha=0.5,并把机械臂阻尼降至 1000。四次完整回放均保持到释放,水平落点误差约 0.52–3.77 mm,其中一次直接使用新安装包。配置已接入 UR5 V2 教程;落地朝向约在 82.1–94.8° 之间波动,姿态差异尚未消除。正式入口重新规划随后完成 778 步,水平误差 2.35 mm,yaw 85.31°,与旧低阻尼对照姿态差约 0.37°,末尾稳定;仍未覆盖初态扰动。 - -Place 的诊断过程也排除了一个过于简单的解释:降低 mimic 阻尼虽然改善了手指跟随,却没有消除掉落;接触参数和机械臂驱动响应都参与了结果。详细试验保留在调参记录中。 - -换手原无等待配置不稳定,重复曾侧倒。保留左手 7 mm/右手 5.5 mm、手指摩擦 4、接触历史和原机械臂驱动,增加释放前一秒等待后,三次完整运行均直立停稳,水平误差约 13–16 mm。等待已接入 UR5 竖直罐子的教程,正式源代码入口随后完整完成 1776 步,水平误差 12.36 mm、直立倾斜 0.020°,最后两秒稳定。最终朝向仍有波动,重新规划生成的指令也与缓存几乎相同,尚未证明不同初态下的稳定性。 +当前单向路径没有这个平衡:被抓取的 VBD 物体无法阻止手指闭合。手指仍受自身驱动、力矩限制和 MuJoCo 可见接触影响,但缺少这件物体的反力。当两指间隙小于物体尺寸时,VBD 只能尝试移动或转动物体,可能出现穿透、挤出、滑转或抖动。 -推物也得到改善:接近距离保持 30 mm,将推进补偿从 18 mm 调到 30 mm 后,完整任务的水平误差为 8.59 mm、姿态误差 0.82°,均优于旧对照的 10.35 mm / 1.78°。38 mm 补偿虽然进一步减小位置误差,却使姿态误差升至 6.44°,暂不采用。30 mm 候选随后三次完整运行的水平误差为 8.59 / 6.79 / 8.95 mm,姿态误差为 0.82 / 2.62 / 7.07°;其中一次重新规划,位置改善但姿态仍有波动,不能直接推广为所有物体的默认值。 +已有直接证据:同一抓取命令下,旧 MuJoCo 的手指被物体挡在约 0.012 m,新路径则继续到约 0.036 m。这些数值是关节位置,不是夹口宽度。调小闭合目标后能够恢复部分抓取,但控制命令已经改变。 -这些是完整固定轨迹回放的证据,仍需正式入口实时重新规划和重复验证,不能推广为全部任务已经对齐。Place 的旧 MuJoCo 重复运行也会出现不同落点,需要同时报告技能效果和新旧轨迹差异,不能只挑一次成功结果比较。 +**影响与边界:** -Pour 还有已确认的初始化错误:5 cm 方块中心原来在 z=0,一半体积穿地,使规划器读到被顶起后的错误位置。现在改为半边长高度,V2 再留出 1 mm 初始间隙。**当前全局地面参数保持原值。** 之前清零地面余量的尝试因 locomotion 回归而撤回,上述最新 Pour 结果不依赖这项修改。详见 [第二轮调参记录](coupling_tuning/round2.md)。 +- 依赖“过闭合目标+接触反力”的位置夹紧控制,不能直接沿用;物体负载对机械臂的反作用也缺失。 +- 增加摩擦、迭代或减小步长,可以改善现有接触求解,无法产生缺失的反力回传。 +- 按尺寸标定闭合目标只是一种场景适配,会对几何、姿态、碰撞余量和控制误差敏感,不能视为通用闭合策略。 +- 若要求保留原有接触驱动的控制行为,需要让这类接触具有双向动力学响应,例如由同一求解器处理,或采用经过稳定性验证的双向耦合。简单延迟一帧回传力并不自动保证稳定。 +- 根据接触主动停止闭合属于另一种控制策略,也不能完整恢复物体对机械臂的负载反馈。 -下文是第一轮历史结果,并不代表所有候选的最新状态。 +这是已确认的结构性限制,但不能据此把所有任务失败都归为同一个原因;场景几何和规划问题仍需独立排查。 -2026-09-17 补充:对 UR5 的 DH 夹爪,把 5 cm 方块的闭合目标从 0.036 m 改为 0.013 m 后,PickUp 和 AxisAlign 已通过完整动作及最终保持。PickUp 的最终物体中心与同轨迹 MuJoCo 对照相差约 1.9 mm;AxisAlign 最终目标轴误差约 0.75°。Place 的候选仍在搬运途中提前掉落,最终落点接近目标不能算成功,候选改动已撤回。单独增加迭代、启用接触历史或改变刚度等尝试没有恢复原来过大的闭合目标。MoveHeldObject 的 0.0115 m 候选完整跑完后没有掉落,但最终位置误差约 11.4 mm、姿态误差约 23.8°,尚未恢复目标位姿,未设为默认。 +## 2. 动态刚体的加入会改变 articulation 的接触路径 -原因是旧 MuJoCo 的接触反力会把手指挡在约 0.012 m,V2 单向耦合则让手指真的闭合到 0.036 m。对已知物体标定闭合目标可以改善效果,但不能当作原始控制命令完全不变的替换。 +纯 articulation 与静态地面场景可以走纯 MuJoCo 分支。加入 VBD 动态刚体后,原生混合分支关闭 MuJoCo 接触,同时又不回传 VBD 反力,因此即使新增物体在远处,也可能让机器人失去地面支撑。这是求解路径变化,不是机器人控制参数突然失效。 -补充几何核对:DH 夹爪原始碰撞网格在采样抓持区域的开口约 73.5–75.1 mm,不是规划模型填写的 100 mm。按关节运动计算,36 mm 目标会把间隙缩到约 1.5–3.1 mm,13 mm 目标则约为 47.5–49.1 mm。通用闭合适配必须使用实际夹爪标定,不能直接从规划模型最大开口换算。这是静态几何证据,尚未包含碰撞余量与求解过程。 +本地实验补丁把混合模式的 `disable_contacts` 默认改为 `False`,保留 `use_mujoco_contacts=True`,恢复了 MuJoCo 紧凑模型内的机器人、静态环境及允许的 articulation 间接触。**它实际启用了 MuJoCo-Warp 和 Newton 两套碰撞管线,偏离原生 V2 混合模式的接触配置。** -第一轮 Pour 的无效固定轨迹在旧 MuJoCo 下也没抓住物体;第二轮已定位其初始化原因,并重新建立有效对照。第一轮筛选和验证边界见 [第一轮调参记录](coupling_tuning/report.md)。下面保留的是**上一轮沿用旧参数时的观察**,不是调参后的结果。 +自由刚体仍不进入 MuJoCo 模型,VBD 侧机器人仍不接收反力,所以双管线不等于同一对接触重复施力,也没有解决第 1 节的夹紧限制。不过,两套管线带来的开销、参数差异和查询范围需要分别处理;本方案尚不是确认后的最终架构。 -最常见的现象是:机器人按规划运动了,但物体没有被稳定夹住,抬起后滑落,或者没有到达预期位置。 +若要求只使用 Newton 碰撞,同时保留 articulation 的接触响应,需要把合适的接触映射给 MuJoCo 求解。当前 V2 尚未接通此路径,直接设 `use_mujoco_contacts=False` 会被拒绝。 -| 场景 | MJVBDV2 的实际表现 | 旧 solver 的对照 | -| --- | --- | --- | -| PickUp | 方块短暂抬起后滑落,最终中心高度约 2.6 cm | 最终中心高度约 18.2 cm | -| MoveHeldObject | 杯子滑落,没有到达搬运目标 | 最终物体位置距目标约 3.7 mm | -| Pour | 方块没有保持夹持,倾倒动作未达到预期效果 | 对照中方块最终仍保持在约 18.1 cm 高处 | -| 双臂协作抬托盘 | 托盘只部分抬起,最终位置距目标约 6.6 cm | 距目标约 9.5 mm | +另外,独立 kinematic 物体不会自动进入上述 MuJoCo 接触模型。固定设施可按真实用途声明为 static;真正运动的 kinematic 物体不能用这种替换来解决支持缺口。 -这些场景涉及机器人与自由刚体的接触。V2 的求解方式和反力传递与旧 solver 不同,是需要重点检查的因素;目前没有逐项证明每个失败都只有这一个原因。 +## 3. 同名接触参数并不代表相同的物理作用 -也不能据此认定所有 manipulation 都不能用。已有 UR5 抓放流程在一次运行中连续完成了三轮抓放,但那不是多次独立实验得出的成功率。 +切换求解器后,必须核对参数实际被谁消费,不能只看配置值相同: -诊断时尽量固定初态和机械臂路径,逐项改变夹持指令、接触或驱动参数,观察物体从哪一阶段开始偏离。验收时再比较完整任务效果,并明确哪些参数或时序已经改变。放慢动作后成功可以是有效适配,但不能据此声称原时序直接替换已经对齐。 - -### 双臂放置的桌子:外观和碰撞形状没有对上 - -**状态:小补丁已构建并安装,正常安装入口检查通过,尚未提交或推送。** - -桌面看起来在 0.65 m 高,但实际碰撞网格最高只有约 0.553 m,横向也有偏移。旧 MuJoCo 和 V2 都受影响,面包与平底锅还没被抓住就掉下去了。这个现象不能用来判断 V2 的抓取能力。 - -原因是单凸包构建时重新用 Newton 读取 GLB,与 DexSim 渲染导入采用了不同坐标。改为使用已导入顶点后,桌子的碰撞坐标与外观恢复一致。面包还存在约 20 mm 的初始穿透;消除穿透后,两种 solver 的启动诊断都能让物体留在桌上。正式修正保持单凸包,不改变刚体所有权;没有增加新的仓库测试。几何修正后的旧 MuJoCo 完整动作已验证:前置抓取恢复,但面包仍在后续协作搬运中甩出;V2 候选继续验证。 协作放置源码中始终不动的桌子也已改成 static,确保它进入 V2 的 MuJoCo 接触模型;这不等于抓持问题已修复。 - -### 双臂放置:旧缓存不能代表正常规划,锅也没有准确到位 - -**状态:正常重新规划已完整运行,仍未达到预期落放效果;继续定位,不据此判定单向耦合不适用。** - -最新候选正常生成三段计划,前两段与旧缓存相同,第三段却明显不同:左手末端峰值速度约为旧缓存的六分之一。面包这次没有早早甩出,最后停在锅所在区域,但朝向几乎翻转,锅本身也偏离目标约 94 mm,不能只看“没有落地”就算成功。 - -释放前,右手离它应该到的位置约 78 mm,锅在手里的相对位移约 8 mm。这说明需要先查右臂为什么没走到位,继续提高夹爪摩擦并不对症。旧 MuJoCo 随后回放同一条新轨迹,右手同样偏离约 78 mm;协作阶段采样持续有右上臂与桌子的接触,驱动与约束力矩大幅对抗,两侧右臂实际关节最大差仅 2.15e-6 rad。这部分大误差并非 VBD 特有,需要先修正场景或路径。详细证据见[第二轮调参记录](coupling_tuning/round2.md)。 - -补充几何核对:右手目标姿态会让右上臂碰撞形状与桌子实体相交,并非只在桌下空隙中发生凸包假碰撞。这是需要先处理的场景/机械臂姿态问题,继续增大驱动力可能只会加深穿透。离线 IK 找到了其他不撞桌的终点姿态,但尚未验证完整路径;运行时接触对照已支持桌子阻挡这一判断;提高机器人安装位置的新旧正常规划对照仍待结果。当前没有为让示例通过而关闭桌子碰撞或改动规划框架。 - -仅把夹爪余量清零也没有解决双臂放置:面包在协作段被甩到工作区外约 4.9 m,确认剩余动作无法重新抓取后主动停止。该候选只运行了 2200 步,作为失败筛选记录,不计作完整验证。 - -### 3. Twist 是一个需要单独排查的例外 - -**状态:已观察到明显差异,原因尚未确定。** - -Twist 的默认场景是机器人与微波炉,主要对象都是带关节的结构,没有单独的动态自由刚体。因此,不能用“机器人和 VBD 物体之间缺少反力”来直接解释这个例子。 - -已有回放中,V2 的旋钮最终转角约为 **2.154 rad**,旧 solver 约为 **1.092 rad**,而且微波炉门也出现了不同程度的运动。 - -这说明“只要都是 articulation,就一定完全一致”还不能成立。不过,之前这组教程对照并没有严格锁定整段动作序列,规划和采样也不是完全受控的,所以目前记录的是待排查现象,还没有确定是哪一处物理实现出了问题。 - -本轮按要求跳过 Twist。若以后恢复排查,应使用同一段动作回放,并核对两边实际生效的接触、摩擦和关节参数。 - -### 4. Twist 启动时会打印大量 margin 警告,配置的 1 mm 没有生效 - -**状态:已确认,仍存在。警告背后的参数变化是真实的。** - -典型输出是: - -```text -authored margin=0.001... zeroed for NATIVECCD/MULTICCD compatibility -``` - -意思是:碰撞形状原本配置了约 1 mm 的接触提前量,但 solver 为兼容当前 MuJoCo-Warp 的原生接触算法,把它改成了 0。 - -Twist 教程启用了多接触点生成。夹爪有多个碰撞形状,每个相关形状都可能打印一条警告,因此启动时会看到很多行。仿真可以继续,但这 1 mm 的配置确实没有被保留,接触建立的时机可能受到影响。 - -这段逻辑在 MR 原始分支里就存在,不是本次 Contact Query 补丁新增的。目前也还没有证据证明它就是 Twist 新旧表现不同的原因。 - -**不能直接照警告建议,把 `use_mujoco_contacts` 改成 `False`。** 当前 V2 的纯 MuJoCo 分支要求这个选项为 `True`,直接修改会报错。警告里的建议适用于通用 MuJoCo solver,没有考虑 V2 的这一限制。 - -后续需要确认这类场景实际需要怎样的接触距离设置,并让警告给出适合 V2 的说明。只隐藏日志不会恢复被清零的参数。 - -### 5. Contact Query 能用,但混合场景还不能提供同样的力反馈 - -**状态:纯 MuJoCo 分支已接通并验证;混合分支的能力仍有限。** - -| 场景 | 当前能拿到什么 | +| 参数或机制 | 当前差异及影响 | | --- | --- | -| 带关节机器人+静态地面,使用纯 MuJoCo 分支 | 接触对象、位置、法线、距离,以及法向冲量和摩擦冲量 | -| 包含 VBD 动态刚体的混合分支 | 接触几何信息;还没有与纯 MuJoCo 分支等价的接触冲量、力反馈 | - -因此,“能查到碰撞位置”和“能获得训练需要的接触力”需要分别确认。使用接触力作为 observation 或 reward 时,必须核对当前分支实际支持的字段。 - -此外,接口提供的冲量不是直接的力。本次足端力比较是用冲量除以对应的物理子步时间得到的,不能改用策略更新间隔来换算。 +| 接触余量 margin | MuJoCo 原生 NATIVECCD/MULTICCD 路径会把相关形状的非零 margin 清零,VBD 仍保留;接触建立和释放时机可能不同。启动警告反映真实参数变化,隐藏警告不等于修复。 | +| 扭转、滚动摩擦 | 当前 VBD 刚体接触不读取独立的扭转、滚动摩擦系数,不能照搬 MuJoCo 的相应约束。多个接触点的切向力仍可产生抗转力矩,不等于完全没有抗转能力。 | +| 滑动摩擦、刚度与阻尼 | VBD 接触对的滑动摩擦取几何平均,刚度和阻尼取算术平均;应比较最终接触对,而非只比较手指字段。 | +| 接触阻尼 kd | 当前硬接触中主要抵抗相互接近的法向运动,不是通用的切向止滑或角阻尼。 | +| friction_epsilon | 当前默认刚体硬接触路径不消费该项,修改它不会改变这条路径的摩擦。 | +| 刚体 linear_damping / angular_damping | 现有 Newton 路径中的这些旧属性只保留记录,没有等价施加到运动上;关节驱动 damping 则实际参与求解。此限制也影响旧 Newton MuJoCo,不能归为 V2 独有回归。 | -### 6. 位置控制下,`get_qf()` 不能当成实际电机输出力矩 +这解释了为什么复制旧参数不能保证行为相同,但不意味着全部差异都能靠调参消除。尤其是摩擦和接触阻尼无法替代双向反力。 -**状态:已确认的现有 Newton 接口限制,不是本次证明出的 V2 独有问题。** +## 4. 接触观测尚未形成统一的力反馈接口 -在本次位置 PD 控制的行走验证中,`get_qf()` 读到的数组一直为 0。检查后确认,当前 Newton 路径读的是直接输入给关节的力矩命令,没有包含 PD 控制器实际产生的力矩。 - -**影响:不能拿这个全零数组来证明两边电机力矩一致,也不能直接用它计算实际力矩或能耗惩罚。** 如果训练任务需要这些奖励项,需要另行接通实际输出力矩,并确认它的含义。 - -## 接入过程中已经修复的问题 - -这些问题已经纳入补丁。下面保留记录,便于以后遇到类似现象时追查。 - -| 问题 | 当时的影响 | 当前处理 | -| --- | --- | --- | -| 接触查询和部分关节操作找不到 V2 内部的 MuJoCo solver | 原来直接访问 MuJoCo 的代码不能直接用于 V2,碰撞形状编号也需要转换 | 已接通内部 solver 的访问和编号转换;纯 MuJoCo 接触反馈已做数值对照 | -| 更新机器人姿态时,可能把自由刚体也写回旧位置 | VBD 已经算出的物体运动被旧关节数据覆盖 | 已限制更新范围,保留 VBD 计算出的自由刚体位置 | -| 瞬移物体后,物体会继续异常移动 | 零重力下把物体从 x=3 移到 x=4,之后两步却跑到 x=5 | 已同步求解器内部的历史状态;复测可以停在 x=4,并保留原有速度 | -| CUDA Graph 预热后,公开状态恢复了,内部历史没有恢复 | 正式仿真的第一步可能使用预热留下的状态,影响初始运动 | 已补齐内部状态恢复,并验证重建后继续步进 | -| VBD 中用于表示机器人的碰撞代理姿态处理不正确 | 代理可能使用回退后的姿态参与接触计算 | 已让不由 VBD 积分的代理保留传入姿态 | -| 混合分支关闭 MuJoCo 接触后,接触缓冲区容量为 0 | 某些摩擦计算路径会除零 | 已保留一个不使用的接触槽;没有因此重新启用 MuJoCo 接触 | -| reset 不能正确覆盖 V2,或把自由刚体的内部关节误算成机器人 | 环境复位可能报错或清理范围不正确 | 已适配;验证了单环境、部分环境和全部环境 reset | -| Gym reset 时删除并重建同名资产失败 | modular Gym 不能正常连续运行多个 episode | 已补齐同名替换:新对象使用新初值,其他对象保留原状态 | - -教程里还修复了几项与 solver 对接有关的问题,包括杯子缩放、Pour 的轨迹重采样、速度跟踪读取状态的时机,以及关闭物理碰撞后规划器丢失障碍物几何。这些修复让程序能正确执行,但不会自动解决抓取接触效果的差异。 - -## 行走已经确认到什么程度 - -在 **ANYmal-C+静态地面/平台** 范围内,当前适配版本与旧 solver 的行为接近。4 个环境分别执行前进、侧移和转弯,每个环境运行 30 秒,并覆盖了局部 reset。 - -相同动作输入下,正常行走时的关节位置最大差约为 **0.0000011 rad**,足端法向力分量最大差约为 **0.015 N**。旧 solver 自己重复运行也会有同量级差异;接触数量和接触/离地标记一致。 - -让两边各自运行策略时,转弯环境会出现步态相位差:机身位置最大差约 1.78 cm,旧 solver 自己重复运行约 1.92 cm。因此,可以说这组场景的行走效果接近,不能说逐帧完全一致。 - -把机器人强行移入地面的压力检查中,两种 solver 都出现了较大的接触力波动。这部分结果没有计入上面的正常行走指标。 - -**实际训练是否能达到相同效果还没有验证。** 本次没有进行 PPO 从零训练,也没有验证具体训练任务的完整 reward、done、域随机化或复杂地形。行走回放通过不等于学习曲线已经对齐。 - -## 一起发现、但不能归为 V2 新增的问题 - -- Press 的按钮行程在新旧 solver 中都出现越限;Slide 在两边都没有完全关上抽屉;OpenDoor 在两边都有打开后回摆。这些任务本身仍需改进,不能只按任务失败就判定 V2 不对齐。 -- 现有 Newton 后端尚未支持通用刚体约束,旧 solver 路径也没有这项能力。 -- USD 导出可以生成文件,但还没有完整写出 Newton 的刚体、关节等物理信息,不能当成可完整还原的仿真场景。 -- NeuralPlanner 缺少匹配的模型资源,尚未完成对应验证。 -- 有些入口不加 `--physics newton` 时会运行默认后端。比较结果前需要确认实际 backend 和 solver,不能只根据“安装了哪个 DexSim”判断运行路径。 - -## 这份记录对应哪一版 - -- EmbodiChain:[draft PR #645](https://github.com/DexForce/EmbodiChain/pull/645),代码提交 `75d3c9a3`。 -- DexSim:[MR !1345](http://192.168.3.16/Engine/dexsim/-/merge_requests/1345),适配补丁已提交到 `MJVBDV2` 分支,提交 `f7d60c2a2`。 -- 验证使用的是包含这些补丁的本地构建,不代表未经适配的早期分支也具备同样能力。 - -此前覆盖了 15 项内置原子技能、18 个原子教程和另外 26 个 Newton 示例入口,但没有穷举所有机器人、参数和规划器组合。最后一轮补丁后,只对受影响场景进行了针对性复测,没有把全部入口再跑一遍。操作任务的多数结果来自单次回放,不能当成统计成功率。 - -详细数据见[示例与原子技能验证报告](/home/oem/code/EmbodiChain/outputs/validation/mjvbd_v2/report.md)和[行走对齐验证报告](/home/oem/code/EmbodiChain/outputs/validation/mjvbd_v2/locomotion_alignment/report.md)。 - -## 最新补充:舀冰旧基线已经跑通 - -旧 MuJoCo 的接触和约束容量增到 8192 / 16384 后,完整完成了 3300 步舀冰与末尾保持,没有 CUDA 错误或容量溢出。勺子没有脱手,最后距目标约 5.6 mm / 1.7°,11 块冰块处于勺斗范围内并已抬升约 29–34 cm。之前“没有有效旧基线”的状态因此更新;具体指标及限制见第二轮记录。V2 的相同种子完整对照尚待运行,不能先宣布舀冰已经对齐。 - -### 2026-09-18 补充:舀冰的完整失败证据 - -新旧 solver 都完整运行到 3300 步,包含全部舀冰动作和末尾保持。旧 MuJoCo 保持勺子,并在勺碗区域带出 11 块冰;当前 MJVBDV2 在抬升时脱手,最终勺子落地,没有带出冰块。两侧手指、勺子的材料输入一致,但接触求解方式不同。此结果确认当前配置没有恢复任务效果,不足以证明单向耦合永远无法完成该任务。 - -正在验证的改进仅涉及手指摩擦、接触历史、闭合姿态和分段闭合指令。没有改变刚体归属,没有附着物体,没有增加仓库测试或 benchmark。分段闭合仍占原来的 100 个物理步,避免用额外等待掩盖差异。 - -### 交接的重复性仍不合格(2026-09-18 补充) - -交接不能只看最好的一次。正式安装包入口两次完整运行的水平落点误差分别为 31.60 mm 和 15.37 mm,两次指令几乎一致。此前表现较好的缓存候选再次完整运行时还出现侧倒,误差 45.91 mm。因此,当前夹爪和接触配置仍不足以稳定替换旧 solver,教程内的参数只能视为本地候选。 - -后续分别检查“机械臂尚未到位就松手”和接触历史中的黏着锚点。先前数据已把主要差异放大阶段定位到释放和落地,但尚未证明是哪一项机制造成失败;不能用未经验证的原因解释掉这些失败。 - -### 舀冰的旧对照也需要重新核实(2026-09-18 补充) - -当前安装包的旧 MuJoCo 补充运行在第 868 步出现冰块非有限位姿,接近阶段已可见飞散,未完成任务。此前成功的旧侧 3300 步记录早于本轮补丁安装,不能直接当作当前版本的严格基线。正在核对单凸包网格导入并补当前安装包的完整旧对照;尚无证据断言该发散由网格补丁造成。V2 此前抬升时丢勺子的失败仍然有效,并未因旧对照异常而撤销。 - -### 舀冰抓持已有改善,但没有提前判定任务通过(2026-09-18) - -正常安装包下,只将手部摩擦设为 4 并启用接触历史,原闭合目标不变,V2 完成了前 1200 步抓持和抬升:勺子抬高 33.7 cm,没有掉落。原闭合目标下相对手部仍有约 3.4 mm / 5.7° 的滑转;随后小幅标定六个手指目标,完整抬升的相对变化降至约 1.14 mm / 1.49°。两组均未脱手,但完整进入冰堆、舀出冰块和保持尚待验证。该结果支持继续调参,不能据此宣称舀冰已对齐。 - -另外,一个代表冰块在新旧网格导入路径下的凸包顶点、尺寸、体积,以及同一 CPU 算法计算的质量、质心和惯量均完全一致。目前没有证据把旧侧发散归因于该冰块的外形或惯量被补丁改坏。 - -### 舀冰盖子驱动是一个新的待验证因素 - -盖子初始是打开的,但配置的驱动没有生效,机械臂接近阶段盖子会明显转动。旧侧冰块飞散也发生在这一阶段,尚不能证明两者是因果关系;V2 中盖子同样转动,冰块却保持稳定。已准备新旧共同的对照,用有限力矩的位置驱动保持盖子打开,仍保留动态关节和碰撞。结果待运行,未把它当作已经修复的问题。 - -### 完整舀冰、双臂放置仍有实质差距 - -舀冰标定候选已经完整完成 3300 步,能带出 3 块冰;只改摩擦和接触历史、保留原闭合目标时为 1 块。但历史旧侧能带出 11 块,标定候选末尾目标误差仍有约 22.69 mm / 14.76°,抓持和末尾保持还不够稳定。分段闭合在修正诊断脚本后完成了阶段验证,反而比闭合姿态标定滑转更大,暂不采用。 - -双臂放置的右夹口修正后,抬锅明显稳定了,但面包仍在协作阶段脱手。放慢第三阶段两倍没有得到成功结果;其中 V2 在前面未改变时序的抓取阶段就掉面包,不能把这次失败归咎于减速。 - -保持容器盖子打开的旧侧舀冰对照已完整运行,没有再次数值发散,却没有带出冰块。因此,“不崩溃”和“完成任务”在这组场景中也是两回事,盖子驱动尚不是完整修复。 - - -### 舀冰旧基线也不稳定,同步开关不是修复(2026-09-18 补充) - -当前安装包中,旧 MuJoCo 显式关闭 CUDA 同步后完整跑完 3300 步,最后带出 5 块冰,但勺子在手里已滑转约 20.8°;显式开启同步的同配置运行则在第 700 步出现冰块非有限位姿。历史上开启同步曾带出 11 块,说明不能把这个开关当作解决办法,也不能把历史最好的一次当作稳定基准。两组仅各一次,尚不足以确定同步开关与失败的因果关系。 - -V2 扩大容量后完整带出 5–6 块冰的结果有效,但不能因为本次旧侧退化就宣布对齐。当前继续完成手部摩擦、刚度的独立验证,并保留完整动作和保持阶段的评价。详见第二轮记录中的同步对照及原始日志。 - - -### 张开夹爪后,接触余量仍可能妨碍释放(2026-09-18 补充) - -Assemble 中,张手后额外等一秒仍留下约 17.82 mm 偏心。等待结束时手指已基本全开,但罐子维持约 9.85° 倾斜;记录的手指接触点间隙约 0.81–0.94 mm,仍处于 VBD 的 1 mm 接触余量内,相关接触的法向约束乘子也没有归零。继续等待并没有让它脱离这些接触。 - -只改接触 alpha=0.5 的另一遍完整运行则正常落到底座,偏心 6.93 mm 并停稳,正在安排重复验证。另增加只改夹爪 margin 的完整对照,检查原 MuJoCo 中被清零、VBD 中仍保留的余量是否影响释放;尚未证明清零就能解决,未改正式默认值。这个线索来自已有接触点的几何与乘子记录,不是精确碰撞重算或完整力测量。 - - -### alpha 的改善不能跨任务直接推广(2026-09-18 补充) - -Assemble 使用 alpha=0.5 的单次结果改善到 6.93 mm 偏心,但同样调整在双臂放置中使面包第一次抬升就失败,最后仍留在桌上;锅的抓持反而更稳定。完整 3032 步正常退出也不能算任务成功。当前不将 alpha=0.5 设为通用默认,继续用完整任务验证每个候选。 - - -### 纸杯的较好参数仍未证明稳定(2026-09-18 补充) - -11.5 mm 闭合量曾在完整缓存回放中取得约 5.01 mm / 3.57° 的目标误差,但正式入口正常重新规划的一次运行中,杯子在手内的转动明显更大。两次记录到的材料、驱动和初态一致,机械臂命令几乎相同;到第 4587 步,杯子姿态已相差约 8.09°。本次仍在运行,不能当作完整失败,但之前一次好结果也不足以验收这套参数。 - -目前需要确认的是抓持对微小差异是否敏感,以及是否存在尚未记录的模型或执行差别。尚未证明是 GPU 非确定性,也未证明必须改双向耦合。详细对照见第二轮记录的纸杯 11.5 mm 小节。 - - -### 少量接触条目的法向量为零,部分诊断数值需作废(2026-09-18 补充) - -装配的一次完整运行中,三个采样点出现零法向接触。原诊断程序据此算出的“1 mm 穿透”没有物理意义,现已标为不可计算并保留原始数据。张手等待结束时的四个接触法向正常,因此先前关于释放余量的线索仍成立,但不能借这些零法向数据推断夹持力或穿透。 - -这是一项待定位的接触数据问题,尚未证明源于碰撞生成、记录时机或 solver 内部处理,也未证明是任务失败的原因。后续接触记录会显式标识有效性,避免继续误读。 - - -### 纸杯最新完整结果:停止后抓得住,搬运转偏尚未解决(2026-09-18 补充) - -11.5 mm 正式入口现已完整跑完 7460 步,最终位置误差 2.90 mm、姿态误差 11.32°;最后 4.8 秒只变化约 0.63 mm / 0.15°。主要偏差在搬运过程中形成,停止后没有继续明显滑动,也没有恢复正确朝向。 +| 路径 | 已确认能力 | +| --- | --- | +| 纯 MuJoCo | 已适配形状编号映射,可查询接触几何、法向及摩擦冲量,并做过行走数值对照。 | +| 混合模式 | 可查询接触几何,但尚未统一合并 MuJoCo 与 VBD 接触,也未提供与纯分支等价的冲量、力反馈。占位零值不能解释为真实无力。 | -此前同闭合量缓存回放的姿态误差只有 3.57°,旧 MuJoCo 独立规划约 2.88°。因此当前不能认为纸杯已稳定对齐,也不能把单次缓存的好结果作为参数已经标定成功的证明。精确缓存重复已排队,仍未确定根因。 +“查到碰撞”不等于“有可用于控制或奖励的接触力”。冲量换算为力需要使用对应物理子步时长,不能使用策略更新间隔。即使未来能查询 VBD 接触力,查询接口本身也不会使它回传给 articulation。 +另有两项观测限制: -### 双臂放置有明确的机器人—桌子冲突,不能全归因于 VBD(2026-09-18 补充) +- 当前 Newton 的 `get_qf()` 在位置驱动下读的是直接输入的力矩命令,不包含 PD 实际输出。全零结果不能证明电机力矩一致,也不能直接用于能耗奖励;这不是 V2 独有问题。 +- 部分混合接触记录出现零法向且伴有非零约束乘子。这些条目不能用于推导穿透或物理力;尚未确定异常产生于碰撞生成、读取时机还是内部处理,也未证明它是任务失败的原因。 -旧 MuJoCo 回放与 V2 相同的新轨迹后,右手同样偏离目标约 7–8 cm。协作阶段记录持续出现右上臂与桌子的接触,驱动和约束产生很大的反向力矩;两侧右臂实际关节最大差仅约 2.15e-6 rad。此前几何核对也发现目标姿态与桌子相交。 +## 5. 接触容量与碰撞成本影响正确性和可用性 -这说明应先处理安装位置或运动路径,继续加摩擦不能解决被桌子挡住的问题。提高安装位置的新旧完整对照已排队,仍需验证整段路径和最终任务效果。本次旧侧使用了和 V2 一样的标定夹爪命令,是定位原因的对照,不是原教程的成功基线;面包抓持问题也尚未解决。 +VBD 单刚体接触容量与 MuJoCo 的接触、约束容量是不同配置。容量不足会截断参与求解的接触,不只是降低性能;仅扩大 MuJoCo 缓冲区不能解决 VBD 溢出。密集接触验证已观察到单刚体需求超过默认 64,扩大到 256 后完整运行无溢出,但受载滑转仍存在。因此不能用发生截断的结果推断单向耦合的能力上限,也不能把扩容当作夹持问题的完整修复。 +性能方面,在双臂、桌子和两个动态物体的初始场景中,关闭窗口、排除规划与录像并完成预热后,同样 20 个子步下,推进 0.08 秒仿真:旧 MuJoCo 约需 0.10 秒,V2 约需 0.38 秒。CUDA Graph 已启用。阶段测量显示主要瓶颈为 Newton 的 GJK/MPR 凸体精细碰撞,每个子步重复执行会放大成本。 -### 舀冰也已记录到真实零法向接触(2026-09-18 补充) +这是特定场景的步进测量,不是全任务平均值或所有场景的固定倍率。优先方向是检查碰撞对过滤和凸体复杂度;降低子步数需要重新验证接触效果。本地已准备该 demo 从 20 降到 5 的改动,但尚未完成完整速度和效果复验,不在本次文档提交内。 -观测器修复后的摩擦 8 重跑中,第 2360 步起保存到了勺子与手掌、手指之间的零法向接触,并带有非零约束乘子。新记录器不再据此中断任务,也不把这些乘子当成有效的法向/切向力,完整运行仍在继续。 +## 6. 资产、规划与执行差异必须从 solver 差异中分离 -这个现象需要继续定位,不能通过增加摩擦来解释或修复数据本身。但当前还不能证明它是滑转原因,更不能据此断言 MJVBDV2 不适合舀冰;已安排的碰撞生成后观测将帮助区分异常出现的环节。 +已有对照发现以下问题会同时影响新旧 solver: +- 单凸包重新读取 GLB 时采用了不同坐标约定,造成外观和碰撞几何不一致。本地导入补丁改为使用已导入顶点;仅检查画面不够,还需核对实际碰撞形状。 +- 初始穿透、物体尚未落稳就规划,以及目标姿态或路径与桌子相交,会改变抓取初态或阻挡机械臂。双臂同轨迹对照已确认新旧都出现桌子阻挡,不能把此类偏差全归为 VBD。 +- 缓存轨迹、重新规划、不同夹爪命令、释放等待和播放时序会改变实验条件。增加等待或改变目标后成功,是适配结果,不能宣称原控制命令直接替换已对齐。 -### 混合模式启用了两套碰撞管线,之前的对齐结论需要限定(2026-09-18 更正) +因此验证应分别报告:相同输入下的物理差异、适配后的完整任务效果,以及重复运行或初态变化下的稳定性。两边都失败不代表自动对齐,一次成功也不代表稳定兼容。 -本轮为了恢复机器人与地面的接触,把 DexSim 混合模式中的 `mujoco_options.disable_contacts` 从强制 `True` 改为默认 `False`,同时仍使用 `use_mujoco_contacts=True`。这会同时运行 MuJoCo-Warp 和 Newton 两套碰撞管线,并不是单纯保留关节求解。此前把它笼统称为“接触修复”不够准确:它改变了原生 V2 混合模式的接触分工。 +## 已修复的接入问题 -当前修改后的分工是:MuJoCo-Warp 检测并求解其紧凑模型内的 articulation 与静态环境、允许的 articulation 之间的接触;Newton 检测 VBD 自由刚体相关接触,由 VBD 求解。自由刚体没有进入 MuJoCo 模型,机器人在 VBD 侧只是无动力学响应的运动代理,因此两套管线并不意味着同一物体被重复施加接触响应。不过,双管线的开销、接触参数差异和数据查询范围仍需分别处理。 +以下补丁解决了接口或状态同步错误,不改变单向耦合的基本性质: -原生混合模式关闭 MuJoCo 接触,又不把 VBD 反力传回机器人。这意味着 Newton 检测到机器人与地面接触,也不能仅靠这条单向路径给机器人提供支撑力。若要求混合模式只用 Newton 碰撞,同时保留动态 articulation 的接触响应,需要将合适的 Newton 接触映射给 MuJoCo 求解;当前 V2 没有接通这条路径,构造器还明确拒绝 `use_mujoco_contacts=False`。这不是只改一个开关就完成的适配。 +| 类别 | 已完成处理 | +| --- | --- | +| 内部 MuJoCo 访问与编号 | 接通内部 solver,适配 mimic、接触形状编号和 reset。 | +| 状态所有权 | 限制 FK 更新范围,避免旧关节状态覆盖 VBD 自由刚体位置;修正运动代理姿态保留。 | +| 历史状态 | 瞬移和 CUDA Graph 预热回滚时同步内部历史,避免物体异常续移。 | +| 接触缓冲区 | 关闭 MuJoCo 接触时保留必要的非零容量,避免特定摩擦路径除零;这与后续额外开启接触是两项不同改动。 | +| 场景生命周期 | 适配部分/全部 reset,以及同名资产删除重建,支持连续 episode。 | -因此,混合场景 locomotion 的约 1e-6 rad 级同动作对齐,是在额外开启 MuJoCo 原生接触之后得到的,不能当作原生 V2 单向混合模式已经对齐的证据。纯 articulation 路线的结果需要单独看待;两者都不能替代完整训练收敛验证。双臂放置中机器人受桌子阻挡的对照,同样依赖这项开启接触的修改。 +## 验证结论与未覆盖范围 -本次提交保留现有实验结果和配置,但不把双管线方案视为已确认的最终架构。DexSim 的这项补丁及凸包导入坐标修复仍是本轮环境的额外依赖,未包含在 EmbodiChain 的 GitHub 提交中。仅拉取 EmbodiChain 代码,不能保证复现本轮结果。 +- **行走:** ANYmal-C 与静态地面/平台已有正常行走和接触反馈对照,同动作关节位置最大差约 1.1e-6 rad,足端法向力分量最大差约 0.015 N,与旧 solver 自身重复差异同量级。纯 MuJoCo 路线与混合路线必须区分;混合地面支撑结果依赖额外开启 MuJoCo 原生接触,不能作为原生混合配置已对齐的证据。未验证 PPO 从零训练收敛、完整生产 reward/done 或复杂地形。 +- **操作:** 抓起、倾倒、放置和托盘搬运已有完整改善结果;纸杯搬运、装配、双臂放置、舀冰等仍未完成稳定对齐。剩余问题涉及夹持与释放机制、几何/路径和基线稳定性,不能概括为“几个 demo 参数没调好”。 +- **Default 对照:** Slide 采用两后端相同的有效关节阻尼后已通过用户效果验收;这不是旧 Newton MuJoCo 与 V2 的严格数值对照。 +- **暂未完成:** Twist 按要求跳过,其早期结果未严格固定完整动作序列;NeuralPlanner 缺少匹配模型。通用刚体约束和 USD 完整物理导出属于既有 Newton 支持缺口。 -### 本轮提交范围与参数适用边界(2026-09-18 补充) +历史覆盖包括 15 项内置原子技能、18 个原子教程和 26 个其他 Newton 示例入口。不是所有入口都完成任务,也没有覆盖所有机器人、初态与规划器组合。后续补丁只做了针对性复测,不能把早期覆盖数量当作最新版本的全量通过率。 -本轮提交包含按场景选择的夹爪闭合目标、部分夹爪摩擦系数 4、接触历史与 latest 匹配;Place 额外使用 alpha=0.5 和机械臂 damping=1000;HandOver 在释放前等待 1 秒;Pour/Place 修正初始高度;固定桌子使用 static;Scoop 将 VBD 单刚体接触容量提高到 256。夹爪数值是关节位置目标,不是夹口宽度。 +## 版本与复现依赖 -这些调整有机器人和物体范围,尚不是通用参数。其中纸杯 0.0115 闭合目标仍是候选,完整运行的姿态误差达到 11.32°,不能称为稳定标定成功。提高摩擦、刚度、安装高度及额外沉降等待等临时对照没有全部写进正式示例。未新增仓库测试或 benchmark 文件,已有测试随配置修改;原始实验日志和临时诊断脚本未纳入本次提交。 +- EmbodiChain:[draft PR #645](https://github.com/DexForce/EmbodiChain/pull/645)。本文整理截至 2026-09-20 的证据;本次文档更新不代表重新完成全部实验。 +- 已推送 DexSim 适配补丁:[MR !1345](http://192.168.3.16/Engine/dexsim/-/merge_requests/1345),`MJVBDV2` 分支提交 `f7d60c2a2`。 +- **后续验证另依赖两项仍未提交、未推送的 DexSim 本地代码补丁:混合模式开启 MuJoCo 原生接触,以及单凸包导入坐标修复。仅检出上述 DexSim 提交与 EmbodiChain PR,不能保证复现这些后续结果。** 这些代码已用于本地安装包,但不在 EmbodiChain 仓库提交范围内。 +- 没有新增仓库测试或 benchmark。历史参数筛选、测量和详细日志保存在本地 `outputs/validation/mjvbd_v2/` 下的 `report.md`、`locomotion_alignment/report.md` 和 `coupling_tuning/round2.md`;这些产物未随 PR 发布。本文保留综合结论,逐次实验历史仍可从本地记录与 Git 历史追溯。