![]() |
Equation for joystick input to Talons
hello all, we currently have decided to look into tweaking the operator controls of driving the robot. we currently have the joystick to Talon equation as a linear equation: y=x. What the joysticks get is sent to the talons. Each get values between -1 and 1. I'm sure you know this. y is what the Talons receive and x is the joystick input. What we're looking for is an equation that starts out slow, but once you get x to be around .4 to .6, y should be roughly equal to the x value. Past that, the y value should rapidly increase until you reach where x is around .75 or .8, where it should become very close to 1.
Example point table: x,y 0,0 .1,.005 .5,.5 .6,.8 1,1 I know it may not be much, but I am also wondering what you may have used. this isn't really an issue with sensitivity, we are just looking to drive a little more slowly when the joysticks are lightly touched, but once they get past .6 or .7, drive very closely to full power if not full. I understand we can do this with simple if statements, but an equation would make it... "flow"... much better. Thank you for your help :) |
Re: Equation for joystick input to Talons
|
Re: Equation for joystick input to Talons
You could use an interpolation table.
Basically, you make a table like you already made, and the software linearly interpolates between the points. Super easy to write, calibrate, etc. I wrote a LV VI to do this (it's in the BuzzLib download here). I can try to dig up my C version if anyone wants it. |
Re: Equation for joystick input to Talons
Here is an sketch I drew up, I'm not entirely convinced that if I found it's equation we would use it, but it was my first idea.
http://i.imgur.com/57TuSZw.jpg (ignore the scribble :) ) @ the posted image: yes, i have come across those equations in my searches. i would like something that changes concavity once it reaches roughly .5. nothing extremely fancy like my sketch, but something of the likes. my sketch doesn't reflect this paragraph, btw. i'm probably confusing you all. sorry about that. |
Re: Equation for joystick input to Talons
Quote:
Or I can show you how to do it yourself. |
Re: Equation for joystick input to Talons
Quote:
|
Re: Equation for joystick input to Talons
If you must have an equation, you could type your in->out pairs into Excel, graph them (x vs y), then add a trendline and use the equation.
|
Re: Equation for joystick input to Talons
Quote:
|
Re: Equation for joystick input to Talons
Quote:
|
Re: Equation for joystick input to Talons
http://www.wolframalpha.com/input/?i...nd+%281%2C1%29
Wolfram Alpha can do some magic... try tweaking this around a bit |
Re: Equation for joystick input to Talons
Thank you for that wolframalpha link! I didn't know you could do that. We will definitely be tweaking that. I've found an equation to use for now by means of Excel - y = 0.9703x^5 - 2.673x^4 + 0.3901x^3 + 2.0981x^2 + 0.2075x. It seems to look good and we will be testing it on the drive train soon. Thank you to all your posts! Definitely helped.
|
Re: Equation for joystick input to Talons
If you have even powers in your equation, you will have to take the abs of the input variable and multiply the output by the sign of the input, because you will lose the sign on the even terms but not the odd terms.
An equation with all odd powers would not do that. |
Re: Equation for joystick input to Talons
Yep, I've got that accounted for.
|
Re: Equation for joystick input to Talons
For a basic interpolation given a few points, this should give you an idea. Your particular data points wouldn't produce a perfect equation fitting into ±1 range, but that can be fixed with some scaling. I would really like to know if there's an alternative to doing it this way, though :)
|
Re: Equation for joystick input to Talons
Quote:
|
Re: Equation for joystick input to Talons
y = x^2, and then if (x < 0) y= y * -1?
or y = x^3 Simplest approach. |
Re: Equation for joystick input to Talons
Quote:
Code:
Here is your XY data: |
Re: Equation for joystick input to Talons
If you like using lookup tables (I come from an automotive world where everything is pretty much a table or surface), you can write a routine to do it.
I do it as a two-step process. First, I 'prelookup' the fractional index of the input. Then, I interpolate the output. I have a 2d (1 input 1 output) and 3d (2 input 1 output) interpolation block, you simply use two prelookup blocks for the two inputs. Header (structs): Code:
/*Code:
/*Code:
/*Code:
/*You can then write an interp curve as a pair of arrays, x and z. X must be monotonic (strictly increasing), z does not have to be. It will first find the points of x that bound the given point X and the fraction between them (the prelookup step). Then it finds the corresponding z points and weights them with the fraction, returning Z (output). Surfaces are similar, but you instead have 2 arrays (x and y) and a 2-dimensional array z. The sizes of x and the first dimension of z must match, and the size of y and the second dimension of z must match. The function needs to know the x size to index the array. In this way, you can make some really easily change the response of the curve or surface based on how you want it to be, non-linearly (there is no dependence between x and y as there would be in a multi-variable equation). For more than 3 dimensions, an interpolation is impractical. If you need more dimensions, you can use multiplied factors (curve with a variable as the input which scales the output). |
Re: Equation for joystick input to Talons
If you pre-compute the slope between each pair of points in the XY table and store those in an array, it makes the lookup marginally faster (and the code a lot cleaner). You can do this pre-computation at runtime at power-up, or after loading a table into memory from a config file. Once you've got a table that you're pretty sure won't need to be tweaked or tuned, you can do the pre-computation offline and hard-code the coefficients into the lookup routine (as was done in my previous post - I have an app that does this, to avoid human error). |
Re: Equation for joystick input to Talons
If using LV, the interpolate function in the array palette accepts an array of XY pairs that are your control points. You can then pass in the fractional index and it will perform the search/interp approach.
Be sure the array is sorted, though. Greg McKaskle |
| All times are GMT -5. The time now is 22:01. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi