-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEncoderSubsystem
75 lines (42 loc) · 1.37 KB
/
EncoderSubsystem
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
69
70
71
72
73
74
package org.usfirst.frc.team6418.robot.subsystems;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.Encoder;
/**
*
*/
public class EncoderSubsystem extends Subsystem
{
// Put methods for controlling this subsystem
// here. Call these from Commands. //Left Encoder
int b = 1;
int c = 2;
Encoder encLeft = new Encoder(b, c);
//Right Encoder
int d = 3;
int e = 4;
Encoder encRight = new Encoder(d, e, true);
public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
encLeft.setMinRate(0.1);
encLeft.setDistancePerPulse(1440);
encLeft.setSamplesToAverage(100);
encRight.setMinRate(0.1);
encRight.setDistancePerPulse(1440);
encRight.setSamplesToAverage(100);
}
public void encoderLoop() {
System.out.println("in encoder subsystem");
while(true) {
double distanceTraveledRight = encRight.getDistance();
double distanceTraveledLeft = encLeft.getDistance();
double rightRate = encRight.getRate();
double leftRate = encLeft.getRate();
System.out.println("distance right " + distanceTraveledRight);
System.out.println("distance left "+ distanceTraveledLeft);
System.out.println();
System.out.println("rate Right "+ rightRate);
System.out.println("rate Left " + leftRate);
}
}
}