Closed dev10110 closed 9 months ago
Sorry for the delayed response -- I haven't been keeping up with my GitHub notifications it seems. In case you're still working on this (or JAX nan
problems in general), there's the jax_debug_nans
configuration option which can help you root cause the issue. The jax.lax.while_loop
in hj.step
obfuscates things a bit but it's basically just wrapping
hj.time_integration.euler_step(solver_settings, dynamics, grid, time, values, target_time)
which in this case (with that debug option on, running on CPU on my machine) yields a stack trace like
...
File ~/Dropbox/code/hj_reachability/hj_reachability/dynamics.py:43, in hamiltonian()
42 del value # unused
---> 43 control, disturbance = self.optimal_control_and_disturbance(state, time, grad_value)
44 return grad_value @ self(state, control, disturbance, time)
File ~/Dropbox/code/hj_reachability/hj_reachability/dynamics.py:80, in optimal_control_and_disturbance()
78 disturbance_direction = -disturbance_direction
79 return (self.control_space.extreme_point(control_direction),
---> 80 self.disturbance_space.extreme_point(disturbance_direction))
File ~/Dropbox/code/hj_reachability/hj_reachability/sets.py:66, in extreme_point()
65 """Computes the point `x` in the set such that the dot product `x @ direction` is greatest."""
---> 66 return self.center + self.radius * direction / jnp.linalg.norm(direction)
...
FloatingPointError: invalid value (nan) encountered in jit(div)
So basically it's a bug with not-very-careful normalization in the implementation of hj.sets.Ball
, fixed in #8.
oh wow thats awesome! thanks for providing the fix too :)
Hi,
I'm trying to use this library to solve for the backwards reachable tube of an obstacle. I was able to successfully run the
examples/air3d.ipynb
but I am having trouble defining my own system. Things keep going tonan
.The dynamics are $\ddot x = u$ and the objective is to avoid a wall at $x_1 = 1.5$.
Here is my code:
any advice on how to debug this, or where I've gone wrong?