Go to Post FIRST, in itself, will not make you an engineer. - RogerR [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #16   Spotlight this post!  
Unread 27-01-2015, 22:06
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: H-Drive Programming

Quote:
Originally Posted by kinganu123 View Post
Yes, exactly this

@kinganu123: Is the following a correct interpretation of what you meant?


Let X be the value of the joystick strafe axis,
in the range 0 to +1 for strafe right.

Let G(X) be your Gaussian taper function, such that G(0)=4 and G(1)=1.

Let Xt(X) be the tapered value of X: Xt(X)=X*G(X).

If so, would you be so kind as to post your G(X) function.


Reply With Quote
  #17   Spotlight this post!  
Unread 28-01-2015, 19:02
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: H-Drive Programming

Our formula is e^(gaussianInput^2/-.18) where the gaussianInput is the polar degrees from 0 to pi where pi/2 is 0, 0 is 1, and pi is -1.
I'm putting the code below, in case what I've typed doesn't make sense, here's the code:
Code:
	centerCurrent = xAxis;
    	 double gaussianInput=angleToGaussianInput(Math.atan2(yAxis, xAxis));
    	 leftCurrent =gaussianConversion(gaussianInput)+rotate;
    	 rightCurrent=leftCurrent-2*rotate;

	private double gaussianConversion(double gaussianInput) {
		return Math.exp(Math.pow(gaussianInput, 2)/(-.18));
	}

	private double angleToGaussianInput(double rad) {
		if(rad>Math.PI)
			rad-=Math.PI;
		return (rad-Math.PI/2.0)/(Math.PI/2.0);
	}
__________________
Reply With Quote
  #18   Spotlight this post!  
Unread 28-01-2015, 23:22
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: H-Drive Programming

Quote:
Originally Posted by kinganu123 View Post
Our formula is...
OK, to see if I'm understanding your formula correctly, can we take a simple numerical example?

Suppose the driver pushes the joystick to Y=1, X=0.5, rotate=0. What will be the "tapered" value of X?


Reply With Quote
  #19   Spotlight this post!  
Unread 29-01-2015, 20:03
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: H-Drive Programming

Oh, sorry, I meant to say that the y-axis is the one that is modified, not the x.
So, x will be .5 and y will be 0.9702, or e^(((atan(1/.5)-pi/2)/pi/2)^2/-.18).
__________________
Reply With Quote
  #20   Spotlight this post!  
Unread 29-01-2015, 22:39
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: H-Drive Programming

Quote:
Originally Posted by kinganu123 View Post
Oh, sorry, I meant to say that the y-axis is the one that is modified, not the x.
So, x will be .5 and y will be 0.9702, or e^(((atan(1/.5)-pi/2)/pi/2)^2/-.18).
I believe you left out a pair of parentheses:

e^(((atan(1/.5)-pi/2)/(pi/2))^2/-.18)


This is quite different from the previous description.

See attachments.

Have you guys driven with this yet? How is it working?


Attached Thumbnails
Click image for larger version

Name:	G(X,Y).png
Views:	21
Size:	24.5 KB
ID:	18051  Click image for larger version

Name:	Yt(X,Y).png
Views:	18
Size:	26.1 KB
ID:	18052  Click image for larger version

Name:	G(X,Y) vs X.png
Views:	12
Size:	31.6 KB
ID:	18054  Click image for larger version

Name:	Yt(X,Y) vs X.png
Views:	12
Size:	22.5 KB
ID:	18055  

Last edited by Ether : 30-01-2015 at 08:45.
Reply With Quote
  #21   Spotlight this post!  
Unread 30-01-2015, 01:15
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: H-Drive Programming

Yes, I didn't realize that he specified the strafe axis, which would result in the confusion.
And we haven't been able to test it yet since the mechanical guys are currently assembling the elevator on the robot, so we're losing a few days on testing and tuning this.
Also, I thought I'd note here that we tweaked the code above, in case anyone else wanted to try our stuff out, because I noticed a slight flaw in getting the y values
Code:
centerCurrent = xAxis;
double gaussianInput=angleToGaussianInput(Math.atan2(yAxis, xAxis));
double scaledGaussianOutput=yAxis*gaussianConversion(gaussianInput)
leftCurrent =scaledGaussianOutput+rotate;
rightCurrent=scaledGaussianOutput-rotate;
__________________
Reply With Quote
  #22   Spotlight this post!  
Unread 30-01-2015, 09:00
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: H-Drive Programming

Quote:
Originally Posted by kinganu123 View Post
Yes, I didn't realize that he specified the strafe axis, which would result in the confusion.
It's not just the axis; the gains are quite different from what was described.

I'm a math enthusiast, so don't take this wrong, but why the complicated function with exponential and inverse trig? Wouldn't a simple linear interpolated 6x6 LUT do the job... and be far more easily tuned to compensate for actual behavior once you've done your testing?



Last edited by Ether : 30-01-2015 at 09:35.
Reply With Quote
  #23   Spotlight this post!  
Unread 30-01-2015, 18:30
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: H-Drive Programming

So we do have a simpler version coded up with some sort of linear adjustment instead of this one (I had some of the other students write that as a backup), but the main reasoning behind this method was to allow y to increase significantly to make up the lost y speed as the driver went at a smaller angle (with respect to the front of the robot).
__________________
Reply With Quote
  #24   Spotlight this post!  
Unread 03-02-2015, 17:16
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: H-Drive Programming


Instead of using arctangent and exponential functions, why not just multiply the X axis by a factor of 4, clip it at 1, and normalize the resulting X,Y pair?


Code:


void adjust(float Xj, float Yj, float *Xa, float *Ya){

	float mag;

	*Ya=Yj;
	
	if (Xj<=-0.25) *Xa=-1; 
	else if (Xj<0.25) *Xa=4.0*Xj;
	else *Xa=1.0;

	// normalize adjusted values:
	mag=sqrt(*Xa**Xa+*Ya**Ya);
	if (mag>1) {*Xa/=mag; *Ya/=mag;}
}
See attached Excel spreadsheet. The 100 tab shows an overview of adjusted XY pairs (cyan cells) for the entire first quadrant. The 25 tab zooms in for a closer look for small joystick values.

The attached plot shows a family of Xa vs Xj curves for Yj=0 to 1.


Or you could make the X gain a function of Yj, like so:

Code:


void adjust(float Xj, float Yj, float *Xa, float *Ya){

	float mag, gain;

        gain=1+3*Yj;

	*Ya=Yj;
	
        *Xa=gain*Xj;
        if (*Xa>1) *Xa=1;
        else if (*Xa<-1) *Xa=-1;

	// normalize adjusted values:
	mag=sqrt(*Xa**Xa+*Ya**Ya);
	if (mag>1) {*Xa/=mag; *Ya/=mag;}
}
See attached plots for Xa vs Xj for Yj=0 to 1
and Ya vs Yj for Xj=0 to 1


Attached Thumbnails
Click image for larger version

Name:	Xa vs Xj  for Yj=0 to 1.png
Views:	6
Size:	17.1 KB
ID:	18138  Click image for larger version

Name:	Xa vs Xj, Yj=0 to 1 (variable gain).png
Views:	8
Size:	48.3 KB
ID:	18139  Click image for larger version

Name:	Ya vs Yj, Xj=0 to 1 (variable gain).png
Views:	6
Size:	17.0 KB
ID:	18140  
Attached Files
File Type: xls XY.xls (47.0 KB, 9 views)

Last edited by Ether : 03-02-2015 at 23:13. Reason: added variable gain option and plots
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:03.

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