|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|
#2
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
|
|
#3
|
||||
|
||||
|
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.
|
|
#4
|
||||
|
||||
|
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 . |
|
#5
|
|||||
|
|||||
|
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. |
|
#6
|
|||
|
|||
|
Re: How to go about making tankDrive and ArcadeDrive methods
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
|
|
#7
|
|||
|
|||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
|
|
#8
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
L1 left 1 (Jaguar) R1 right 1 So S1 = speed 1 (variable) S2 = Speed 2 L1 S1 R1 S2 L2 S1 R2 S2 |
|
#9
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
[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 : 05-18-2011 at 03:32 PM. |
|
#10
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
.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. Last edited by mwtidd : 05-18-2011 at 03:24 PM. |
|
#11
|
|||
|
|||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
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. |
|
#12
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
. 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. Last edited by mwtidd : 05-18-2011 at 05:55 PM. |
|
#13
|
|||
|
|||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
|
|
#14
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
Left is y. - x Right is y+ x They may be flipped Once again remember scaling |
|
#15
|
||||
|
||||
|
Re: How to go about making tankDrive and ArcadeDrive methods
Quote:
FL = -Y +X +Z RR = -Y +X -Z RL = -Y -X +Z How does trig make the above any easier ? Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|