This will use doubles because you don’t specify the constants as float.
Which means it won’t use the FPU as it handles only single precision (without f suffix and with f suffix)
This can slow down the code.
This is wrong, it should be 13.92f (24 * 0.58f) otherwise you do overmodulation.
motor.voltage_limit = 24;
I would also not use velocity control for now, only torque control.
FOC control would be faster, lag compensation will help if you cannot do FOC.
I also shared some of those tips here