View Single Post
  #3   Spotlight this post!  
Unread 27-03-2007, 18:25
dpick1055's Avatar
dpick1055 dpick1055 is offline
David Pick
FRC #1739 (Chicago Knights)
Team Role: Alumni
 
Join Date: May 2005
Rookie Year: 2004
Location: Chicago
Posts: 75
dpick1055 is on a distinguished road
Send a message via AIM to dpick1055
Re: Joystick filtering gone horribly wrong...help!

Your actually making it more complicated then you need to with a lookup table. Using a squaring function and some if statements you can get the curved response you want. Here's the code I used on our robot this year.
Code:
        int linput;
	int rinput;
	int loutput;
	int routput;

		if (p1_y < 127)
			{
				linput = 127 - p1_y;
				loutput = 127 - ((linput * linput) / 127);
			}
		if (p1_y >= 127)
			{
				linput = p1_y - 127;
				loutput = ((linput * linput) / 127) + 127;
			}
		
		if (p2_y < 127)
			{
				rinput = 127 - p2_y;
				routput = 127 - ((rinput * rinput) / 127);
			}
		if (p2_y >= 127)
			{
				rinput = p2_y - 127;
				routput = ((rinput * rinput) / 127) + 127;
			}

					pwm15 = 254 - routput;
					pwm13 = loutput;
__________________
Always remember to take your powered wheels off the ground when first testing code. Otherwise you'll end up with holes in the wall like us