Go to Post An extra week of driving practice and shakedown outweighs a lot of ooo-shiny. - Billfred [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
  #16   Spotlight this post!  
Unread 18-05-2011, 19:54
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by lineskier View Post
Rotation is handled as plus or minus

Left is y. - x
Right is y+ x

They may be flipped

Once again remember scaling
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
__________________
Reply With Quote
  #17   Spotlight this post!  
Unread 18-05-2011, 21:40
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by kinganu123 View Post
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
well you could do an if > 1 output 1
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
__________________
"Never let your schooling interfere with your education" -Mark Twain
Reply With Quote
  #18   Spotlight this post!  
Unread 19-05-2011, 00:00
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
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
Look at this diagram, and see if you can figure out what the left and right motor speeds should be for the red, green, and blue dots. If you can do that, you should be able to design an algorithm to compute the wheel speeds for any joystick position.

Some drivers find this behavior more intuitive.


Attached Thumbnails
Click image for larger version

Name:	reverse arcade.png
Views:	61
Size:	12.0 KB
ID:	10706  

Last edited by Ether : 19-05-2011 at 09:12.
Reply With Quote
  #19   Spotlight this post!  
Unread 19-05-2011, 20:33
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
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
What do you mean by "doesn't work" and "one specific coordinate" ? Please post a couple of example calculations to illustrate the problem you are encountering.


Reply With Quote
  #20   Spotlight this post!  
Unread 19-05-2011, 21:53
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by Ether View Post
What do you mean by "doesn't work" and "one specific coordinate" ? Please post a couple of example calculations to illustrate the problem you are encountering.

I assume it has something to do with the math being done. If you pass a value >1 or <-1 i'm pretty sure the robot does nothing.

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
__________________
"Never let your schooling interfere with your education" -Mark Twain

Last edited by mwtidd : 19-05-2011 at 21:56.
Reply With Quote
  #21   Spotlight this post!  
Unread 19-05-2011, 23:43
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by lineskier View Post
I assume it has something to do with the math being done. If you pass a value >1 or <-1 i'm pretty sure the robot does nothing.

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
I was thinking it would be easier in simpleRobot as well however since we use iterative for our robot code he wants me to make one that will work with iterative.
__________________
Reply With Quote
  #22   Spotlight this post!  
Unread 19-05-2011, 23:48
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by Ether View Post
What do you mean by "doesn't work" and "one specific coordinate" ? Please post a couple of example calculations to illustrate the problem you are encountering.

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.
It looks pretty inefficient but without trig i dont think theres another way to do it.
__________________
Reply With Quote
  #23   Spotlight this post!  
Unread 19-05-2011, 23:54
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 lineskier View Post
arc estimators will have to be coded up as only standard sin cos and tan are supported
Not sure what you mean by the above. Java, C++, and LabVIEW all support the atan2 function.


Quote:
Originally Posted by lineskier View Post
My interest has been peaked by approaching the arcade drive similar to a mecanum by using arc functions.
There's nothing wrong with exploring that, it's a great way to learn. But what is the basis for the following statements:

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.
Reply With Quote
  #24   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
  #25   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
  #26   Spotlight this post!  
Unread 20-05-2011, 15:38
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by Ether View Post
Not sure what you mean by the above. Java, C++, and LabVIEW all support the atan2 function.




There's nothing wrong with exploring that, it's a great way to learn. But what is the basis for the following statements:

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




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.)
__________________
"Never let your schooling interfere with your education" -Mark Twain
Reply With Quote
  #27   Spotlight this post!  
Unread 20-05-2011, 15:45
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by lineskier View Post
How do you access atan2? Its not included in the stripped down Math util.
http://www.chiefdelphi.com/forums/sh...ght=atan2+java
Reply With Quote
  #28   Spotlight this post!  
Unread 20-05-2011, 16:23
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 lineskier View Post
How do you access atan2? Its not included in the stripped down Math util.
See Joe's post.

Quote:
A perfect arcade drive would map every point within a circle to a set of motor outputs.
The joystick makes a square, not a circle. The algorithms mentioned here map every point in the square to a set of left/right motor outputs.


Quote:
Using trig you can program for every case using one formula.
You don't need trig to do this.


Quote:
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.
FR = -Y -X -Z

FL = -Y +X +Z

RR = -Y +X -Z

RL = -Y -X +Z

How does trig make the above any easier ?


Quote:
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.)
How does using trigonometry make the above mec code any "cleaner", or "more efficient"? The above code is kinematically correct, even after normalization.



Reply With Quote
  #29   Spotlight this post!  
Unread 20-05-2011, 17:33
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by Ether View Post
See Joe's post.



The joystick makes a square, not a circle. The algorithms mentioned here map every point in the square to a set of left/right motor outputs.




You don't need trig to do this.




FR = -Y -X -Z

FL = -Y +X +Z

RR = -Y +X -Z

RL = -Y -X +Z

How does trig make the above any easier ?




How does using trigonometry make the above mec code any "cleaner", or "more efficient"? The above code is kinematically correct, even after normalization.


thanks for the feedback.

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 )
__________________
"Never let your schooling interfere with your education" -Mark Twain
Reply With Quote
  #30   Spotlight this post!  
Unread 20-05-2011, 20:13
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 lineskier View Post
The way you solve the grid seems to be a case statement
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:
Personally I would rather have one equation that gets the value based on heading and magnitude.
If that's your personal choice I cannot argue. But what "one equation" are you referring to? To get heading and magnitude, you need two equations right there. Then you have to calculate the wheel speeds from those.


Quote:
But i guess we approach the joystick from 2 different views: a square vs a circle. I believe both approaches to be correct.
I also believe both approaches are correct.


Quote:
approaching it as a square requires normalization where as approaching it as a circle does not
If your X,Y values are (1,1) then your magnitude calculation will give 1.4 and you will need to clip or normalize... unless you aren't using the magnitude but converting it back to X and Y values... in which case I'm puzzled why you converted them to polar in the first place.

Would you be willing to post your code ? I'd like to understand better what you are saying.



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