Replace UT hardcoded Search Windows logic
At present, the UT Search Windows algorithm contains fragile and not understood logic. We should either better document what it does and make it more resilient, or replace / remove it altogether. Concretely, this issue refers to the following bits of code:
- Fudge factors in
calculate_windows
(the assert was commented out and replaced by anif
statement in this MR:
// TODO: Understand and fix this logic
// -- This is hardcoded, so faster
// -- If you ever change the Table in the magnet tool, this will be wrong
const float absSlopeY = fabsf(velo_state.ty);
int index = static_cast<int>(absSlopeY * 100 + 0.5f);
// assert(3 + 4 * index < UTMagnetTool::N_dxLay_vals);
if (3 + 4 * index >= UTMagnetTool::N_dxLay_vals) {
index = 2 + 4 * index;
}
const float normFact[4] {
fudge_factors[4 * index], fudge_factors[1 + 4 * index], fudge_factors[2 + 4 * index], fudge_factors[3 + 4 * index]};
- The odd 500:
// -- this 500 seems a little odd...
// to do: change back!
const float invTheta = min(500.0f, 1.0f / sqrtf(velo_state.tx * velo_state.tx + velo_state.ty * velo_state.ty));