Go to Post Driving and using the cell phone and taking a picture with it. Where is your Safety Captain? - GaryVoshol [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-04-2011, 22:18
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Switching Drive System While Driving

Odd question but can you change the drive system as you are diving?

something like this:

Code:
if(joystick1.GetRawButton(2)){
myrobot.Tankdrive(joystick1.GetY(), joystick2.GetY());
}
Im asking this because today at our competition our drive didnt want to use menanume drive during parts of the match so i comments out the old drive system and then he wanted mecaume again and it was quite annoying

Any ideas?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-04-2011, 22:20
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Switching Drive System While Driving

If you are using the Logitech Attack 3, I suggest using the "Z". So:
The "Z" is the thing at the bottom where you can push up or down. Its like a knob.


if(joystick1.GetZ() > 0)
{
myrobot.Tankdrive(joystick1.GetY(), joystick2.GetY());
}
else
{
//the other drive
}
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-04-2011, 22:26
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Switching Drive System While Driving

so that you can do it then right?

and how would you switch back to the original drive system

like this?

Code:
if(joystick1.GetRawButton(2)){
myrobot.Tankdrive(joystick1.GetY(), joystick2.GetY());
}
else{
other drive drive
}

else if(joystick1.GetRawButton(3)){
other drive
}
Reply With Quote
  #4   Spotlight this post!  
Unread 02-04-2011, 22:43
Dacilndak's Avatar
Dacilndak Dacilndak is offline
Matt'); DROP TABLE Users; --
AKA: Matthew Haney
FRC #3729 (Red Knights)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Denver, Colorado
Posts: 12
Dacilndak is an unknown quantity at this point
Re: Switching Drive System While Driving

Well, you could do something like

Code:
if (joystick1.GetZ() < 1.0 && joystick1.GetZ() >= 0.33)
{
	// tank drive
}
else if (joystick1.GetZ() < 0.33 && joystick1.GetZ() >= -0.33)
{
	// arcade drive
}
else // if (joystick1.GetZ() < -0.33 && joystick1.GetZ() >= -1.0)
{
	// holonomic drive (?) ... whatever else
}
Ideally, then, in the middle of driving you could turn the Z wheel (towards the bottom of the joystick closest to you, like davidthefat said), thus switching drive modes.

I wouldn't recommend using buttons to switch drive modes, as the change in speed can be sudden and you could tear up your drivetrain if the driver isn't careful and/or you aren't ramping your joystick inputs.
__________________
Team 3729 - Raiders - Programming Team Co-Captain
2011 Colorado Regional Semifinalist
2011 Colorado Regional Rookie All-Star Award
2011 Colorado Regional Highest Rookie Seed Award

Last edited by Dacilndak : 02-04-2011 at 22:45. Reason: Clarification.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-04-2011, 22:52
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Switching Drive System While Driving

couldnt i do something like this so stop the tearing apart?

Code:
if (joystick.GetTrigger()){
myRobot.Drive(0)
tank drive
my thinking is that when you push the trigger it will stop the robot and then it will switch modes that way you do not have to worry about the robot driving while you are switching modes

at least that is what i think you are trying to do
Reply With Quote
  #6   Spotlight this post!  
Unread 02-04-2011, 22:53
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Switching Drive System While Driving

i see what you are talking about now after i read it again couldnt we do the samething on a regular controller
Reply With Quote
  #7   Spotlight this post!  
Unread 03-04-2011, 00:30
Dacilndak's Avatar
Dacilndak Dacilndak is offline
Matt'); DROP TABLE Users; --
AKA: Matthew Haney
FRC #3729 (Red Knights)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Denver, Colorado
Posts: 12
Dacilndak is an unknown quantity at this point
Re: Switching Drive System While Driving

What exactly do you mean by a "regular controller"? The Z-axis wheel is on all of the KOP joysticks.

If you mean just using buttons, then what you seem to be doing there (driving the motor to 0, then using the new drive mode) would certainly work. I would advise, however, adding something like a Wait(0.05); in between the two to allow the robot to come to a bit of a stop or at least slow down - by driving in the new mode immediately, the stop would be basically ignored because you'd be sending it new orders before it had time to stop. It would only stop for a fraction (1/20 in this case) of a second, but it'd really help.

Try doing something like:

Code:
int driveMode;
if (joy1.GetRawButton(4) == 1 && joy1.GetRawButton(3) == 0)		// button 4, not button 3
{
	driveMode = 0;			// flag for tank drive
	drive.Drive(0, 0);		// stop motors
	Wait(0.05);			// let them stop
}
else if (joy1.GetRawButton(4) == 0 && joy1.GetRawButton(3) == 1)	// button 3, not button 4
{
	driveMode = 1;			// flag for arcade drive
	drive.Drive(0, 0);		// stop motors
	Wait(0.05);			// let them stop
}
then later...

Code:
switch (driveMode)
{
case 0:
	drive.TankDrive(joy1.GetY(), joy2.GetY());	// Tank drive
	break;
case 1:
	drive.Drive(joy1.GetY(), joy1.GetX());		// Arcade drive
	break;
default:
	drive.Drive(joy1.GetY(), joy1.GetX());		// Arcade drive (default, no buttons have been pressed)
	break;
}
to do the actual switching process. The above would make it so that if you press button 4, you swap to tank drive mode and stay in it until you press button 3.

Also, you're transmission won't get ripped apart unless you slam the joystick from 1.0 to -1.0 quickly. Still, it's worth putting in safeties like these, since you can't trust your drivers to remember each time .
__________________
Team 3729 - Raiders - Programming Team Co-Captain
2011 Colorado Regional Semifinalist
2011 Colorado Regional Rookie All-Star Award
2011 Colorado Regional Highest Rookie Seed Award
Reply With Quote
  #8   Spotlight this post!  
Unread 03-04-2011, 10:35
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Switching Drive System While Driving

So I should combine a if statement with a casestatment?
Reply With Quote
  #9   Spotlight this post!  
Unread 03-04-2011, 13:00
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Switching Drive System While Driving

tomy, I'm not sure you understand the way a "drive system" works. Are you expecting to call "TankDrive" once and have the robot switch to tank drive, and later call "ArcadeDrive" once and have the robot switch to arcade drive? That's not what the functions do.

The Drive() functions take joystick inputs and mix them around to control motors. You have to call one of them at least ten times a second in order to keep your robot moving. You can decide which to use every time through your Teleop() loop, and you can change which one you use whenever you want to.

I agree with the suggestion to use the Z-axis "throttle" as the selection between Arcade and Tank drive.
Reply With Quote
  #10   Spotlight this post!  
Unread 03-04-2011, 13:12
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Switching Drive System While Driving

Ok thar sounds good I just wanted to make sure you could do it
Reply With Quote
Reply


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


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

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