Go to Post Obligatory warning: School comes first. If you have to choose between doing homework and going to a build season meeting, do the homework. - Billfred [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 18-05-2011, 10:46
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
How to go about making tankDrive and ArcadeDrive methods

So I'm a new programmer for my team and we program in Java. I already know Java programming language and i get the basics of FRC robotics programming. However our main programmer wants me to be able to make the tank drive and arcade drive methods instead of just knowing how to call them. I'm not allowed to look at the methods FRC provides so I was wondering whats the best way to go about making those methods on my own
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 18-05-2011, 11:57
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by kinganu123 View Post
I'm not allowed to look at the methods FRC provides so I was wondering whats the best way to go about making those methods on my own
Before anyone answers, how much help are you "allowed" to solicit from contributors here on Chief Delphi ? We want to help, but we don't want to interfere with the assignment you've been given.


Reply With Quote
  #3   Spotlight this post!  
Unread 18-05-2011, 12:16
SuperBK's Avatar
SuperBK SuperBK is offline
Registered User
AKA: BrianK
FRC #1225 (Amperage Robotics)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Henersonville, NC
Posts: 357
SuperBK is just really niceSuperBK is just really niceSuperBK is just really niceSuperBK is just really nice
Re: How to go about making tankDrive and ArcadeDrive methods

Right, see what you can figure out. Read the sticks and turn on motors indivdually. Start with tank drive.
__________________
Brian K
Team 1225 Robotics Mentor
Reply With Quote
  #4   Spotlight this post!  
Unread 18-05-2011, 12:17
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Start by looking into the Jaguar or Victor classes respective to the speed controllers you have.

A hint, tank drive directly maps joysticks to speed controllers.

Arcade drive is a little trickier, but here's a hint. To turn the robot you send a positive value to one speed controller and a negative to the other. To go in a direction you send the same value to both controllers. Remember your max value is 1 too, so you may want to consider that if you really want to impress .
__________________
"Never let your schooling interfere with your education" -Mark Twain
Reply With Quote
  #5   Spotlight this post!  
Unread 18-05-2011, 13:02
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,077
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

When doing these sorts of problems, I like to make a table. What are my inputs? (Joystick positions). What are my outputs? (Motor PWM values). What are the "points" for which I have well behavior (for example, when your sticks aren't being touched you probably want to set your motors to 0 speed)?

Once you have this data down in front of you, the relationship between inputs and outputs can be analyzed and you can derive mathematical functions relating them.
Reply With Quote
  #6   Spotlight this post!  
Unread 18-05-2011, 13:46
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by lineskier View Post
Start by looking into the Jaguar or Victor classes respective to the speed controllers you have.

A hint, tank drive directly maps joysticks to speed controllers.

Arcade drive is a little trickier, but here's a hint. To turn the robot you send a positive value to one speed controller and a negative to the other. To go in a direction you send the same value to both controllers. Remember your max value is 1 too, so you may want to consider that if you really want to impress .
We have four motors, would it still be the same for arcade drive and tank drive that way?
__________________
Reply With Quote
  #7   Spotlight this post!  
Unread 18-05-2011, 15:13
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by kinganu123 View Post
We have four motors, would it still be the same for arcade drive and tank drive that way?
Yes, what you will want to do is pair the right speed controllers and left speed controllers together. So anytime you send values to them they should be the same.

L1 left 1 (Jaguar)
R1 right 1
So S1 = speed 1 (variable)
S2 = Speed 2

L1 S1 R1 S2
L2 S1 R2 S2
__________________
"Never let your schooling interfere with your education" -Mark Twain
Reply With Quote
  #8   Spotlight this post!  
Unread 18-05-2011, 13:44
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by Ether View Post
Before anyone answers, how much help are you "allowed" to solicit from contributors here on Chief Delphi ? We want to help, but we don't want to interfere with the assignment you've been given.

im pretty sure you can help me in any way other than actually giving me the code. The reason ive gotta do this is so I can mod the FRC classes should the need ever arise
__________________
Reply With Quote
  #9   Spotlight this post!  
Unread 18-05-2011, 15:19
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by kinganu123 View Post
im pretty sure you can help me in any way other than actually giving me the code. The reason ive gotta do this is so I can mod the FRC classes should the need ever arise
Tank drive is pretty straightforward. To go straight forward, drive the left and right wheels at the same (forward) speed. To turn right, add a little speed to the left wheel(s), and subtract the same amount from the right wheel(s). To turn left, add a little speed to the right wheel(s), and subtract the same amount from the left wheel(s)

[edit]
The above is actually a generic description for a skid steer vehicle.

For a "tank drive" interface to a skid-steer vehicle (where you are using only the Y axis of each of two joysticks) it is even easier. Just control the left wheel(s) with the left joystick Y-axis, and the right wheel(s) with the right joystick Y-axis.
[/edit]


Last edited by Ether : 18-05-2011 at 15:32.
Reply With Quote
  #10   Spotlight this post!  
Unread 18-05-2011, 15:22
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by Ether View Post
Tank drive is pretty straightforward. To go straight forward, drive the left and right wheels at the same (forward) speed. To turn right, add a little speed to the left wheel(s), and subtract the same amount from the right wheel(s).

Now the trick is to try to figure out how to make it scale correctly. When you add together 2 values the max # you can see is 2 but the max value you can set is 1. I will let you know though that dividing by 2 is not the answer because then full speed ahead is only a .5 .

sorry this is in reference to an arcade drive.

are you driving this via joystick or via autonomous?

also you may want to create a drive class that contains 2 functions arcade drive and tank drive.

encapsulating the drive within its own class is good practice.
__________________
"Never let your schooling interfere with your education" -Mark Twain

Last edited by mwtidd : 18-05-2011 at 15:24.
Reply With Quote
  #11   Spotlight this post!  
Unread 18-05-2011, 17:29
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by lineskier View Post
are you driving this via joystick or via autonomous?

also you may want to create a drive class that contains 2 functions arcade drive and tank drive.

encapsulating the drive within its own class is good practice.


I am driving via joystick but I dont have the robot or a driver station on my personal laptop to actually test it so thats kind of a problem, and ya my assignment is to pretty much make the drive class with those methods and when I know trig i gotta add mecanum to it, but thats next year.
__________________
Reply With Quote
  #12   Spotlight this post!  
Unread 18-05-2011, 17:48
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by kinganu123 View Post
I am driving via joystick but I dont have the robot or a driver station on my personal laptop to actually test it so thats kind of a problem, and ya my assignment is to pretty much make the drive class with those methods and when I know trig i gotta add mecanum to it, but thats next year.
Actually you can do mecanum without trig. Just like the arcade drive is figuring out how to sum up the motor in the right way based on the joystick input. It certainly isn't an overly efficient mecanum drive as scaling is an issue, but you can get the idea of it. I think its actually a good problem solving task to do the mecanum without trig .

Actually doing an encoder based mecanum drive could be done without trig too. Its only when you start going field centric that you really need trig.

Also the trig isn't too bad either, you could find it online. Just treat the left joystick as a circle and find the angle and distance from center based on the 2 values.

x^2 + y^2 = magnitude^2

angle = arctan(y/x)

soh cah toa
sin = opposite over hypotenuse
cos = adjacent over hypotenuse
tan = opposite over adjacent

cos(angle)*mag = y mag
sin(angle)*mag = x mag

give all 4 motor the y mag

top right back left y mag + x mag
top left back right y mag - x mag
i may have the side flipped not sure

programming a mec via trig is a lot easier than doing it without it, that why i suggest you try doing it by taking all joystick values / 2 and setting the motors via that. its def possible. for scaling reasons i'd leave out rotation at first.

if your feeling really ambitious let a gyro set the rotation value and you just set the x and y.
__________________
"Never let your schooling interfere with your education" -Mark Twain

Last edited by mwtidd : 18-05-2011 at 17:55.
Reply With Quote
  #13   Spotlight this post!  
Unread 18-05-2011, 18:09
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by lineskier View Post
Actually you can do mecanum without trig. Just like the arcade drive is figuring out how to sum up the motor in the right way based on the joystick input. It certainly isn't an overly efficient mecanum drive as scaling is an issue, but you can get the idea of it. I think its actually a good problem solving task to do the mecanum without trig .

Actually doing an encoder based mecanum drive could be done without trig too. Its only when you start going field centric that you really need trig.

Also the trig isn't too bad either, you could find it online. Just treat the left joystick as a circle and find the angle and distance from center based on the 2 values.

x^2 + y^2 = magnitude^2

angle = arctan(y/x)

soh cah toa
sin = opposite over hypotenuse
cos = adjacent over hypotenuse
tan = opposite over adjacent

cos(angle)*mag = y mag
sin(angle)*mag = x mag

give all 4 motor the y mag

top right back left y mag + x mag
top left back right y mag - x mag
i may have the side flipped not sure

programming a mec via trig is a lot easier than doing it without it, that why i suggest you try doing it by taking all joystick values / 2 and setting the motors via that. its def possible. for scaling reasons i'd leave out rotation at first.

if your feeling really ambitious let a gyro set the rotation value and you just set the x and y.
Lol Ill save mecanum for later on though, so ya i kinda got the logic behind tank, what about arcade?
__________________
Reply With Quote
  #14   Spotlight this post!  
Unread 18-05-2011, 19:11
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by kinganu123 View Post
Lol Ill save mecanum for later on though, so ya i kinda got the logic behind tank, what about arcade?
Rotation is handled as plus or minus

Left is y. - x
Right is y+ x

They may be flipped

Once again remember scaling
__________________
"Never let your schooling interfere with your education" -Mark Twain
Reply With Quote
  #15   Spotlight this post!  
Unread 18-05-2011, 19:54
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: How to go about making tankDrive and ArcadeDrive methods

Quote:
Originally Posted by lineskier View Post
Rotation is handled as plus or minus

Left is y. - x
Right is y+ x

They may be flipped

Once again remember scaling
That doesnt work for moving the joystick to the corners or towards them. thats the hardest part of arcade and ive been trying a bunch of algorithims but none of them can be used for more than one specific coordinate
__________________
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 11:20.

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