|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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. |
|
#2
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
See attached chart. The first column is for the simple L=Y+X, R=Y-X with normalization. The second column is the same as the first except it uses clipping instead of normalization. The third column is a slightly (very slightly) more complicated algorithm which I believe gives the same results as what you get from the WPI library (and may indeed even be mathematically identical... I haven't checked). The first 8 rows of the chart are the values around the perimeter of the large square in this diagram, starting at the top center and going around the square clockwise. Notice that all three algorithms give the same values for these points. The remaining rows show the outputs for intermediate joystick values. The three algorithms differ somewhat for these inputs. None of these algorithms uses any trigonometry. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|