bldc icon indicating copy to clipboard operation
bldc copied to clipboard

[Utils] Streamline `utils_saturate_vector_2d()`

Open kubark42 opened this issue 3 years ago • 1 comments

There was no need to do the sqrt() unless the absolute magnitude is exceeded.

Passes unit tests but shouldn't be merged until #459 is merged.

kubark42 avatar Mar 25 '22 13:03 kubark42

It looks like the worst case, when saturation is needed, will still take the same amount of time. Also, sqrtf is quite fast on the FPU.

For optimizations like this one it would be good to set up a way to profile how much difference they make. Maybe this can be done by running a test on the STM32 with some build option and plot the result in VESC Tool.

vedderb avatar Mar 25 '22 20:03 vedderb