forked from PHScodemaster/FRC4949
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTank Drive
53 lines (44 loc) · 1.81 KB
/
Tank Drive
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package org.usfirst.frc.team4949.robot;
import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.vision.USBCamera;
/**
* This is a demo program showing the use of the RobotDrive class, specifically it
* contains the code necessary to operate a robot with tank drive.
*
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SampleRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*
* WARNING: While it may look like a good choice to use for your code if you're inexperienced,
* don't. Unless you know what you are doing, complex code will be much more difficult under
* this system. Use IterativeRobot or Command-Based instead if you're new.
*/
public class Robot extends SampleRobot {
RobotDrive myRobot; // class that handles basic drive operations
Joystick leftStick; // set to ID 1 in DriverStation
Joystick rightStick; // set to ID 2 in DriverStation
USBCamera camera;
public Robot() {
myRobot = new RobotDrive(0, 1, 2, 3);
myRobot.setExpiration(0.1);
leftStick = new Joystick(0);
rightStick = new Joystick(1);
camera = new USBCamera();
}
/**
* Runs the motors with tank steering.
*/
public void operatorControl() {
myRobot.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled()) {
myRobot.tankDrive(leftStick, rightStick);
Timer.delay(0.005); // wait for a motor update time
}
}
}