Skip to content

Commit

Permalink
Fix model reduction logic
Browse files Browse the repository at this point in the history
We only need to set the positions of the joints to remove. Passing the angles of the kept joints produces a wrong model with mismatching kinematics and collidable points.
  • Loading branch information
diegoferigo committed Apr 22, 2024
1 parent c805f0a commit 9e63752
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/jaxsim/api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dataclasses
import functools
import pathlib
from typing import Any
from typing import Any, Sequence

import jax
import jax.numpy as jnp
Expand Down Expand Up @@ -56,7 +56,7 @@ def build_from_model_description(
*,
terrain: jaxsim.terrain.Terrain | None = None,
is_urdf: bool | None = None,
considered_joints: list[str] | None = None,
considered_joints: Sequence[str] | None = None,
) -> JaxSimModel:
"""
Build a Model object from a model description.
Expand Down Expand Up @@ -293,7 +293,7 @@ def reduce(
# Update the initial position of the joints.
# This is necessary to compute the correct pose of the link pairs connected
# to removed joints.
for joint_name in model.joint_names():
for joint_name in set(model.joint_names()) - set(considered_joints):
j = intermediate_description.joints_dict[joint_name]
with j.mutable_context():
j.initial_position = float(joint_positions_locked.get(joint_name, 0.0))
Expand Down

0 comments on commit 9e63752

Please sign in to comment.