|
Re: removed classes from wpilib
Use the following if you want arcade drive. Tank drive is easier.
Linear Arcade drive:
int m1 = 0; //Temp Variables
int m2 = 0; //Temp Variable
int x = 0; //Joystick X
int y = 0; //Joystick Y
Joystick JoyHoy = new Joystick(1);
PWM motor1 = new PWM(1);
PWM motor2 = new PWM(2);
/*
I usually declare and initialize separately like I do for C++, but for simplicity sake I didn't.
*/
while(teleop) //arbitrary while loop, its the teleop
{
Y = JoyHoy.getY();
X = JoyHoy.getX();
m1 = 127 * y + 127;
m2 = 127 * y + 127;
motor1.setRaw((int)(m1 + m1 * x));
motor2.setRaw((int)(m2 - m2 * x));
}
edit:
also regulate the PWM, as is, the code will generate invalid PWMs
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Last edited by davidthefat : 11-01-2011 at 17:33.
|