-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhrive.java
More file actions
40 lines (30 loc) · 1.62 KB
/
hrive.java
File metadata and controls
40 lines (30 loc) · 1.62 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
// -----------------------------H-DRIVE.------------------------------------ //
package frc.robot;
import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
import edu.wpi.first.wpilibj.SpeedControllerGroup;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
public class hrive {
private OI oi;
private DifferentialDrive driveType;
private CANSparkMax frontRight, rearRight, frontLeft, rearLeft, horizontalMotor;
private static int frontRightID=0, rearRightID=1, frontLeftID=2, rearLeftID=3, horizontalMotorID=4;
// -----------------------------Before code starts.------------------------------------ //
public void hDriveInit() {
oi = new OI();
frontRight = new CANSparkMax(frontRightID, MotorType.kBrushless);
rearRight = new CANSparkMax(rearRightID, MotorType.kBrushless);
frontLeft = new CANSparkMax(frontLeftID, MotorType.kBrushless);
rearLeft = new CANSparkMax(rearLeftID, MotorType.kBrushless);
horizontalMotor = new CANSparkMax(horizontalMotorID, MotorType.kBrushless);
SpeedControllerGroup Right = new SpeedControllerGroup(frontRight, rearRight);
SpeedControllerGroup Left = new SpeedControllerGroup(frontLeft, rearLeft);
driveType = new DifferentialDrive(Right, Left);
}
// -----------------------------Main program.------------------------------------ //
public void hDriveMain() {
driveType.arcadeDrive(oi.getDriveLeftX(), oi.getDriveLeftY());
horizontalMotor.set(oi.getDriveRightX());
}
}
// ----------------------------------------------------------------- //