Skip to content

Commit

Permalink
Use bitwise operators instead of jnp.logical_*
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti committed Oct 23, 2024
1 parent 4742ae4 commit c8d6b53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/jaxsim/api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2027,15 +2027,15 @@ def step(
# Raise runtime error for not supported case in which Rigid contacts and
# Baumgarte stabilization are enabled and used with ForwardEuler integrator.
jaxsim.exceptions.raise_runtime_error_if(
condition=jnp.logical_and(
isinstance(
integrator,
jaxsim.integrators.fixed_step.ForwardEuler
| jaxsim.integrators.fixed_step.ForwardEulerSO3,
),
jnp.array(
[data_tf.contacts_params.K, data_tf.contacts_params.D]
).any(),
condition=isinstance(
integrator,
jaxsim.integrators.fixed_step.ForwardEuler
| jaxsim.integrators.fixed_step.ForwardEulerSO3,
)
& (
data_tf.contacts_params.K
is not None | data_tf.contacts_params.D
is not None
),
msg="Baumgarte stabilization is not supported with ForwardEuler integrators",
)
Expand Down
12 changes: 4 additions & 8 deletions src/jaxsim/integrators/variable_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,10 @@ def reject_step():
params_next,
discarded_steps,
) = jax.lax.cond(
pred=jnp.array(
[
discarded_steps >= self.max_step_rejections,
local_error <= 1.0,
Δt_next < self.dt_min,
integrator_init,
]
).any(),
pred=discarded_steps
>= self.max_step_rejections | local_error
<= 1.0 | Δt_next
< self.dt_min | integrator_init,
true_fun=accept_step,
false_fun=reject_step,
)
Expand Down

0 comments on commit c8d6b53

Please sign in to comment.