Skip to content

Commit

Permalink
Simplify position limit extraction logic
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti committed Nov 13, 2024
1 parent 885c3e6 commit 40d60e3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/jaxsim/api/joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ def position_limit(
"""

if model.number_of_joints() == 0:
s_min = model.kin_dyn_parameters.joint_parameters.position_limits_min
s_max = model.kin_dyn_parameters.joint_parameters.position_limits_max

return jnp.atleast_1d(s_min).astype(float), jnp.atleast_1d(s_max).astype(float)
return jnp.empty(0).astype(float), jnp.empty(0).astype(float)

exceptions.raise_value_error_if(
condition=jnp.array(
Expand All @@ -138,8 +135,12 @@ def position_limit(
idx=joint_index,
)

s_min = model.kin_dyn_parameters.joint_parameters.position_limits_min[joint_index]
s_max = model.kin_dyn_parameters.joint_parameters.position_limits_max[joint_index]
s_min = jnp.atleast_1d(
model.kin_dyn_parameters.joint_parameters.position_limits_min
)[joint_index]
s_max = jnp.atleast_1d(
model.kin_dyn_parameters.joint_parameters.position_limits_max
)[joint_index]

return s_min.astype(float), s_max.astype(float)

Expand Down

0 comments on commit 40d60e3

Please sign in to comment.