Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Desensitizing Joysticks (http://www.chiefdelphi.com/forums/showthread.php?t=24613)

bob1million 31-01-2004 19:20

Desensitizing Joysticks
 
My fellow programmers and I have tried many different ways to desensitize our joysticks, but none of ways work very well. Does anyone know a good way to desensitize them?

edomus 31-01-2004 19:47

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by bob1million
My fellow programmers and I have tried many different ways to desensitize our joysticks, but none of ways work very well. Does anyone know a good way to desensitize them?


Why dont you just get new joysticks. very good ones can be found for cheep

WillyC 31-01-2004 20:14

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by bob1million
My fellow programmers and I have tried many different ways to desensitize our joysticks, but none of ways work very well. Does anyone know a good way to desensitize them?

You could make a different "transfer function" for the joystick in the form of a lookup table. For instance, right now the transfer function for joystick input to motor output is purely linear (not including the x and y axis mixing). It's linear in the sense that the motor output is linearly proportional to the joystick deflection from neutral.

You could make a slightly non-linear lookup table to de-sensitize the joystick in whatever region of deflection you want. This is actually what I use this lookup table generator for - to rapidly prototype and test new transfer functions for the joystick.

If you want some help, let me know...

KenWittlief 31-01-2004 20:35

Re: Desensitizing Joysticks
 
how much do you want to back them down?

lots of teams just divide the joystick variable by 2, then add 64 to make 127= center again

or divide it by 4 and add 96 to make 127 = center

you can have this as optional code, with a button or operator switch that lets you switch between normal and "fine tuning" mode of driving.

Gusman1188 31-01-2004 20:47

Re: Desensitizing Joysticks
 
We played around with joysticks for a while trying to desensitize and the only way that we found effective is to just state something like the following
if (p1_y <= 135 && p1_y >= 127)
{
p1_y = 127;
}

if (p1_y >= 119 && p1_y <127)
{
p1_y = 127;
}


We tried this but just decided to buy new ones or use last years.

Vladimir 31-01-2004 21:11

Re: Desensitizing Joysticks
 
Here's how I'd do it... first psuedocode for understanding:

Code:

x1 = p1_x; // get an axis, store it in temp variable
x1 = x1-127; // make 0 = neutral
x2 = abs(x1); // find magnitude from center
x3 = (x2/127) * x1; // create harshly curved value
x4 = (x3+x1)/2; // average curve with real to lessen curve
p1_x = x4+127; // restore neutral to 127 and replace value

then this should actually work and is a lot more concise... it assumes you have an abs( function available, either include a math library or make your own with something like if (x<0) x*=-1; -- I haven't tested this so don't run me over with your robot if it doesn't work off the first try, there may be some casting or something required with this compiler, but it'll at least be close.

Code:

p1_x-=127;
p1_x = ((p1_x*abs(p1_x)/127)+p1_x)/2+127;

Hope this helps some!

-Sean

fox46 31-01-2004 22:20

Re: Desensitizing Joysticks
 
Hmmm... I'm not a programmer, but I think a large hammer would do it! :D

KevinB 01-02-2004 00:47

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by Gusman1188
We played around with joysticks for a while trying to desensitize and the only way that we found effective is to just state something like the following
if (p1_y <= 135 && p1_y >= 127)
{
p1_y = 127;
}

if (p1_y >= 119 && p1_y <127)
{
p1_y = 127;
}

All this could be rewritten as one line:

if ((p1_y <= 135 && p1_y >= 127) || (p1_y >= 119 && p1_y <= 127)) p1_y = 127;

deltacoder1020 01-02-2004 02:55

Re: Desensitizing Joysticks
 
and heck, if readability is your issue, just include the 127 case as well:

Code:

if(p1_y >= 119 && p1_y <= 135) p1_y = 127;

KevinB 01-02-2004 10:40

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by deltacoder1020
and heck, if readability is your issue, just include the 127 case as well:

Code:

if(p1_y >= 119 && p1_y <= 135) p1_y = 127;

Looking back at my statement reminds me of why coding at midnight is bad. :D

KenWittlief 01-02-2004 10:55

Re: Desensitizing Joysticks
 
I dont understand how putting a deadband around 127 will make the joystick less sensitive

in fact, your bot is going to lurch when the joystick is moved just outside the deadband

dividing the joystick variable by two, and then correcting the zero point by adding 64 - makes the full forward or full right... positions of the joystick equal to half forward, or half right... making the entire motion of the joystick less sensitive

and making it easier to make fine control adjustments to the motion of the machine while driving - ie when you want to manuver to capture a ball, or position the robot precisely on the field.

IMDWalrus 01-02-2004 11:08

Re: Desensitizing Joysticks
 
Quote:

Originally Posted by bob1million
My fellow programmers and I have tried many different ways to desensitize our joysticks, but none of ways work very well. Does anyone know a good way to desensitize them?

Expose them to lots of violent movies and video games. :)

ginger 01-02-2004 11:28

Re: Desensitizing Joysticks
 
I think this is related to the threads on PID and motor feedback. Id look there for the best solution.

I would try a simple average function- keep a bufer of the last 10 or so values, add each new one into the buffer, take the average, and send that value to the motor. Remove the oldest value from the buffer.

This should at least smooth out effects of noise and minor hand jiggles.

deltacoder1020 01-02-2004 12:52

Re: Desensitizing Joysticks
 
that, or ramp the output - put in a "max change per cycle" function. also, you might try an exponential function for the joystick, so that it really only opens up at full movement.

WillyC 01-02-2004 12:59

Re: Desensitizing Joysticks
 
1 Attachment(s)
Quote:

Originally Posted by KenWittlief
I dont understand how putting a deadband around 127 will make the joystick less sensitive

in fact, your bot is going to lurch when the joystick is moved just outside the deadband

I've got to agree with Ken on this one. This deadband approach will make the joysticks more sensitive, because the motor output is proportional to the joystick deflection. If you ignore the stick input unless it's greater than 135 or less than 119, then as the stick moves out of the deadband and starts the motor moving, the motor's smallest non-zero speed is even faster than without the deadband. The result will be jerkiness as the bot starts moving.

Ken's solution sounds good, and is obviously more efficient than what I'm about to suggest here. I haven't tried my idea on the bot yet, and I'm a little sketchy about putting a lookup table of any size into the user routine because I don't want to slow it down too much. But here's the principle: make a slightly non-linear lookup table to de-emphasize the stick input near neutral, but not near the max/min. I've attached an example of the kind of curve I'm thinking of. Notice that near 127, it "dumbs down" the stick input to drive the motors slower and make the sticks less sensitive, but near the high or low end of the input it looks almost linear to make the driveability at high speeds feel pretty normal.

Try it out and let me know what you think! Like I said, I haven't tried this on the bot yet...

EDIT: I just changed the .xls to a zipped up .xls.


All times are GMT -5. The time now is 20:03.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi