You need to find the max
absolute value, since speeds can be +/-.
Let
fr,
fl,
rl, and
rr be the 4 wheel speed commands in the range +/- 1. Then here's the pseudo-code:
Code:
max=fabs(fr);
if (max<fabs(fl)) max=fabs(fl);
if (max<fabs(rl)) max=fabs(rl);
if (max<fabs(rr)) max=fabs(rr);
if (max>1){fr/=max; fl/=max; rl/=max; rr/=max;}