+ public void resetEncoders() {
+ leftEncoder.reset();
+ rightEncoder.reset();
+ }
+
+ public double getRightSpeed() {
+ return rightEncoder.getRate(); // in inches per second
+ }
+
+ public double getLeftSpeed() {
+ return leftEncoder.getRate(); // in inches per second
+ }
+
+ public double getSpeed() {
+ return (getLeftSpeed() + getRightSpeed()) / 2.0; // in inches per second
+ }
+
+ public double getRightDistance() {
+ return rightEncoder.getDistance(); // in inches
+ }
+
+ public double getLeftDistance() {
+ return leftEncoder.getDistance(); // in inches
+ }
+
+ public double getDistance() {
+ return (getRightDistance() + getLeftDistance()) / 2.0; // in inches
+ }
+
+ public void stop() {
+ setMotorSpeeds(0, 0);
+ }
+
+ public void setMotorSpeeds(double leftSpeed, double rightSpeed) {
+ // Right motors receive negative values because they turn in the opposite
+ // direction
+ this.frontLeft.set(leftSpeed);
+ this.frontRight.set(-rightSpeed);
+ this.rearLeft.set(leftSpeed);
+ this.rearRight.set(-rightSpeed);
+ }
+