|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
Re: How to go about making tankDrive and ArcadeDrive methods
That doesnt work for moving the joystick to the corners or towards them. thats the hardest part of arcade and ive been trying a bunch of algorithims but none of them can be used for more than one specific coordinate
|
|
#17
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
or a divide by 2 those should work somewhat. the best case would be to use trig even for an arcade drive to ensure max values |
|
#18
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
Some drivers find this behavior more intuitive. Last edited by Ether : 19-05-2011 at 09:12. |
|
#19
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
|
|
#20
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
Also knowing whether or not iterative or simple robot are being used is helpful too. I prefer simple robot as I like to have control over initialization and my loops. My interest has been peaked by approaching the arcade drive similar to a mecanum by using arc functions. however arc estimators will have to be coded up as only standard sin cos and tan are supported Last edited by mwtidd : 19-05-2011 at 21:56. |
|
#21
|
|||
|
|||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
|
|
#22
|
|||
|
|||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
It looks pretty inefficient but without trig i dont think theres another way to do it. |
|
#23
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
Quote:
the best case would be to use trig even for an arcade drive to ensure max values programming a mec via trig is a lot easier than doing it without it Last edited by Ether : 20-05-2011 at 00:22. |
|
#24
|
||||
|
||||
|
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. |
|
#25
|
||||
|
||||
|
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. |
|
#26
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
How do you access atan2? Its not included in the stripped down Math util. A perfect arcade drive would map every point within a circle to a set of motor outputs. Using trig you can program for every case using one formula. Same is true for the mecanum drive. By knowing the resulting vector and magnitude you want, you can program a whole mec drive with a couple calculations. The code would be a lot cleaner and more efficient, as every point on the circle formed by the joystick would map to a distinct ideal set of motor outputs. (as opposed to using a scaling algorithm.) |
|
#27
|
||||||
|
||||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
|
|
#28
|
|||||
|
|||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
Quote:
Quote:
Quote:
FL = -Y +X +Z RR = -Y +X -Z RL = -Y -X +Z How does trig make the above any easier ? Quote:
|
|
#29
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
I guess if you approach the js as a square, you are def right. I personally always approach the joystick as a circle as the points you can get on a joystick can be easily mapped to either a circle or a square. The way you solve the grid seems to be a case statement. Personally I would rather have one equation that gets the value based on heading and magnitude. Again your algorithm certainly solves the problem well and I do not believe it would have any dead spots. But i guess we approach the joystick from 2 different views: a square vs a circle. I believe both approaches to be correct. approaching it as a square requires normalization where as approaching it as a circle does not (unless we start looking at mecanum where factoring in rotation requires normalization ) |
|
#30
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
No, its not a case statement. It's simply this:
L = Y+X R = Y-X I can't imagine anything simpler. It works for all 4 quadrants. No case statement is necessary. Quote:
Quote:
Quote:
Would you be willing to post your code ? I'd like to understand better what you are saying. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|