Go to Post It is probable that you will find mroe than a few spotlight worthy phrases or sentences in the following. ;) - sanddrag [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-02-2008, 15:47
bronxbomber92 bronxbomber92 is offline
Registered User
FRC #1551 (Grapes of Wrath)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Naples
Posts: 75
bronxbomber92 is an unknown quantity at this point
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;
}
Can someone explain the concept for turning the joy stick values on each axis into something for each motor?

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   Spotlight this post!  
Unread 16-02-2008, 22:41
cmptrgy412 cmptrgy412 is offline
Robohawks Programmer
AKA: Jacob G
FRC #1985 (Robohawks)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Missouri
Posts: 7
cmptrgy412 is an unknown quantity at this point
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 nTurn and nSpeed will be adjusted based off your ramping.
the left and right values go through a typical 1-joystick function.

Then you just assign those values to your motors.
__________________
  #3   Spotlight this post!  
Unread 17-02-2008, 00:37
Steve_Alaniz Steve_Alaniz is offline
Registered User
FRC #2848 (All Sparks)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 1997
Location: Dallas
Posts: 211
Steve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond repute
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   Spotlight this post!  
Unread 17-02-2008, 11:57
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
Re: One joystink drive

Quote:
Originally Posted by Steve_Alaniz View Post
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.
The ramping function that BronxBomber gives just cubics the input. This means that a little push from neutral doesn't move the motors too much. Otherwise, your motors will start moving too quickly too soon.

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);
You add 2000 because of the nature of the Limit_Mix function. If p1_x and p1_y are both neutral, then you get 2000+nSpeed+nTurn which is 2254, so you need to subtract 127 to make it 2127 (neutral). Finally, if the y-axis is near 255 (going forward), you want the left wheels forward, so you add nSpeed. If if the x-axis is near 0 (turning right), then nTurn is near 255 so you add nTurn since you want the left wheels going forward as well.

The next call to Limit_Max is
Code:
int right = (int)Limit_Mix(2000 + nSpeed - nTurn + 127);
If both axes are neutral, this becomes 2000+127-127, so you have to add 127 to make it 2127. For the same reason described above, you add nSpeed. And for the opposite reason of above, you subtract nTurn.

I know this was complicated, but does it sort of make sense?
  #5   Spotlight this post!  
Unread 17-02-2008, 12:21
bronxbomber92 bronxbomber92 is offline
Registered User
FRC #1551 (Grapes of Wrath)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Naples
Posts: 75
bronxbomber92 is an unknown quantity at this point
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
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


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

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