Skip to content

Commit

Permalink
Moved checkTractionEncoder() into drivetrain holonomic() so that it o…
Browse files Browse the repository at this point in the history
…nly gets called when not rotating (in theory)
  • Loading branch information
haydenshively committed Jun 9, 2018
1 parent 39f12bc commit bbddceb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/org/usfirst/frc/team4256/robot/R_Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,21 @@ public void holonomic(final double direction, double speed, final double spin) {
for (int i = 0; i < 4; i++) modules[i].set(speeds_final[i]);//control traction if good and there
}else stop();//otherwise, stop traction

if (spin < 0.07) moduleD.checkTractionEncoder();

//{UPDATE RECORDS}
previousSpin = spin;
}


public void holonomic_encoderIgnorant(final double direction, double speed, final double speedSpin) {
public void holonomic_encoderIgnorant(final double direction, double speed, final double spin) {
//{PREPARE VARIABLES}
speed = Math.abs(speed);
final double chassis_fieldAngle = gyro.getCurrentAngle();
final double forward = speed*Math.cos(Math.toRadians(R_SwerveModule.convertToRobot(direction, chassis_fieldAngle))),
strafe = speed*Math.sin(Math.toRadians(R_SwerveModule.convertToRobot(direction, chassis_fieldAngle)));
final double[] comps_desired = computeComponents(strafe, forward, speedSpin);
final boolean bad = speed == 0.0 && speedSpin == 0.0;
final double[] comps_desired = computeComponents(strafe, forward, spin);
final boolean bad = speed == 0.0 && spin == 0.0;

//{CONTROL MOTORS, computing outputs as needed}
if (!bad) {
Expand All @@ -105,6 +107,8 @@ public void holonomic_encoderIgnorant(final double direction, double speed, fina
final double[] speeds_final = computeSpeeds(comps_desired);
for (int i = 0; i < 4; i++) modules[i].set(speeds_final[i]);//control traction if good and there
}else stop();//otherwise, stop traction

if (spin < 0.07) moduleD.checkTractionEncoder();
}


Expand Down
6 changes: 2 additions & 4 deletions src/org/usfirst/frc/team4256/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.RobotController;
import edu.wpi.first.wpilibj.hal.PowerJNI;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableInstance;

Expand Down Expand Up @@ -97,8 +96,8 @@ public void robotInit() {
setupLogging(ds);

moduleA.setTareAngle(-78.0);moduleB.setTareAngle(-28.0);moduleC.setTareAngle(45.0);moduleD.setTareAngle(-77.0);

moduleA.setParentLogger(logger);moduleB.setParentLogger(logger);moduleC.setParentLogger(logger);moduleD.setParentLogger(logger);

elevatorOne.setZero(0.5);
elevatorTwo.setZero(1.0);
clamp.setZero();
Expand Down Expand Up @@ -178,8 +177,7 @@ public void robotPeriodic() {
faraday.getEntry("Angle B").setNumber(moduleB.rotationMotor().getCurrentAngle(true));
faraday.getEntry("Angle C").setNumber(moduleC.rotationMotor().getCurrentAngle(true));
faraday.getEntry("Angle D").setNumber(moduleD.rotationMotor().getCurrentAngle(true));

moduleD.checkTractionEncoder();

odometer.update();
faraday.getEntry("X").setNumber(odometer.getX(/*markAsRead*/false));
faraday.getEntry("Y").setNumber(odometer.getY(/*markAsRead*/false));
Expand Down

0 comments on commit bbddceb

Please sign in to comment.