|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
One joystick drive
Hi,
I'm trying to get something better than the default one joystick drive, but I don't really understand the concept of turning the x and y joystick values into values for each wheel motor (2 motors). I'm planning on doing something along the lines of using a lookup table to make the robot more handlable, using thisa function instead of a look up table: Code:
long ramping (unsigned char ramp)
{
long answer = 0;
answer = ((long)ramp - 127);
answer = ((answer) * (answer) * (answer));
answer = ((answer) / (128 * 128));
answer = (answer) + (127);
return answer;
}
Thanks edit - sorry for the typo in the name of the thread, I can't change it. Last edited by bronxbomber92 : 16-02-2008 at 17:07. |
|
#2
|
|||
|
|||
|
Re: One joystink drive
Sure. What you should end up having is code that looks like this:
Code:
// on our joystick the x values were inverted int nTurn = ramping(128 - p1_x) + 127; int nSpeed = ramping(p1_y - 127) + 127; int left = (int)Limit_Mix(2000 + nSpeed + nTurn - 127); int right = (int)Limit_Mix(2000 + nSpeed - nTurn + 127); // pwm01/pwm02 corresponds to motor PWMs. pwm01 = left; pwm02 = 255 - right; the left and right values go through a typical 1-joystick function. Then you just assign those values to your motors. |
|
#3
|
|||
|
|||
|
Re: One joystink drive
DO you want the explanation of the one joystick formula... how they are derived? It's a bit long winded but not complicated. If that's what you want I can post it.
The function you are showing creates a curve based on the cubic values of the inputs. This makes the joystick less sensitive to start up and more sensitive once the bot is going. Not sure you can "improve" on the one joystick formulas but you can customize them. |
|
#4
|
|||
|
|||
|
Re: One joystink drive
Quote:
Next you need to know what Limit_Mix function does. It takes a value and bounds it to be between 2000 and 2254, the subtracts 2000, and returns a value from 0 to 254. The first call to Limit_Mix is Code:
int left = (int)Limit_Mix(2000 + nSpeed + nTurn - 127); The next call to Limit_Max is Code:
int right = (int)Limit_Mix(2000 + nSpeed - nTurn + 127); I know this was complicated, but does it sort of make sense? |
|
#5
|
|||
|
|||
|
Re: One joystink drive
That makes perfect sense! After running that Limit_Mix logic through my head with the joystick in each direction it's really quite simple
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| one wheel drive | Simon Strauss | Technical Discussion | 11 | 16-11-2005 23:58 |
| One Joystick Drive | mattsavela | Programming | 20 | 19-05-2005 21:28 |
| FIRST's one hour drive | Duke 13370 | Motors | 4 | 25-02-2003 17:29 |
| one stick drive | Hendrix | Programming | 3 | 14-02-2003 20:53 |
| question about one joystick drive programing | james700 | Programming | 13 | 29-01-2003 14:49 |