Go to Post Doctor the drill, or doctor your hand. Easy choice. Let's all make the right one. - Molten [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-12-2011, 09:15
Ja3 Ja3 is offline
Registered User
FRC #3137
 
Join Date: Dec 2011
Location: Connetquot High School
Posts: 5
Ja3 is an unknown quantity at this point
Creating a program that switch between tank and arcade

I havehit a hard point in trying to creat a program that can switch between both tank and arcade drive. I have basic block structure for both, I have no clue what to do next can any help?
  #2   Spotlight this post!  
Unread 22-12-2011, 10:03
spacepenguine spacepenguine is offline
Registered User
AKA: Ian Hartwig
no team
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 2008
Location: Troy, MI
Posts: 43
spacepenguine is an unknown quantity at this point
Re: Creating a program that switch between tank and arcade

We usually right that into out drive program when we have a tank base too. It's pretty simple to set up. For our program (in C++, but the logic is the same wherever), we used the throttle on the left joystick as our switch. In the program, this is the z axis and reports values from -1 to 1. The idea is that you have each drive in a if/else if or case block and you grab the value from the z axis (or whatever control you use) at the beginning of the teleop loop and use this to choose which drive block to use.

If you want to use an instantaneous button, the easiest way is probably to write the button value to a variable at the end of the loop then compare the current value to the last value to see if the value has changed and the value is true. This condition can toggle a variable that saves the current drive type. You would then use that current drive variable to decide which drive to use.

Additionally, you can decrease the amount of duplicate code by saving the pwm value for the motors in a variable for each motor in the drive blocks, then setting the motor pwm values at the end of the loop outside of the control blocks. This also makes it easier to implement a drive ramp or other filters on the pwm values that are universal to all drives.

Good Luck!
__________________
2008-2011: #226 - The Hammerheads

Last edited by spacepenguine : 22-12-2011 at 10:09.
  #3   Spotlight this post!  
Unread 22-12-2011, 10:07
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,113
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: Creating a program that switch between tank and arcade

What language are you using?

In LabVIEW it's easy: just put the two different drive functions in separate cases of a CASE structure, and use whatever you have controlling which mode you want to select the appropriate case. In C++, use an if/then/else to drive it in one fashion or the other. Java should work just like C++.
  #4   Spotlight this post!  
Unread 22-12-2011, 10:21
Ja3 Ja3 is offline
Registered User
FRC #3137
 
Join Date: Dec 2011
Location: Connetquot High School
Posts: 5
Ja3 is an unknown quantity at this point
Re: Creating a program that switch between tank and arcade

Thank you, but I should have asked how to set up using a button control I originally had them in a case structure but after that using the buttons wasn't connecting right?
  #5   Spotlight this post!  
Unread 22-12-2011, 10:55
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,113
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: Creating a program that switch between tank and arcade

Quote:
Originally Posted by Ja3 View Post
...I should have asked how to set up using a button control...
What does "button control" mean? Do you want it to be two-stick tank drive by default, and the driver has to hold down a button in order to make it single-stick arcade drive? Do you want separate buttons to select between tank and arcade mode? Do you want to use a single button to alternate between the two modes each time it is pressed?

Tell us how you want the driver to use it, and we can tell you how to program it to work that way.
  #6   Spotlight this post!  
Unread 22-12-2011, 21:47
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
Re: Creating a program that switch between tank and arcade

If you want to make the system remember whether you're currently on tank or arcade drive without using something like the Z-axis, you'd need to add a state field to the class, like:

bool isArcadeDrive = true;

Then, you'd modify that during each loop with conditionals to change it:

if( joystick->getRawButton(ArcadeButton)) {

isArcadeDrive = true;

}

else if ( joystick->getRawButton(TankButton)) {
isArcadeDrive = false;
}

This way, during each loop, your code constantly checks whether you've hit either button to switch driving modes, and the mode, being held in a field, is static during the program, so the program remembers whether you're in arcade or tank drive at any moment.

Next, you could add conditionals so that, depending on whether isArcadeDrive indicates arcade or tank driving, to use the drive code associated with either arcade or tank driving.

Example:

if(isArcadeDrive){
//Arcade drive code
}
else { //isArcadeDrive is false, therefore use Tank drive settings
//tank drive code
}
__________________
Attending: MN Duluth Regional
  #7   Spotlight this post!  
Unread 23-12-2011, 23:26
gixxy's Avatar
gixxy gixxy is offline
Programming and Arduino Mentor
AKA: Gustave Michel III
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Ruston, LA
Posts: 207
gixxy is on a distinguished road
Re: Creating a program that switch between tank and arcade

Using Java I created 3 classes and an interface.

the interface (ControlMap) was just a list of functions we would need to get the infomation from the joysticks. things like getThrottle() in arcade and getLeftJoystick() and getRightJoystick() for Tank.

Then the other two classes were tankControlBoard and arcadeControlBoard. Which implemented the ControlMap interface. This way I could use a single ControlMap object and just switch which implentation to use, and thus change what code was used to get the data needed.

That is how I did the controls selection.


Then another class i made was softSwitch. which basicly had the methods getState(), toggleState(), and setState() so that I could use a button on the joystick as an on/off toggle (as well as set the button's state in software).

so then in our ControlOperator class, which read the data from the ControlMap (and then used the proper ControlBoard) would tell the Drive Train how to drive, using Tank or Arcade.

I can't seem to find the code I used. If you need help I will gladly attempt to rewrite a simple version of it.
  #8   Spotlight this post!  
Unread 24-12-2011, 18:03
Ja3 Ja3 is offline
Registered User
FRC #3137
 
Join Date: Dec 2011
Location: Connetquot High School
Posts: 5
Ja3 is an unknown quantity at this point
Re: Creating a program that switch between tank and arcade

Thanks guys you helped out a lot.
  #9   Spotlight this post!  
Unread 24-12-2011, 20:42
ratdude747's Avatar
ratdude747 ratdude747 is offline
Official Scorekeeper
AKA: Larry Bolan
no team
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Madison, IN
Posts: 1,064
ratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond repute
Re: Creating a program that switch between tank and arcade

I have code for this somehwhere...

its labview code

it uses 3 drive modes, controlled by joystick buttons

one is pure arcade (arcade), one is RC car (left stick steers, right stick throttles), one is tank

it also has a dashboard to go with it.

I'll post the code once I get it off my old laptop

edit- someone must have deleted it from dropbox...

the code worked like this:

(in teleop)

- 3 buttons for each setting
- each button connects to a select block
- the false inputs of the slects are hooked tot he select above it, with the last select going into a feedback node, which returns to the false input of the first select block. the true inputs connect the the button's corresponding mode.
-the initial input of the feedback note is set to arcade (set to the default case)
-the output of the last select goes to a case structure, with one case for each mode. for each case, it uses 2 of 4 axises to go to either an arcade block (arcade and rc) or tank (tank):
- the current case selected also goes to a global variable, which is sent to the dashboard data vi to be sent to the dashboard, which has an added display for the current mode.

I wish I still had the code, but as far as i can tell it is lost... if I do happen to find it, i will post it.
__________________
Dean's List Semi-finalist 2010
1747 Harrison Boiler Robotics 2008-2010, 2783 Engineers of Tomorrow 2011, Event Volunteer 2012-current

DISCLAIMER: Any opinions/comments posted are solely my personal opinion and does not reflect the views/opinions of FIRST, IndianaFIRST, or any other organization.

Last edited by ratdude747 : 24-12-2011 at 21:05.
  #10   Spotlight this post!  
Unread 15-02-2012, 00:33
ratdude747's Avatar
ratdude747 ratdude747 is offline
Official Scorekeeper
AKA: Larry Bolan
no team
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Madison, IN
Posts: 1,064
ratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond reputeratdude747 has a reputation beyond repute
Re: Creating a program that switch between tank and arcade

Quote:
Originally Posted by ratdude747 View Post
I have code for this somehwhere...

its labview code

it uses 3 drive modes, controlled by joystick buttons

one is pure arcade (arcade), one is RC car (left stick steers, right stick throttles), one is tank

it also has a dashboard to go with it.

I'll post the code once I get it off my old laptop

edit- someone must have deleted it from dropbox...

the code worked like this:

(in teleop)

- 3 buttons for each setting
- each button connects to a select block
- the false inputs of the slects are hooked tot he select above it, with the last select going into a feedback node, which returns to the false input of the first select block. the true inputs connect the the button's corresponding mode.
-the initial input of the feedback note is set to arcade (set to the default case)
-the output of the last select goes to a case structure, with one case for each mode. for each case, it uses 2 of 4 axises to go to either an arcade block (arcade and rc) or tank (tank):
- the current case selected also goes to a global variable, which is sent to the dashboard data vi to be sent to the dashboard, which has an added display for the current mode.

I wish I still had the code, but as far as i can tell it is lost... if I do happen to find it, i will post it.
reviving the thread briefly to add the source code; I found an old flash drive the just by chance had a copy

included in the .zip:

robot source code
driver station source code
driver station .exe

It was designed to be used with Logitech wingman extreme 3d joystics (I donated an old pair I had sitting). it also uses the left joystick's throttle to scale the speed as the bot it was written for had an unusually high drive gearing (at full speed it was known for flinging batteries )

maybe this will be useful in the future to somebody...
Attached Files
File Type: zip 6wd extreme.zip (364.0 KB, 12 views)
__________________
Dean's List Semi-finalist 2010
1747 Harrison Boiler Robotics 2008-2010, 2783 Engineers of Tomorrow 2011, Event Volunteer 2012-current

DISCLAIMER: Any opinions/comments posted are solely my personal opinion and does not reflect the views/opinions of FIRST, IndianaFIRST, or any other organization.
  #11   Spotlight this post!  
Unread 15-02-2012, 01:04
CRLS97 CRLS97 is offline
Registered User
FRC #0097
 
Join Date: Jan 2011
Location: Cambridge
Posts: 28
CRLS97 is an unknown quantity at this point
Re: Creating a program that switch between tank and arcade

Your example did come in handy in teaching me how to pass data from the robot to the dashboard
  #12   Spotlight this post!  
Unread 15-02-2012, 12:44
Cal578 Cal578 is offline
Passionate FIRST-er, CD donor
AKA: Gerry
FRC #0578 (Red Raider Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Rochester, NY
Posts: 262
Cal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant future
Re: Creating a program that switch between tank and arcade

Here's another idea, which our team is using. The new Smart Dashboard has a way of storing values and sending them to the robot on startup. We use one of the variables to store a value indicating which steering method to use. When the robot connects, it reads that variable and stores the value locally. The code from that point is pretty much as other posters have described.

As an aside, we have three different steering methods to choose from:
  1. Tank drive (two joysticks independently control left/right wheels)
  2. Arcade drive (one joystick, tilt left/right to rotate robot)
  3. 3-axis (one joystick, rotate handle to rotate robot, tilt left/right is ignored)
We're using the common 6-wheel drive, so sliding left/right isn't an option

Hope this helps. Good luck, all!
__________________
Cal
R3: Red Raider Robotics (FRC Team 578)
Fairport, NY, USA
www.FairportRobotics.org
2016 Finger Lakes Regional: Semifinalist on Alliance 7 (1128, 2010, 578)
2016 NYC Regional: Finalist on Alliance 3 (3419, 578, 3017), 4th seed team, Team Spirit Award
2015 Finger Lakes Regional: 8-3-0 in qualification, 7th seed, Quarterfinalist
2014 NY Tech Valley Regional: 8-4-0 in qualification, 13th seed, Semifinalist
2013 Finger Lakes Regional: 4-5-0 in qualification, 26th seed, Alliance 6, 1-2 in tournament
2012 Buckeye Regional: Gracious Professionalism Award, 7-3-0, 14th seed
2011 Finger Lakes Regional: Engineering Inspiration Award
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


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

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