DriveStraight command with encoder
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / driving / DriveStraight.java
CommitLineData
dd016bd2 1package org.usfirst.frc.team3501.robot.commands.driving;
2
3import org.usfirst.frc.team3501.robot.Robot;
4
5public class DriveStraight {
6
7 double distL;
8 double distR;
9 double moveR = Robot.getDriveTrain().getLeftSpeed();
10 double moveL = Robot.getDriveTrain().getRightSpeed();
11
12 public DriveStraight() {
13 distL = Robot.getDriveTrain().getLeftEncoderDistance();
14 distR = Robot.getDriveTrain().getRightEncoderDistance();
15 }
16
17 public void updateMotorSpeed() {
18 if (distL > distR) {
19 double k = distL / distR;
20 moveR *= k;
21 moveL /= k;
22 } else if (distR > distL) {
23 double k = distR / distL;
24 moveR /= k;
25 moveL *= k;
26 }
27
28 Robot.getDriveTrain().setMotorValues(moveR, moveL);
29 }
30}