Quote:
|
Originally Posted by Bharat Nain
Our robots are a little too fast for anyone other than the driver to control. Since we take our robots out for demos and stuff, I being the programmer would want it to be safe. So I have been trying to come up with a program to drive this thing at half speed when the joystick are at full forward. We can't just divide all the values by 2 because that moves the center from 127 to 63.5. Anybody done such a thing, or can come up with a working program for this? I would appreciate any help
Thanks,
-Bharat
|
Another good way is look up tables. Then you can also set it up so it "ramps" (eg: if you move the joystick 1/2 of the way, it will only bring it up to 1/4 the possible speed, then when you push the joystick all the way, the robot will go up to 1/2 speed (or what have you). The code would look something like this:
Code:
const rom unsigned char mytable[256] = {
56,56,55,55....
};
I wrote a little python script (which I promptly lost) that would generate them for me. There is also an auto-generator
here (but your gonna need M$ excel to open it =\)