Skip to content

Commit 979f21c

Browse files
hshi74claude
andcommitted
Only solve equality constraints during slider dragging
The constraint projection was running on every _forward() call, moving joints away from qpos0 during initialization and ground placement. Now it only runs when locked_joint_names is provided (slider drag path). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fa566d7 commit 979f21c

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "robot-keyframe-kit"
7-
version = "0.3.2"
7+
version = "0.3.3"
88
description = "A generalizable Viser-based keyframe editor for any MuJoCo robot"
99
readme = "README.md"
1010
license = "MIT"

src/robot_keyframe_kit/editor.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
from .config import EditorConfig
4848
from .keyframe import Keyframe
49-
from .math_utils import interpolate_action, solve_equality_constraints
49+
from .math_utils import interpolate_action
5050
from .sim_worker import SimWorker
5151

5252

@@ -1276,9 +1276,8 @@ def _get_site_transform(self, name: str) -> np.ndarray:
12761276
raise ValueError(f"Could not find site or body named '{name}'")
12771277

12781278
def _forward(self) -> None:
1279-
"""Run forward kinematics and solve equality constraints at position level."""
1279+
"""Run forward kinematics."""
12801280
mujoco.mj_forward(self.model, self.data)
1281-
solve_equality_constraints(self.model, self.data)
12821281

12831282
def _estimate_robot_height(self) -> float:
12841283
"""Estimate robot height from geom bounds in the current model state."""

src/robot_keyframe_kit/sim_worker.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,14 @@ def _set_joint_angles(self, joint_angles: Dict[str, float]) -> None:
395395
self.data.joint(name).qpos = value
396396

397397
def _forward(self, locked_joint_names: Optional[list[str]] = None) -> None:
398-
"""Run forward kinematics and solve equality constraints at position level."""
398+
"""Run forward kinematics, optionally solving equality constraints.
399+
400+
Constraint projection only runs when *locked_joint_names* is provided
401+
(i.e. during slider dragging). All other callers just need mj_forward.
402+
"""
399403
mujoco.mj_forward(self.model, self.data)
400-
solve_equality_constraints(self.model, self.data, locked_joint_names=locked_joint_names)
404+
if locked_joint_names is not None:
405+
solve_equality_constraints(self.model, self.data, locked_joint_names=locked_joint_names)
401406

402407
def _step(self) -> None:
403408
"""Step physics simulation."""

0 commit comments

Comments
 (0)