Go to Post Some of them look like phone numbers... LETS START CALLING THEM ALL! - akoscielski3 [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 03:06.

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