Skip to content

Commit

Permalink
fix qvel bug with no freejoint (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-zhng authored Feb 14, 2025
1 parent f1957d3 commit 2a7f543
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stac_mjx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,12 @@ def compute_velocity_from_kinematics(
[qpos_trajectory, qpos_trajectory[-1, jp.newaxis, :]], axis=0
)

qvel_joints = (qpos_trajectory[1:, 7:] - qpos_trajectory[:-1, 7:]) / dt
# If there's no freejoint, qpos only has the joint angles so no need for indexing.
if not freejoint:
qvel_joints = (qpos_trajectory[1:, :] - qpos_trajectory[:-1, :]) / dt
return jp.clip(qvel_joints, -max_qvel, max_qvel)
else:
qvel_joints = (qpos_trajectory[1:, 7:] - qpos_trajectory[:-1, 7:]) / dt
qvel_translation = (qpos_trajectory[1:, :3] - qpos_trajectory[:-1, :3]) / dt
qvel_gyro = []
for t in range(qpos_trajectory.shape[0] - 1):
Expand Down

0 comments on commit 2a7f543

Please sign in to comment.