Quote:
Originally posted by EbonySeraphim
Who or what is IFI?
And I don't know what's going on with either your or rbayer's algorithms. I need to know what those variables are/mean.
|
IFI is Innovation First Inc. (That's the company that makes the control systems for FIRST.)
Both Rob's and my code "smooth out" the joystick input. I think Rob gave a fairly understandable explanation of what the code accomplishes, so I assume what you want to know is how it accomplishes it.
In my code, newJoystick is the joystick value just read in, and prevJoystick is the "filtered" joystick calculated the last time through the loop. DIVISOR is an arbitrary number. In this case, I chose 100 because people are used to thinking in percents. GAIN is a value that is chosen to produce the desired smoothing.
On each loop, a new filtered joystick value is calculated by summing 70% of the previous value with 30% of the new joystick. (Using the GAIN and DIVISOR from my code snippet.) Does this make sense how it will smooth out the response to rapid joystick changes?
Again, GAIN must be less than (or equal to) DIVISOR. If GAIN equals DIVISOR, then no smoothing will occur because 100% of the new value will be added to 0% of the previous value. If GAIN is zero, then the filtered value will never change.
Now, one thing I left out of my snippet, is that if the new filtered value is within 10 of 127, I set it to 127. This keeps rounding errors from preventing the filtered joystick from ever returning to neutral.
Any questions?
