forked from rockyMountainRobotics/rmr2019
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrive.java
More file actions
68 lines (46 loc) · 1.77 KB
/
Drive.java
File metadata and controls
68 lines (46 loc) · 1.77 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package frc.robot;
import com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX;
import edu.wpi.first.wpilibj.SpeedControllerGroup;
import edu.wpi.first.wpilibj.GenericHID.Hand;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
public class Drive extends Component {
//A multipier for speed
final double MULTIPLIER = .6;
//Motors
private WPI_VictorSPX leftFront;
private WPI_VictorSPX rightFront;
private WPI_VictorSPX leftBack;
private WPI_VictorSPX rightBack;
//Combines the motors into left and right "sides" of the robot
private SpeedControllerGroup leftDrive;
private SpeedControllerGroup rightDrive;
//Convenient for Driving
private DifferentialDrive m_myRobot;
//Constructors
public Drive() {
//Initialize motors using the ports that are in RobotMap
leftFront = new WPI_VictorSPX(RobotMap.LEFT_FRONT_MOTOR);
rightFront = new WPI_VictorSPX(RobotMap.RIGHT_FRONT_MOTOR);
leftBack = new WPI_VictorSPX(RobotMap.LEFT_BACK_MOTOR);
rightBack = new WPI_VictorSPX(RobotMap.RIGHT_BACK_MOTOR);
//invert one motor :D
leftFront.setInverted(true);
//Initialize speed controllers
leftDrive = new SpeedControllerGroup(leftFront, leftBack);
rightDrive = new SpeedControllerGroup(rightFront, rightBack);
//create differential drive
m_myRobot = new DifferentialDrive(leftDrive, rightDrive);
}
@Override
public void update() {
//Drive!!
m_myRobot.arcadeDrive(MULTIPLIER *(-RobotMap.driveController.getY(Hand.kLeft)), MULTIPLIER*(RobotMap.driveController.getX(Hand.kLeft)));
}
@Override
public void autoUpdate() {
// probably need to call update in here
}
@Override
public void disable() {
}
}