View Single Post
  #4   Spotlight this post!  
Unread 17-02-2008, 11:57
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
Re: One joystink drive

Quote:
Originally Posted by Steve_Alaniz View Post
DO you want the explanation of the one joystick formula... how they are derived? It's a bit long winded but not complicated. If that's what you want I can post it.
The function you are showing creates a curve based on the cubic values of the inputs. This makes the joystick less sensitive to start up and more sensitive once the bot is going.
Not sure you can "improve" on the one joystick formulas but you can customize them.
The ramping function that BronxBomber gives just cubics the input. This means that a little push from neutral doesn't move the motors too much. Otherwise, your motors will start moving too quickly too soon.

Next you need to know what Limit_Mix function does. It takes a value and bounds it to be between 2000 and 2254, the subtracts 2000, and returns a value from 0 to 254.

The first call to Limit_Mix is
Code:
int left =  (int)Limit_Mix(2000 + nSpeed + nTurn - 127);
You add 2000 because of the nature of the Limit_Mix function. If p1_x and p1_y are both neutral, then you get 2000+nSpeed+nTurn which is 2254, so you need to subtract 127 to make it 2127 (neutral). Finally, if the y-axis is near 255 (going forward), you want the left wheels forward, so you add nSpeed. If if the x-axis is near 0 (turning right), then nTurn is near 255 so you add nTurn since you want the left wheels going forward as well.

The next call to Limit_Max is
Code:
int right = (int)Limit_Mix(2000 + nSpeed - nTurn + 127);
If both axes are neutral, this becomes 2000+127-127, so you have to add 127 to make it 2127. For the same reason described above, you add nSpeed. And for the opposite reason of above, you subtract nTurn.

I know this was complicated, but does it sort of make sense?