Go to Post This isn't an engineering fair and demonstration, it's FRC. Defense is part of the game. You can't expect a good FRC team to just sit there and get clobbered by a full-court shooter; they're going to engineer a solution to the problem. - Kevin Sevcik [more]
Home
Go Back   Chief Delphi > CD-Media > White Papers
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

photos

papers

everything



joystick sensitivity (gain) adjustment

Ether

By: Ether
New: 22-12-2010 10:07
Updated: 05-06-2014 09:35
Total downloads: 4439 times


12/22/2010 Vary the joystick (or any signal which has range -1 to +1) response curve from linear (y=x) to cubic (y=x^3) or anywhere in-between.

12/27/2010 updated to 2-parameter function with tunable inverse deadband

06/05/2014 added piecewise linear gain shaping alternative, with tunable constants a b c

Attached Files

  • gif Figure1

    sensitivity adjustment.gif

    downloaddownload file

    uploaded: 22-12-2010 10:08
    filetype: gif
    filesize: 11.76kb
    downloads: 1954


  • txt gain adjustment

    sensitivity adjustment.txt

    downloaddownload file

    uploaded: 22-12-2010 10:10
    filetype: txt
    filesize: 1.41kb
    downloads: 1265


  • pdf 12/27/2010 revised 2-parameter version with inverse deadband

    2parm-b.pdf

    downloaddownload file

    uploaded: 27-12-2010 17:55
    filetype: pdf
    filesize: 19.56kb
    downloads: 713


  • png piecewise linear joystick gain shaping with inverse deadband

    Joystick_Gain_Shaping.png

    downloaddownload file

    uploaded: 05-06-2014 09:23
    filetype: png
    filesize: 27.32kb
    downloads: 505



Recent Downloaders

  • Guest

Discussion

view entire thread

Reply

22-12-2010 23:34

JesseK


Unread Re: paper: joystick sensitivity (gain) adjustment

No dead band?



23-12-2010 06:24

Roger


Unread Re: paper: joystick sensitivity (gain) adjustment

I had fiddled with this off and on years before, but never really worked it out properly or had the time (or a spare robot) during build season. It's nice to see it formalized and posted here.

Just to make it clear (or correct me if I'm wrong), the X and Y are not the actual joystick numbers from the X and Y axis (eg, in y = x^3, axis x number doesn't produce axis y number), but the input and output from each direction, so really you should have two formulas:

AxisX_output = AxisX_input ^ 3
AxisY_output = AxisY_input ^ 3

The deadzone or band would be a separate calculation (at least programming-wise); a simple "if input is between -0.2 and +0.2 then Y= 0". Whilst doing it all at once would be elegant, it would be a nightmare to debug. Though looking at the graph for f(x)=x^3, in all practicallity the robot motors might not overcome robot weight at all under +/-0.3.

I wonder what the effect would be if a<0? That is, more power near zero (to overcome the robot weight) and leveling off at higher speeds.

In practice this would have to be adjusted to each individual robot; even similar robots (a prototype and competition robot for example) would have different results. Also adjust to the driver, as different drivers like different reactions. If the driver doesn't notice it, then it works!



23-12-2010 07:39

Ether


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by JesseK View Post
No dead band?

Not sure what you mean. You can easily add additional deadband if you wish, but for values of "a" near 1, you may not need to.





23-12-2010 07:59

Ether


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Roger View Post
I had fiddled with this off and on years before, but never really worked it out properly or had the time (or a spare robot) during build season. It's nice to see it formalized and posted here.

Just to make it clear (or correct me if I'm wrong), the X and Y are not the actual joystick numbers from the X and Y axis
Correct. The X and Y are general variables. You can use this approach for any signal, not just the inputs from a joystick. For a 3-axis joystick, if you wanted to independently adjust the sensitivity for each axis, it would look like this:

X' = a1*X^3 + (1-a1)*X

Y' = a2*Y^3 + (1-a2)*Y

Z' = a3*Z^3 + (1-a3)*Z


Quote:
...looking at the graph for f(x)=x^3, in all practicallity the robot motors might not overcome robot weight at all under +/-0.3.
Yes, at higher values of the "a" parameter, you may not need to add deadband.


Quote:
I wonder what the effect would be if a<0? That is, more power near zero (to overcome the robot weight) and leveling off at higher speeds.
Higher gain near zero, lower gain at higher commands. Not recommended under normal circumstances. See the added purple lines in the attached graph*. Also, you'd have to add logic to constrain the output to the range -1/+1.


Quote:
In practice this would have to be adjusted to each individual robot; even similar robots (a prototype and competition robot for example) would have different results. Also adjust to the driver, as different drivers like different reactions.
Yes, that's the idea.


*for some reason this thread does not allow me to attach the graph



23-12-2010 17:05

Tom Line


Unread Re: paper: joystick sensitivity (gain) adjustment

We take a somewhat different approach.

We use four linear equations (y=mx+b). First, we test our robot. So far, every robot we have built has been skid-steer. This means that there is an appreciable amount of motor force that it takes to break the robot into a skid to turn. Utilizing a control on the dashboard, we watch the values required to break it free using only one side. This is the B-intercept of our equation, so that the instant you move the joysticks out of the controller's preprogrammed deadband, you have enough power to turn the robot at the slowest possible speed.

So we use one equation from 0 to about 80% power. This portion has a gentle slope. After that, the slope goes from that point up to 1 (maximum joystick), 1 (maximum motor output). The nice part is that we only need to enter two values into our custom VI. The "B" y-intercept value that the drivetrain manages to start turning the robot at, and the intersection point of the two slopes.

For instance, if you were to graph it, the positive domain of the joystick would have these x,y points:

(X,Y)
(0,0.2)
(0.7,0.7)
(1,1)

I'm trying to attach a picture, but it doesn't appear I can do so in this forum.



23-12-2010 17:09

Ether


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Tom Line View Post
I'm trying to attach a picture, but it doesn't appear I can do so in this forum.
Does anybody know why this is, and can it be corrected? I also had the same problem: I wanted to attach a graph to a previous post in this thread but was not able to.





26-12-2010 23:26

Jogo


Unread Re: paper: joystick sensitivity (gain) adjustment

Really like the idea of that use of throttle.

Out of curiosity, is there anything special about the function x^3+x?

Recently we've used an exponential graph:
Let min = lowest desired value (min>0, usually the highest value at which the robot doesn't move)
Let max = highest desired value (usually, max = 1.0)
Then, output = min(max/min)^joystick value.

This also enables us to vary the max value for the turning axes based on the robot's forward speed.



27-12-2010 10:12

Ether


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Jogo View Post
Really like the idea of that use of throttle.

Out of curiosity, is there anything special about the function x^3+x?
Just to be clear (to avoid possibly confusing other readers), the function is not x^3+x, it is f(x) = a*x^3 + (1-a)*x. This function has some interesting properties.

As mentioned in the paper, when a=0, it becomes f(x)=x. When a=1, it becomes f(x)=x^3. When 0<a<1, it's something in-between. You can vary the "a" parameter to create a curve between f(x)=x and f(x)=x^3 to obtain the desired gain at low joystick settings.

Also, f(x) maps the domain (-1..1) into the range (-1..1) for any chosen value of "a" between 0 and 1, so there's no extra code required to break the domain up into, say, x<0 and x>0.


Quote:
Recently we've used an exponential graph:
Let min = lowest desired value (min>0, usually the highest value at which the robot doesn't move)
Let max = highest desired value (usually, max = 1.0)
Then, output = min(max/min)^joystick value.
Clever. I like it.

If you want to add a Y-intercept to the f(x) function, you can do it like this:

Code:
g(x) = b + (1-b)*[a*x^3 + (1-a)*x]  for x>=0

g(x) = -b + (1-b)*[a*x^3 + (1-a)*x]  for x<0
Now you have 2 adjustable parameters: "b" and "a". The "a" parameter still adjusts the gain, and the extra parameter, "b", adjusts the y-intercept.

Interestingly, if you set b=0.2 and a=0.5, you get almost exactly the same curve as your exponential curve with min=0.2.

I have a graph prepared to illustrate this but can't attach it to this post for some reason*. I'll upload it when I get a chance.

Quote:
This also enables us to vary the max value for the turning axes based on the robot's forward speed.
Could you provide some more detail explaining what you mean please.


*if a moderator happens to be reading, would it be possible to change permissions on this thread to allow attaching graphs?




27-12-2010 10:17

EricVanWyk


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Jogo View Post

Out of curiosity, is there anything special about the function x^3+x?
Nope! Pick anything that your drivers are comfortable with.

Selecting a joystick mapping function is one of the best teaching opportunities you have in FRC. There are many right answers, it is open to opinion, it is super easy to prototype, you can objectively compare a bunch of them on a whiteboard, and it answers the questions set forth in this article: http://www.fordham.edu/academics/pro...math/index.asp . That is to say, it might be the first time the students go in the "from problem to math" direction, instead of the "from math to problem" direction.

ax^3+(1-a)x does have a few special properties, see if your students come up with these in their lists of "wants" for their formula:
  • The function is smooth
  • The 1st derivative is smooth
  • It is tunable.
  • The gain is low near 0.
  • ...and high near 1.
  • The gain inflection is always near the middle (.577, per Ether)



27-12-2010 13:36

Jogo


Unread Re: paper: joystick sensitivity (gain) adjustment

@Ether
Cool, will try it with the y-intercept. Really curious if I'll be able to feel a significant difference at different a-values.

When I stated "This also enables us to vary the max value for the turning axes based on the robot's forward speed," I meant that we found at high speeds, a slight tap to the side on the joystick will send the robot flying away. So, for example, when the robot is moving 1.0 (full speed) in the y-direction, then we might only allow the robot to move up to 0.1 in the x-direction. When the robot isn't moving in the y-direction, then we allow the full 1.0 turning speed.

@EricVanWyk
As a student, steering curves was the first time I went from problem->math; it was definitely among my fav. robotics experiences. I will try this with some of the rookie programmers, and maybe my calc teacher



27-12-2010 14:15

Ether


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Jogo View Post
When I stated "This also enables us to vary the max value for the turning axes based on the robot's forward speed," I meant that we found at high speeds, a slight tap to the side on the joystick will send the robot flying away. So, for example, when the robot is moving 1.0 (full speed) in the y-direction, then we might only allow the robot to move up to 0.1 in the x-direction. When the robot isn't moving in the y-direction, then we allow the full 1.0 turning speed.
Well, that makes sense from a physical point of view. For those of us old enough to remember driving cars before the days of power steering, think how hard it was to turn the steering wheel when the car was not moving (like while parallel parking).

To address this problem, you could use the 2-parameter g(x) function, and treat the "b" inverse deadband parameter like a variable instead of a tuning constant. In other words, adjust the value of "b" (for the rotate axis conversion) as a function of speed before running your joystick rotate axis through the g(x) conversion. caveat emptor: I've never tried this.




27-12-2010 15:49

Ether


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Tom Line View Post
We use four linear equations (y=mx+b). First, we test our robot. So far, every robot we have built has been skid-steer. This means that there is an appreciable amount of motor force that it takes to break the robot into a skid to turn. Utilizing a control on the dashboard, we watch the values required to break it free using only one side. This is the B-intercept of our equation, so that the instant you move the joysticks out of the controller's preprogrammed deadband, you have enough power to turn the robot at the slowest possible speed.

So we use one equation from 0 to about 80% power. This portion has a gentle slope. After that, the slope goes from that point up to 1 (maximum joystick), 1 (maximum motor output). The nice part is that we only need to enter two values into our custom VI. The "B" y-intercept value that the drivetrain manages to start turning the robot at, and the intersection point of the two slopes.

For instance, if you were to graph it, the positive domain of the joystick would have these x,y points:

(X,Y)
(0,0.2)
(0.7,0.7)
(1,1)
That's a good approach too.

I took the liberty of parameterizing it, to make it tunable on-the-fly.

Here's an implementation written in Delphi:

Code:

if (x>=a) then y := c+(x-a)*((1-c)/(1-a))
else if (x>=0) then y :=b + ((c-b)/a)*x
else if (x>=-a) then y := -b + ((c-b)/a)*x
else y:= -c + (x+a)*((1-c)/(1-a));
The above connects the points (-1,-1), (-a,-c), (0,-b), (0,b), (a,c), and (1,1) with straight line segments.

The three parameters are a, b, and c:
  • "b" is the y-intercept (inverse deadband), and
  • (a,c) are the coordinates of the point at which the slope changes






27-12-2010 18:48

Ether


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by EricVanWyk View Post
Thanks for that link Eric! I found myself saying "Yes!" out loud as I read it.





01-01-2011 10:59

Roger


Unread Re: paper: joystick sensitivity (gain) adjustment

Yesterday I gave this to one of my programmers to put into our LabVIEW code, as a sort of a warm-up exercise. An added bonus was making it a sub-vi to plug into future code.

There is a difference in driving, though perhaps not enough to change a good driver with careful joystick control. We didn't test it fully however.

A suggetion that simplifies changing "a" from rewriting code to letting the driver change it on the fly: use the thumb-thingie on the KOP joystick (it's at the base in the front and is known as axis3). It's range is -1 to +1, but with simple math can be converted to 0 to +1.



01-01-2011 12:44

Ether


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Roger View Post
Yesterday I gave this to one of my programmers to put into our LabVIEW code, as a sort of a warm-up exercise. An added bonus was making it a sub-vi to plug into future code.

There is a difference in driving, though perhaps not enough to change a good driver with careful joystick control. We didn't test it fully however.

Which one did you try? The one with just tunable sensitivity, or the one with both sensitivity and inverse deadband tuning parameters?

If you use the one with 2 tunable parameters, you could use three buttons to tune the two parameters: one button to bump parameter "a" up/down; one button to bump parameter "b" up/down; and a third button to select up/down.





01-01-2011 13:55

Roger


Unread Re: paper: joystick sensitivity (gain) adjustment

Oh dear, I'm way behind, aren't I? We were using the original y = a(x^3) + (1-a)x formula. That "2parm" looks interesting for Monday's programming session.

I think we might be running out of joystick buttons. We've got 2 buttons already for switching gear speed up and down -- yet another parameter in the mix, as "Full cubic" in first gear is really slow.

Another thing I might mention is that we are changing only the "forward/backward" axis of the joystick, and the "left/right" axis is not being changed. (The robot is a standard drive left/right sides.) General thought of the group is that this gives full turning power always.



01-01-2011 17:17

Ether


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Roger View Post
...the "left/right" axis is not being changed...General thought of the group is that this gives full turning power always.
Perhaps this is the result of a misunderstanding. Just to be clear: You would still have "full turning power" if you used this sensitivity adjustment for the turn axis.

Look carefully at the figures and the associated narrative. This filter does not reduce the maximum available output. It just changes the response curve to reduce the gain for small commands. The maximum output of the filter is +/-1 regardless of the values selected for the tuning parameters.

What kind of drivetrain are you using, and what type of driver interface?




01-01-2011 17:35

AustinSchuh


Unread Re: paper: joystick sensitivity (gain) adjustment

This probably should go in another paper, but it helps handling a lot if you get some speed vs PWM data, and then curve fit it so that you can convert the nonlinear response of the Victors to a nicer linear response. I ended up using a 7th order polynomial last year to do that, and it helped quite a bit.



01-01-2011 17:53

Ether


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by AustinSchuh View Post
This probably should go in another paper, but it helps handling a lot if you get some speed vs PWM data, and then curve fit it so that you can convert the nonlinear response of the Victors to a nicer linear response. I ended up using a 7th order polynomial last year to do that, and it helped quite a bit.
Would you be willing to post your data? (Or maybe you already have?)




01-01-2011 18:05

AustinSchuh


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Ether View Post
Would you be willing to post your data?
Sure. I only tested it one direction and duplicated the data as you can see. The data isn't quite as clean as I would have liked, but it's not bad and worked well enough. I exploited the symmetry when I fitted it to avoid getting answers that didn't make much sense.

Code:
# Speed Power	Data on blocks.
0.103448	0.020000
-0.103448	-0.020000
0.252874	0.043000
-0.252874	-0.043000
0.333333	0.059000
-0.333333	-0.059000
0.454023	0.082000
-0.454023	-0.082000
0.517241	0.098000
-0.517241	-0.098000
0.614943	0.145000
-0.614943	-0.145000
0.724138	0.184000
-0.724138	-0.184000
0.793103	0.223000
-0.793103	-0.223000
0.885057	0.363000
-0.885057	-0.363000
0.965517	0.559000
-0.965517	-0.559000
1.000000	0.918000
-1.000000	-0.918000



01-01-2011 20:16

Joe Ross


Unread Re: paper: joystick sensitivity (gain) adjustment

By default, RobotDrive squares the inputs before it outputs the PWM, so you should consider the affects of that on any input adjustments.



01-01-2011 21:44

AustinSchuh


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Joe Ross View Post
By default, RobotDrive squares the inputs before it outputs the PWM, so you should consider the affects of that on any input adjustments.
If you are referring to the data that I provide, that was generated using the victor.Set function, rather than passing it through the RobotDrive.



04-01-2011 11:22

Roger


Unread Re: paper: joystick sensitivity (gain) adjustment

Quote:
Originally Posted by Ether
What kind of drivetrain are you using, and what type of driver interface?
It's our 2009 robot with skid steer/tank drive; see this photo. We're using LabVIEW and the standard KOP joysticks and driver station. A single joystick does the driving. The robot drive has the drill-type gear shifter (1st and 2nd gear only; 3rd gear was too fast for Lunacy's floor.)

Adding the second axis to the formula won't be a problem. It was more of "let's get one working first, then add the second." But now that you wrote it out, it makes sense that full power is always possible. We just ran out of time to do the changes.

This was a perfect project as a warm-up, with just enough learning joystick interfacing, sub-vi creation, and math programming, to get done in an hour then debug and change and test after. Adding the different modes and deciding which is "best" will be fun.

There are also two different drivers that we have to program for, and not for the same time. The first (and obvious) is the high school competition driver, who has practice driving with the robot. The second, more unpredictable, driver is the off-season "carnival" driver, a wanna-drive-the robot seven-year-old that throws the joystick all over the place. The former is easy, the latter we can only slow down the action so the robot doesn't crash too much.



20-06-2014 17:59

jhebbel


Unread Re: paper: joystick sensitivity (gain) adjustment

Sorry to revive a more than dead thread but its really the only relevant thread I could find. Im intrigued by the b + (1-b)*[a*x^3 + (1-a)*x] equation, but also confused, doesnt this need to be formated to solve for x and not y? Has anybody done this yet?



21-06-2014 08:00

jhebbel


Unread Re: paper: joystick sensitivity (gain) adjustment

For anybody else that lands here from Google like I did wondering the similar, The reason I though the equation needed to be formatted to solve for X is I didn't realize this was for inverse deadzone, to calculate for traditional deadzone it is y=G*((x-D)/(1-D))^3+(1-G)*(x-D)/(1-D); Where X is in value, D is Deadzone and G is Gain.



view entire thread

Reply

Tags

loading ...



All times are GMT -5. The time now is 06:27.

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