Skip to content

Commit

Permalink
Make sure that mutable attributes do not get cross-altered in reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed Jun 12, 2024
1 parent 3f41551 commit bf9d7a2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/jaxsim/api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,9 @@ def reduce(
new_joints = set(model.joint_names()) - set(locked_joint_positions)
raise ValueError(f"Passed joints not existing in the model: {new_joints}")

# Copy the model description with a deep copy of the joints.
intermediate_description = dataclasses.replace(
model.description, joints=copy.deepcopy(model.description.joints)
)
# Operate on a deep copy of the model description in order to prevent problems
# when mutable attributes are updated.
intermediate_description = copy.deepcopy(model.description)

# Update the initial position of the joints.
# This is necessary to compute the correct pose of the link pairs connected
Expand Down

0 comments on commit bf9d7a2

Please sign in to comment.