Go to Post FIRST itself is simply a mechanism, not the real goal. - msd [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 22-03-2008, 23:09
starsROBOTICS starsROBOTICS is offline
Registered User
FRC #2276 (S.T.A.R.S)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2006
Location: texas, houston
Posts: 44
starsROBOTICS is on a distinguished road
control all driving with one joystick

does anyone know how to program the robot to drive with one joystick
  #2   Spotlight this post!  
Unread 22-03-2008, 23:19
team2061's Avatar
team2061 team2061 is offline
Gilberto Gonzalez
AKA: team 2061 captain/mechanical
FRC #2061 (PIONEERS)
Team Role: Leadership
 
Join Date: May 2007
Rookie Year: 2007
Location: Las Vegas
Posts: 85
team2061 will become famous soon enoughteam2061 will become famous soon enough
Re: control all driving with one joystick

Depends, what program are you using? if your using easyC just change the programming from tank to arcade
__________________
2007 Las Vegas Highest Rookie Seed Award
2007 Las Vegas Regional Quater-Finalist
2007 Las Vegas Best Rookie Award provided by team 1547 Where's Waldo
2007 Las Vegas Regional Rank 7 of 51 teams, 2nd Seed

  #3   Spotlight this post!  
Unread 23-03-2008, 00:02
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: control all driving with one joystick

It would also depend on your drivebase. Are you using:
4wd
6wd
Tank Tread
Ackermann
4 wheel 90 offset Omni
3 wheel 120 offset Omni (Kiwi)
Swerve/Crab (4 rotateable pods)
Mecanum
1565-esque Linkage Drive
etc
  #4   Spotlight this post!  
Unread 23-03-2008, 00:22
starsROBOTICS starsROBOTICS is offline
Registered User
FRC #2276 (S.T.A.R.S)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2006
Location: texas, houston
Posts: 44
starsROBOTICS is on a distinguished road
Re: control all driving with one joystick

Quote:
Originally Posted by 1075guy View Post
It would also depend on your drivebase. Are you using:
4wd
6wd
Tank Tread
Ackermann
4 wheel 90 offset Omni
3 wheel 120 offset Omni (Kiwi)
Swerve/Crab (4 rotateable pods)
Mecanum
1565-esque Linkage Drive
etc
i am using the 2wd on arcade.
  #5   Spotlight this post!  
Unread 23-03-2008, 00:59
programMORT11
 
Posts: n/a
Re: control all driving with one joystick

kevin's code has a limit_mix function by default, so i'd think that you could just use that ... just assign your drive motor pwm's to the value returned by limit_mix
  #6   Spotlight this post!  
Unread 23-03-2008, 10:28
starsROBOTICS starsROBOTICS is offline
Registered User
FRC #2276 (S.T.A.R.S)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2006
Location: texas, houston
Posts: 44
starsROBOTICS is on a distinguished road
Re: control all driving with one joystick

Quote:
Originally Posted by programMORT11 View Post
kevin's code has a limit_mix function by default, so i'd think that you could just use that ... just assign your drive motor pwm's to the value returned by limit_mix
i dont know what that means.
  #7   Spotlight this post!  
Unread 23-03-2008, 12:59
tajmorton tajmorton is offline
Registered User
FRC #0847 (PHRED)
Team Role: College Student
 
Join Date: Nov 2007
Rookie Year: 2008
Location: Philomath, OR
Posts: 10
tajmorton is a jewel in the roughtajmorton is a jewel in the roughtajmorton is a jewel in the roughtajmorton is a jewel in the rough
Send a message via AIM to tajmorton
Re: control all driving with one joystick

What are you using to program your robot? easyC, the default code, WPILib...?

This year we experimented with two different drive modes: arcade mode and RC-Car style drive (two joysticks, one for forward/backward and one for steering).

If you're using WPILib or easyC, arcade mode for 2 wheel drive is fairly easy to do. I don't have experience with easyC, but with WPILib/MPLab, you need to call Arcade2() function in your OperatorControl(). Unfortunately, I appear to have lost the code that I used for it, but check the docs (page 41) for more information. Basically, you just need to pass Arcade2 the joystick port you're using (PORT_1, PORT_2, etc), the axis of the joystick (X_AXIS, Y_AXIS), the PWM ports that your victors are plugged into (1, 2, etc), and if either your left or right motor is inverted (1=inverted, 0=not, I think).

If you're not using WPILib, you can still do the mixing of the joysticks manually and achieve the same result. This is what we ended up doing because we wanted more control over how sensitive the joysticks were (and so we could use a gyro to keep our bot driving in a straight line).

Our final code worked something like this:
  1. Read Joystick Values
  2. Processed the joystick values through a function that mixed the X and the Y into PWM values for our 2 motors
  3. Sent the motor values to the PWMs

This is what our code that processes joystick values into motor values sort of looks like:
Code:
/* OurDrive
 * Takes joystick x and y and converts into motor values. 
 * Then drives motors.
 * WARNING: Unlike the numbers you get from the joysticks,
  x and y are signed (-127 - 127). Also, the x val is expected to
  go from -127 (full left) to 127 (full right). Make sure you convert
  the joystick vals to signed and multiply x by -1.
*/
void OurDrive(int x, int y) {
	int rm, lm; // values to send to motors
	if ((x==0) && (y==0)) { //not going anywhere
		rm=0;
		lm=0;
	}
	else if (x==0) { //driving straight
		rm = lm = y;
	}
	else if (y==0) { //spin turn
		rm=(x*-1)/2;
		lm=x/2;
	}
	else if (x<0 && y>0) {//forward left,, y pos & x neg
		if (y-x > 127){//turn by decrease
			rm= y;
			lm=y+x;
		}
		else{//turn by increase
			rm=y-x;
			lm=y;
		}
	}
	else if (x<0 && y<0) {//back left, y neg & x neg
		if (y-x < -127) { //turn by decrease
			rm=y-x;
			lm=y;
		}
		else { //turn by increase
			rm=y;//drive backwards
			lm=y+x;//add neg x to neg y, lm goes back faster
		}
	}
	else if (x>0 && y>0) {//forward right, y pos & x pos
		if (y+x>127) {//turn by decrease
			lm = y;
			rm = y-x;
		}
		else {//turn by increase
			lm = y+x;
			rm = y;
		}
	}
	else if (x>0 && y<0) {//back right, y neg & x pos
		if (y-x<-127){//turn by decrease
			rm= y;
			lm=y+x;
		}
		else {//turn by increase
			rm=y-x;
			lm=y;
		}
	}
	
	/* now, drive your motors with the PWM values of lm and rm. In WPILib, you use Motors(lm,rm);
	Make sure you convert the numbers to unsigned if you drive the PWMs directly */
}
Now, just read the x and y axis from the same joystick and send it to the OurDrive() function. You will probably want to process the joystick variables somehow to make the drive more controllable. We gave the drivers the option of dividing by 4 or 6 (selectable by pressing a button on a joystick) to make for a fairly controllable robot.

Good luck! If you have any other questions, please ask!
- Taj
  #8   Spotlight this post!  
Unread 23-03-2008, 13:03
T3_1565 T3_1565 is offline
Registered User
AKA: Twitch Drive Designer
FRC #1360
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: Burlington, Ontario
Posts: 855
T3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant future
Send a message via MSN to T3_1565
Re: control all driving with one joystick

Quote:
Originally Posted by 1075guy View Post
It would also depend on your drivebase. Are you using:

1565-esque Linkage Drive
Bwaha, we are on our drive system class

And for the record we only use one joystick, only ever have used one joystick

I think we use blend functions to drive it with one joystick.

Drive foreward: all wheels turn foreward
Drive backward: all wheels turn backwards
Turn left: left wheels turn back, right wheels turn foreward
Turn right: left wheels turn forward, right wheels turn back

Those are the extremes, and then we set up a blend function (not sure if it something we made or not though) to blend the extremes together for any other joystick position.

For the record, I am not the programmer, that all I know about, and I have heard the term blend function so many times from them while they work on the drive program, so it must be important!!

best of luck!!
  #9   Spotlight this post!  
Unread 23-03-2008, 13:16
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
Re: control all driving with one joystick

Quote:
Originally Posted by T3_1565 View Post
Those are the extremes, and then we set up a blend function (not sure if it something we made or not though) to blend the extremes together for any other joystick position.
for the record, yes, we made it. the best example i've seen is in the IFI 2007 default code (NOT kevin watson 2008 code). in user_routines.c, look for the limit_mix() function as where as where it is called. that's basic tank drive. now, if you're like me, that's way too complicated. simplify it. make the right side wheels and the left side wheels the actual joystick value, then blend (add to) the x-axis joystick values to what the wheels are already doing.

EX.

pwm01=pwm02=p1_y; //right wheels forward with the joystick
pwm03=pwm04=flip(p1_y); //flip() simply makes 255 into 0, and so on

pwm01=pwm03=blend(pwm01,p1_x); //add p1_x to what pwm01 is already doing
pwm03=pwm04=blend(pwm03,flip(p1_x)); //same with other side.


of course, this is very simple. when you realize that the KOP joysitcks arent the bast things to use and have a lot of error, you'll want to make a function that returns if it's around a certain value, say, 127 perhaps?

good luck!
__________________


  #10   Spotlight this post!  
Unread 23-03-2008, 14:43
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: control all driving with one joystick

Quote:
Originally Posted by T3_1565 View Post
Bwaha, we are on our drive system class
Well, its unique enough that it would require some fancy code to make it work so nice.
  #11   Spotlight this post!  
Unread 23-03-2008, 18:43
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
Re: control all driving with one joystick

Quote:
Originally Posted by 1075guy View Post
Well, its unique enough that it would require some fancy code to make it work so nice.
not to give away our secret, but it's remarkable similar to what i described in my earlier post on how basic one joystick drive works.....
__________________


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
We need help with joystick control Team ICE #1611 Control System 4 24-01-2005 15:57
One Joystick Control KWalsh Programming 4 24-02-2004 17:53
problem with joystick buttons (top left one) Richomundo Programming 5 15-02-2004 17:16
how do i control a piston with a joystick Ryan Foley Programming 2 27-05-2003 17:13
Control system with one joystick(or two) CharlieWilken Technical Discussion 3 04-02-2002 09:20


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

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