Skip to content

Commit

Permalink
Avoid unnecessary dynamics computation in inverse dynamics computations
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti authored Feb 11, 2025
1 parent 0020a58 commit 5c89223
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/jaxsim/api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,14 +1420,10 @@ def free_floating_gravity_forces(
The free-floating gravity forces of the model.
"""

# Build a zeroed state.
data_rnea = js.data.JaxSimModelData.zero(
model=model, velocity_representation=data.velocity_representation
)

# Set just the generalized position.
data_rnea = data_rnea.replace(
# Build a new state with zeroed velocities.
data_rnea = js.data.JaxSimModelData.build(
model=model,
velocity_representation=data.velocity_representation,
base_position=data.base_position,
base_quaternion=data.base_quaternion,
joint_positions=data.joint_positions,
Expand Down Expand Up @@ -1462,19 +1458,16 @@ def free_floating_bias_forces(
The free-floating bias forces of the model.
"""

# Build a zeroed state.
data_rnea = js.data.JaxSimModelData.zero(
model=model, velocity_representation=data.velocity_representation
)

# Set the generalized position and generalized velocity.
base_linear_velocity, base_angular_velocity = None, None
if model.floating_base():
base_velocity = data.base_velocity
base_linear_velocity = base_velocity[:3]
base_angular_velocity = base_velocity[3:]
data_rnea = data_rnea.replace(

data_rnea = js.data.JaxSimModelData.build(
model=model,
velocity_representation=data.velocity_representation,
base_position=data.base_position,
base_quaternion=data.base_quaternion,
joint_positions=data.joint_positions,
Expand Down

0 comments on commit 5c89223

Please sign in to comment.