Go to Post FRANK, YOU'RE THE MAN. - Libby K [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-05-2011, 00:30
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by kinganu123 View Post
For example, i was trying to figure out how i would get the left motors to stay off and the right motors to stay full on when the joystick is at teh top left corner(X,Y) = (-1,1), and see if that code works for all quadrants. I used y+X for the left wheels and Math.max(X,Y) for the right wheels. However that algorithim doesnt work for all four quadrants so Ive made a big branching if-else so I have a different algorithim for each quadrant of the cartesian plane and another if else for if the joystick is on the x or y axis

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.
Reply With Quote
  #2   Spotlight this post!  
Unread 20-05-2011, 14:48
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
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.



Attached Thumbnails
Click image for larger version

Name:	arcade_compare.png
Views:	133
Size:	24.9 KB
ID:	10712  
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:14.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi