Skip to content

[BugFix] _set_obj_xyz in stick-push/stick-pull uses wrong qvel indices, causing object to drift after reset - #584

Open
15101051 wants to merge 4 commits into
Farama-Foundation:mainfrom
15101051:main
Open

[BugFix] _set_obj_xyz in stick-push/stick-pull uses wrong qvel indices, causing object to drift after reset#584
15101051 wants to merge 4 commits into
Farama-Foundation:mainfrom
15101051:main

Conversation

@15101051

Copy link
Copy Markdown

In SawyerStickPushEnvV3 and SawyerStickPullEnvV3, the _set_obj_xyz method zeroes qvel[16:18] to clear the object's velocity. However, due to the stick body using a free joint (7 qpos but only 6 qvel components), there is a +1 offset between qpos and qvel indices for all bodies defined after the stick.
The object's slide joint velocities are actually at qvel[15:17], not qvel[16:18].

  # Current (buggy):
  def _set_obj_xyz(self, pos):
      qpos = self.data.qpos.flat.copy()
      qvel = self.data.qvel.flat.copy()
      qpos[16:18] = pos.copy()
      qvel[16:18] = 0          # ← wrong: zeroes qvel[16] and qvel[17]
      self.set_state(qpos, qvel)

  # Fixed:
      qvel[15:17] = 0          # ← correct: zeroes the actual slide joint velocities

Observed behavior: After reset(), the thermos retains a nonzero x-velocity (~0.68) from the _reset_hand() simulation steps. It slides along +x until hitting the joint limit (offset = 0.2, world x ≈ 0.4), which coincidentally aligns with the target position — making it appear as if the object "teleports" to the goal.

Affected files:

  • metaworld/envs/sawyer_stick_push_v3.py
  • metaworld/envs/sawyer_stick_pull_v3.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants