|
Re: How do I program a joystick deadband?
Allow me to show you a piece of code my team has used the last three years....
public double deadband(double JoystickValue, double DeadbandCutOff) {
if (JoystickValue<DeadbandCutOff&&JoystickValue>(Dead bandCutOff*(-1))) {
deadbandreturn=0;
}
else {
deadbandreturn=(JoystickValue-(Math.abs(JoystickValue)/JoystickValue*DeadbandCutOff))/(1-DeadbandCutOff);
}
return deadbandreturn;
}
this not only cuts it off at a point, but prevents jumping up to 0.1 after you get past it. it basically smooths the dead band curve. How ever, i would recommend making a algorithm you understand. ((i am still working on understanding this one. lol))
__________________
"you can build a perfect machine out of imperfect parts" -Urza
Last edited by techkid86 : 08-10-2012 at 01:31.
|