modeld: handle division by zero (#30411)

* modeld: avoid division by zero

* undefined at 0
old-commit-hash: 84d2fa68f7
This commit is contained in:
YassineYousfi 2023-11-08 10:06:30 -08:00 committed by GitHub
parent 32821e0860
commit 66a17a17b8
1 changed files with 1 additions and 1 deletions

View File

@ -92,7 +92,7 @@ def fill_model_msg(msg: capnp._DynamicStructBuilder, net_output_data: Dict[str,
# interpolate to find `t` for the current xidx
current_x_val = plan_x[tidx]
next_x_val = plan_x[tidx+1]
p = (ModelConstants.X_IDXS[xidx] - current_x_val) / (next_x_val - current_x_val)
p = (ModelConstants.X_IDXS[xidx] - current_x_val) / (next_x_val - current_x_val) if abs(next_x_val - current_x_val) > 1e-9 else float('nan')
PLAN_T_IDXS[xidx] = p * ModelConstants.T_IDXS[tidx+1] + (1 - p) * ModelConstants.T_IDXS[tidx]
# lane lines