Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   joystick sensitivity (http://www.chiefdelphi.com/forums/showthread.php?t=34557)

Team 668 13-02-2005 14:06

joystick sensitivity
 
i have been tampering with the code to make joysticks less sensitive. i cannot figure it out. it either has an error or nothing responds. does any1 kniw the code to make tha joystick less sensitive

Jeff K. 13-02-2005 14:17

Re: joystick sensitivity
 
I'm not really into programming, but I do know from driving the robot that our controls are also really sensitive and sometimes do get stuck so the robot moves by itself after someone has driven it. If you want to make a makeshift fix on your joystick, you can probably take apart the joystick and play around with the springs in the joystick and see if they are better or not after doing that. It might work...it might not...but good luck writing the program...




...Actually...once I think of my method...it seems really stupid...sorry.

Xufer 13-02-2005 14:22

Re: joystick sensitivity
 
Are you working with the white joysticks ? If so the best thing you could do is throw them away and get some new ones. We used 1 of them last year to control our arm and i wished we hadn't. I happen to be both the programmer and the arm operator and i did the best i could to get them some what usable. Anyway here are some possibilities.

What you can do to fix this problem is put a parabola in your joystick code, this makes the beginning movements less sensitive. I think if you look through the white papers, in the programing section you'll find one on adding a parabola.

Other teams have replaced the springs to make the movement less "floppy", in return making them easier to control.

Joshua May 13-02-2005 14:38

Re: joystick sensitivity
 
One thing we did was add in a "deadband" to the center of the joysticks, which has really helped. The code makes use of an absolute value function that we created. Today, we'll also be adding a ramping function to the joysticks just like what was described above, I can get you that code too if you need it.

Code:

#define DEADBAND 10

int abs(int x)
{
  if (x >= 0)
    return x;
  else
    return -x;
}

if (abs((p1_y - 127)) < DEADBAND)
  p1_y = 127;

if (abs((p1_x - 127)) < DEADBAND)
  p1_x = 127;


AIBob 13-02-2005 14:51

Re: joystick sensitivity
 
Quote:

Originally Posted by Joshua May
One thing we did was add in a "deadband" to the center of the joysticks, which has really helped. The code makes use of an absolute value function that we created. Today, we'll also be adding a ramping function to the joysticks just like what was described above, I can get you that code too if you need it.

Code:

#define DEADBAND 10
 
int abs(int x)
{
if (x >= 0)
return x;
else
return -x;
}
 
if (abs((p1_y - 127)) < DEADBAND)
p1_y = 127;
 
if (abs((p1_x - 127)) < DEADBAND)
p1_x = 127;


Here is something similar, only you do not need a seperate function... abs(p1_x) can be replaced with (p1_x && 0x7F), because the last bit is the sign, like so:
Code:

#define DEADBAND 10
if (((((signed int)p1_x-127) && 0x7f) < DEADBAND) p1_x=127;
if (((((signed int)p1_y-127) && 0x7f) < DEADBAND) p1_y=127;


sirbleedsalot 13-02-2005 16:35

Re: joystick sensitivity
 
OK where does this code go into the rest of the default program. Can I put it anywhere in user routines.c or does it have a special place?

AIBob 13-02-2005 16:39

Re: joystick sensitivity
 
Quote:

Originally Posted by sirbleedsalot
OK where does this code go into the rest of the default program. Can I put it anywhere in user routines.c or does it have a special place?

You would place this code right after you read the input data from the operator interface like so:
top of the page, or in an included file:
Code:

#define DEADBAND 10
you may place this in "Default_Routine()" if it is called, right at the beginning:
Code:

if (((((signed int)p1_x-127) && 0x7f) < DEADBAND) p1_x=127;
if (((((signed int)p1_y-127) && 0x7f) < DEADBAND) p1_y=127;

or if you do not call "Default_Routine()", then place the code right after "Getdata(&rxdata);" is called

Ryan M. 13-02-2005 17:02

Re: joystick sensitivity
 
Quote:

Originally Posted by Stonefan5271138
I'm not really into programming, but I do know from driving the robot that our controls are also really sensitive and sometimes do get stuck so the robot moves by itself after someone has driven it. If you want to make a makeshift fix on your joystick, you can probably take apart the joystick and play around with the springs in the joystick and see if they are better or not after doing that. It might work...it might not...but good luck writing the program...

...Actually...once I think of my method...it seems really stupid...sorry.

Actually, your idea is a very good one. We did it last year and this year with great success.

The deadband will solve your problem of the robot not stopping when you let the joysticks return to "center," but it doesn't help with your sensitivity problem. You can go for a full PID controller, but a low pass filter, which is basically just the P of a PID, will probably do the trick. I can get you our code from this year in an hour or two. :)

Alan Anderson 13-02-2005 20:38

Re: joystick sensitivity
 
Quote:

Originally Posted by AIBob
abs(p1_x) can be replaced with (p1_x && 0x7F), because the last bit is the sign,...

Not so. For two reasons, the first of which is very important:

Negative numbers are not stored in sign-magnitude form. They are in "two's-complement" form. The value -1 masked with 0x7F yields a value of 127, a far cry from the expected 1.

(The second reason is that && is a logical operator, giving a true or false result. The arithmetic and is represented by a single &.)

The simplest syntax I know of for an absolute value function uses the ternary if operator. It's cryptic, but effective:
Code:

(value<0?-value:value)

AIBob 13-02-2005 20:44

Re: joystick sensitivity
 
Quote:

Originally Posted by Alan Anderson
Not so. For two reasons, the first of which is very important:

Negative numbers are not stored in sign-magnitude form. They are in "two's-complement" form. The value -1 masked with 0x7F yields a value of 127, a far cry from the expected 1.

(The second reason is that && is a logical operator, giving a true or false result. The arithmetic and is represented by a single &.)

The simplest syntax I know of for an absolute value function uses the ternary if operator. It's cryptic, but effective:
Code:

(value<0?-value:value)

Ok.... for some reason it worked for me in my code though.... but I suppose it will not work for absolute values...
Thanks for letting me know.

probizzle 13-02-2005 21:01

Re: joystick sensitivity
 
Quote:

Originally Posted by Alan Anderson
Negative numbers are not stored in sign-magnitude form. They are in "two's-complement" form. The value -1 masked with 0x7F yields a value of 127, a far cry from the expected 1.

For more information:
http://en.wikipedia.org/wiki/Negativ...tive_in_binary
http://en.wikipedia.org/wiki/Two%27s_complement

h0x4r 16-02-2005 18:45

Re: joystick sensitivity
 
i just decreased the limit mix to the joystick drive, which should be at 2000 when to begin with, so it will move less when u move the joystick, using the normal white joysticks :D


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

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