Go to Post Doughnuts would probably be a pretty good alternative to churros. However, that could be open to debate. - Calvin Hartley [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #28   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,102
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
 


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:19.

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