|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Programming an Arcade Drive
How would you go about programming a class as a custom arcade drive for your robot?
What type of formulas would you need to use? |
|
#2
|
||||
|
||||
|
Re: Programming an Arcade Drive
Quote:
|
|
#3
|
||||
|
||||
|
Is the puedo-code on the referenced page written in python and if so do you know what the java equivalent might be
Last edited by inkspell4 : 15-12-2012 at 21:22. |
|
#4
|
||||
|
||||
|
Re: Programming an Arcade Drive
Quote:
|
|
#5
|
||||
|
||||
|
Sorry,
I was referring to the puedo-code found on the page that was previously referenced |
|
#6
|
||||
|
||||
|
Re: Programming an Arcade Drive
Quote:
|
|
#7
|
||||
|
||||
|
To tell you the truth i cant make sense of any of the psuedo-code files
|
|
#8
|
||||
|
||||
|
Re: Programming an Arcade Drive
Quote:
In your original post, you said you wanted the "formulas" so you could program a "custom arcade drive". If, however, all you want is canned Java code that already works, you can find it in the WPILibrary. |
|
#9
|
||||
|
||||
|
Re: Programming an Arcade Drive
Basic arcade drive in Java:
(Everything in red can be renamed.) Code:
throttle = joystick.getY();
turnValue = joystick.getX();
leftMtr = throttle + turnValue;
rightMtr = throttle - turnValue;
public double getArcadeLeftMotor() {
return leftMtr;
}
public double getArcadeRightMotor() {
return rightMtr;
}
plug in getArcadeLeftMotor() and getArcadeLeftMotor() as the left and right channels in a JoystickDrive object
But the basic code is a bit lacking. At high speeds the robot is going to tend to keep going more and it won't turn so well. It also results in situations where you get bad clipping because of the addition and subtaction. So we make the algorithm a bit more complex... Code:
throttle = joystick.getY();
turnValue = joystick.getX();
leftMtr = throttle + turnValue;
rightMtr = throttle - turnValue;
public double getArcadeLeftMotor() {
return leftMtr + skim(rightMtr);
}
public double getArcadeRightMotor() {
return rightMtr + skim(leftMtr);
}
public double skim(double v) {
if (v > 1.0) {
return -((v - 1.0) * RobotMap.TURNING_GAIN);
} else if (v < -1.0) {
return -((v + 1.0) * RobotMap.TURNING_GAIN);
} return 0;
}
You can use whatever algorithm you want to smooth it out. skim() is just an example, and some teams have found better algorithms entirely. Play around with it until you find something that works well. Good luck. Last edited by F22Rapture : 16-12-2012 at 00:38. |
|
#10
|
||||
|
||||
|
Could you please further explain the function and purpose of the skim method. Im relatively new to learning how to program an arcade drive
|
|
#11
|
||||
|
||||
|
Re: Programming an Arcade Drive
Quote:
Skim takes whatever was left on the end (in this case .2), multiplies it by another value, (say .5), and then subtracts it from the other side of the drivetrain. So instead of .75 throttle and .45 turn giving you full throttle on one side and .3 on the other, it gives you full throttle on one side and .2 on the other. So it's more accurate to the driver's input. The trick is finding an algorithm that has a comfortable response curve. |
|
#12
|
||||
|
||||
|
Re: Programming an Arcade Drive
Here's a contour map of the "skim" method with gain=0.5. Here's a contour map of the linear interpolation method with a=0.5 and b=1.0 Notice that the contour maps are identical all around the perimeter, but differ in how they get there. The linear one tries to provide linear response to the joystick in both X and Y directions. How that plays out in actual use is an open question. I'd like to hear back from teams who have tried the linear interpolation arcade. Last edited by Ether : 16-12-2012 at 17:19. Reason: fixed links |
|
#13
|
||||
|
||||
|
Ok thanks that makes sense now
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|