Skip to content

Commit 37b75a2

Browse files
authored
Warn when free joint has non-NONE drive targets in SolverMuJoCo (#4083)
1 parent 8b0800e commit 37b75a2

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

changelog/3701.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Warn when joint drive targets are set on a free joint under `SolverMuJoCo`. MuJoCo does not support actuators on free joints, so `joint_target_mode`, `joint_target_ke`, and `joint_target_kd` were silently ignored. A `UserWarning` is now emitted at solver construction time pointing at `Control.joint_f` as the supported workaround.

newton/_src/solvers/mujoco/solver_mujoco.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6668,6 +6668,17 @@ def add_body_from_joint(j: int, *, mocap: bool | None):
66686668
num_dofs += 6
66696669
num_qpos += 7
66706670
num_mjc_joints += 1
6671+
for i in range(6):
6672+
if joint_target_mode[qd_start + i] != int(JointTargetMode.NONE):
6673+
warnings.warn(
6674+
f"Free joint '{model.joint_label[j]}' has a non-NONE joint_target_mode but "
6675+
"SolverMuJoCo cannot create actuators on free joints. "
6676+
"Drive targets (joint_target_ke, joint_target_kd, joint_target_q) are silently ignored. "
6677+
"Apply the desired wrench directly via Control.joint_f instead.",
6678+
UserWarning,
6679+
stacklevel=2,
6680+
)
6681+
break
66716682
elif j_type == JointType.BALL:
66726683
ball_params = {
66736684
"name": name,

0 commit comments

Comments
 (0)