|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#28
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
Try this: Use L=Y+X and R=Y-X. Then limit L and R to the range -1..+1. Spoiler hint at bottom. If you do this, you should get these values: Code:
X Y L R 0 1 1 1 1 1 1 0 1 0 1 -1 1 -1 0 -1 0 -1 -1 -1 -1 -1 -1 0 -1 0 -1 1 -1 1 0 1 The above table matches this diagram. If the above table is not the result you are seeking, post a table showing the result you want. Warning: spoiler follows: Hint: for limiting (clipping), do this: if(L>1) L=1; else if(L<-1) L=-1; if(R>1) R=1; else if(R<-1) R=-1; instead of clipping, you could normalize instead. you'll still get the same table as above, but intermediate joystick results will be slightly different: max=fabs(L); if(fabs(R)>max) max=fabs(R); if(max>1){ L/=max; R/=max;} if you want to get the exact same results as the WPI library functions for all intermediate joystick settings, a slightly different algorithm will be necessary... but still no trig required. Last edited by Ether : 20-05-2011 at 01:11. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|