Skip to content
This repository has been archived by the owner on Jul 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #56 from frc3197/mke-prep
Browse files Browse the repository at this point in the history
Milwaukee Cleanup and Preparation
  • Loading branch information
spencrr committed Mar 24, 2019
2 parents bdf589c + 49701f6 commit 9d9db58
Show file tree
Hide file tree
Showing 23 changed files with 262 additions and 453 deletions.
18 changes: 4 additions & 14 deletions src/main/java/org/team3197/frc2019/robot/OI.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.team3197.frc2019.robot;

import org.team3197.frc2019.robot.RobotMap.MaxSpeeds;
import org.team3197.frc2019.robot.commands.AlignTurn;
import org.team3197.frc2019.robot.commands.presets.Cargo;
import org.team3197.frc2019.robot.commands.presets.LevelOne;
import org.team3197.frc2019.robot.commands.presets.LevelThree;
Expand Down Expand Up @@ -46,20 +45,12 @@ public class OI {
private static JoystickButton secondaryLeftBumper = new JoystickButton(secondary, 5);

static {
// driverDPadUp.whenPressed(Robot.driveTrain.changeDriveMode);

// driverDPadRight.whileHeld(new AlignTurn(Robot.driveTrain));

// driverDPadLeft.whenPressed(Robot.driveTrain.changeDriveGryo);

driverA.whenPressed(Robot.driveTrain.changeDriveMode);

driverB.whileHeld(new AlignTurn(Robot.driveTrain));
// secondaryX.whenPressed(Robot.elevator.reset);
// driverB.whileHeld(new AlignTurn(Robot.driveTrain));
secondaryX.whenPressed(Robot.arm.toggleGyro);
driverY.whileHeld(Robot.autoClimb);

// driverY.whenPressed(Robot.driveTrain.changeDriveGryo);
secondaryX.whenPressed(Robot.arm.toggleGyro);

secondaryY.whenPressed(Robot.arm.resetEncoder);
secondaryY.whenPressed(Robot.elevator.reset);
Expand Down Expand Up @@ -106,7 +97,8 @@ public static double wristSpeed() {
}

public static double erectorSpeed() {
return driver.getTriggerAxis(Hand.kLeft) - driver.getTriggerAxis(Hand.kRight);
return driver.getTriggerAxis(Hand.kLeft)
- driver.getTriggerAxis(Hand.kRight) * RobotMap.erectorSpeedMultiplier;
}

public static double manipulatorSpeed() {
Expand All @@ -117,8 +109,6 @@ public static double manipulatorSpeed() {
public static double hatchSpeed() {
return (driverLeftBumper.get() ? MaxSpeeds.kHatch.forwardSpeed : 0)
+ (driverRightBumper.get() ? MaxSpeeds.kHatch.reverseSpeed : 0);
// return (driverLeftBumper.get() ? MaxSpeeds.kHatch.forwardSpeed :
// MaxSpeeds.kHatch.reverseSpeed);
}

public static double climberVerticalSpeed() {
Expand Down
63 changes: 14 additions & 49 deletions src/main/java/org/team3197/frc2019/robot/Robot.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package org.team3197.frc2019.robot;

import org.team3197.frc2019.robot.RobotMap.DeadbandType;
import org.team3197.frc2019.robot.RobotMap.ElbowPreset;
import org.team3197.frc2019.robot.RobotMap.ElevatorPreset;
import org.team3197.frc2019.robot.RobotMap.GyroSensitivity;
import org.team3197.frc2019.robot.RobotMap.MaxSpeeds;
import org.team3197.frc2019.robot.commands.GyroClimb;
import org.team3197.frc2019.robot.commands.test.DriveTrainTest;
import org.team3197.frc2019.robot.subsystems.Arm;
import org.team3197.frc2019.robot.subsystems.CargoManipulator;
import org.team3197.frc2019.robot.subsystems.Climber;
import org.team3197.frc2019.robot.subsystems.DriveTrain;
import org.team3197.frc2019.robot.subsystems.Elevator;
import org.team3197.frc2019.robot.subsystems.Erector;
import org.team3197.frc2019.robot.subsystems.Hatch;
import org.team3197.frc2019.robot.subsystems.Intake;

import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.PowerDistributionPanel;
Expand All @@ -25,22 +20,21 @@

public class Robot extends TimedRobot {

public static DriveTrain driveTrain = new DriveTrain();
public static Elevator elevator = new Elevator();
public static Arm arm = new Arm();
public static CargoManipulator manipulator = new CargoManipulator();
public static Hatch hatch = new Hatch();
public static Erector erector = new Erector();
public static Climber climber = new Climber();
public static final DriveTrain driveTrain = new DriveTrain();
public static final Elevator elevator = new Elevator();
public static final Arm arm = new Arm();
public static final Intake manipulator = new Intake();
public static final Hatch hatch = new Hatch();
public static final Erector erector = new Erector();
public static final Climber climber = new Climber();

// public static PowerDistributionPanel pdp = new PowerDistributionPanel(0);
public static final GyroClimb autoClimb = new GyroClimb(climber);

public static DriveTrainTest driveTrainTest;
public static final PowerDistributionPanel pdp = new PowerDistributionPanel();

public static NetworkTableInstance ntInst = NetworkTableInstance.getDefault();
public static NetworkTable table;
public static final NetworkTableInstance ntInst = NetworkTableInstance.getDefault();

public static Preferences prefs = Preferences.getInstance();
public static final Preferences prefs = Preferences.getInstance();

private static boolean resetEncoders = true;

Expand All @@ -51,36 +45,6 @@ public void robotInit() {
@Override
public void robotPeriodic() {
SmartDashboard.putNumber("Time", DriverStation.getInstance().getMatchTime());

ElbowPreset.kHatchOne.elbowPos = prefs.getDouble("kHatchLevelOne", ElbowPreset.kHatchOne.elbowPos);
ElbowPreset.kHatchTwo.elbowPos = prefs.getDouble("kHatchLevelTwo", ElbowPreset.kHatchTwo.elbowPos);
ElbowPreset.kHatchThree.elbowPos = prefs.getDouble("kHatchLevelThree", ElbowPreset.kHatchThree.elbowPos);
ElbowPreset.kCargoOne.elbowPos = prefs.getDouble("kCargoOne", ElbowPreset.kCargoOne.elbowPos);
ElbowPreset.kCargoTwo.elbowPos = prefs.getDouble("kCargoTwo", ElbowPreset.kCargoTwo.elbowPos);
ElbowPreset.kCargoThree.elbowPos = prefs.getDouble("kCargoThree", ElbowPreset.kCargoThree.elbowPos);
ElbowPreset.kCargoShip.elbowPos = prefs.getDouble("kCargoShip", ElbowPreset.kCargoShip.elbowPos);

ElevatorPreset.kHatchLevelThree.pos = prefs.getDouble("kHatchLevelThree", ElevatorPreset.kHatchLevelThree.pos);
ElevatorPreset.kCargoLevelOne.pos = prefs.getDouble("kCargoLevelOne", ElevatorPreset.kCargoLevelOne.pos);
ElevatorPreset.kCargoLevelTwo.pos = prefs.getDouble("kCargoLevelTwo", ElevatorPreset.kCargoLevelTwo.pos);
ElevatorPreset.kCargoLevelThree.pos = prefs.getDouble("kCargoLevelThree", ElevatorPreset.kCargoLevelThree.pos);
ElevatorPreset.kCargoLoadingLevel.pos = prefs.getDouble("kCargoLoadingLevel",
ElevatorPreset.kCargoLoadingLevel.pos);
ElevatorPreset.kCargoShipCargo.pos = prefs.getDouble("kCargoShipCargo", ElevatorPreset.kCargoShipCargo.pos);

DeadbandType.kElevator.speed = prefs.getDouble("kElevatorDeadband", DeadbandType.kElevator.speed);
DeadbandType.kElbow.speed = prefs.getDouble("kElbowDeadband", DeadbandType.kElbow.speed);
DeadbandType.kWrist.speed = prefs.getDouble("kWristDeadband", DeadbandType.kWrist.speed);
DeadbandType.kDrive.speed = prefs.getDouble("kDriveDeadband", DeadbandType.kDrive.speed);

GyroSensitivity.kDrive.val = prefs.getDouble("kDriveSensitivity", GyroSensitivity.kDrive.val);
GyroSensitivity.kArm.val = prefs.getDouble("kArmSensitivity", GyroSensitivity.kArm.val);

MaxSpeeds.kElevator.forwardSpeed = prefs.getDouble("kElevatorSpeedUp", MaxSpeeds.kElevator.forwardSpeed);
MaxSpeeds.kElevator.reverseSpeed = prefs.getDouble("kElevatorSpeedDown", MaxSpeeds.kElevator.reverseSpeed);
MaxSpeeds.kHatch.forwardSpeed = prefs.getDouble("kHatchSpeed", MaxSpeeds.kHatch.forwardSpeed);
MaxSpeeds.kCargo.forwardSpeed = prefs.getDouble("kCargoSpeedUp", MaxSpeeds.kCargo.forwardSpeed);
MaxSpeeds.kCargo.reverseSpeed = prefs.getDouble("kCargoSpeedDown", MaxSpeeds.kCargo.reverseSpeed);
}

@Override
Expand Down Expand Up @@ -125,6 +89,7 @@ public void testPeriodic() {

private void reset() {
arm.resetGyro.start();
climber.resetGyro.start();
erector.resetPID.start();
if (resetEncoders) {
elevator.reset.start();
Expand Down
56 changes: 9 additions & 47 deletions src/main/java/org/team3197/frc2019/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class RobotMap {
public static enum CANSparkMaxID {
kFrontLeft(14, "FrontLeft"), kBackLeft(15, "BackLeft"), kFrontRight(1, "FrontRight"), kBackRight(16, "BackRight"),
kElevatorLeft(2, "ElevatorLeft"), kElevatorRight(13, "ElevatorRight"), kWrist(12, "Wrist"), kElbow(3, "Elbow"),
kCargoManipulator(11, "CargoManipulator"), kHatch(10, "Hatch"), kErectorLeft(5, "ErectorLeft"),
kErectorRight(4, "ErectorRight"), kLiftVertical(8, "LiftVertical"), kLiftHorizontal(9, "LiftHorizontal");
kIntake(11, "Intake"), kHatch(10, "Hatch"), kErectorLeft(5, "ErectorLeft"), kErectorRight(4, "ErectorRight"),
kLiftVertical(8, "LiftVertical"), kLiftHorizontal(9, "LiftHorizontal");

public final int id;
public final String name;
Expand Down Expand Up @@ -37,7 +37,8 @@ private ElevatorPreset(double pos) {
}

public static enum DeadbandType {
kElevator(0.03), kElbow(0.06), kWrist(0.06), kDrive(0.08), kClimberVertical(0.05), kErector(0.05);
kElevator(0.03), kElbow(0.06), kWrist(0.06), kDrive(0.08), kClimberVertical(0.05), kErector(0.05),
kClimberGyroVal(5);
public double speed;

private DeadbandType(double speed) {
Expand All @@ -49,28 +50,8 @@ public static enum DriveTrainSide {
LEFT, RIGHT, BOTH;
}

public static enum CANSparkPID {
P(0), I(0), D(0), F(0);

public final double val;

private CANSparkPID(double val) {
this.val = val;
}
};

public static enum ElevatorPID {
P(0), I(0), D(0), F(0);

public final double val;

private ElevatorPID(double val) {
this.val = val;
}
};

public static enum Channel {
kDriveGyro(0), kWristGyro(1);
kWristGyro(0), kClimberGyro(1);
public final int channel;

private Channel(int channel) {
Expand All @@ -79,7 +60,7 @@ private Channel(int channel) {
};

public static enum GyroSensitivity {
kDrive(0.01), kArm(-0.005);
kDrive(0.01), kArm(-0.005), kClimber(0.005);
public double val;

private GyroSensitivity(double val) {
Expand All @@ -88,7 +69,8 @@ private GyroSensitivity(double val) {
};

public static enum MaxSpeeds {
kElevator(.7, -.5), kArm(.38), kWrist(.10), kHatch(1), kCargo(1), kClimberVertical(.7), kClimberHorizontal(.9);
kElevator(.7, -.5), kArm(.38), kWrist(.10), kHatch(1), kCargo(1), kClimberVertical(.7), kClimberHorizontal(.9),
kErector(.3);

public double forwardSpeed;
public double reverseSpeed;
Expand All @@ -104,29 +86,16 @@ private MaxSpeeds(double speed) {
}
}

// TODO this is bad
public static final RobotType current = RobotType.A;

public static enum RobotType {
A, B;
}

public static final double elevatorPresetThreshold = 1.5;

public static final double wristPresetThreshold = .5;

public static final double elbowPresetThreshold = 1.5;

public static final double elevatorDegreeSensitivity = 0.15;

public static final double wristDegreeSensitivity = 0.15;

public static final double elbowDegreeSensitivity = 0.15;

public static final double elevatorExponent = 0.5;

public static final double wristExponent = 0.5;

public static final double elbowExponent = 0.5;

public static final double elevatorSpeedMultiplier = 0.5;
Expand All @@ -135,13 +104,6 @@ public static enum RobotType {

public static final double wristSpeedMultiplier = 0.5;

public static final int gyroChannel = 0;

public static final double xMax = 640;

public static final double visionTargetX = .5;

public static final double visionTargetArea = 32000;
public static final double erectorSpeedMultiplier = 0.5;

public static final int cameraPixelWidth = 640;
}
82 changes: 0 additions & 82 deletions src/main/java/org/team3197/frc2019/robot/commands/AlignTurn.java

This file was deleted.

0 comments on commit 9d9db58

Please sign in to comment.