Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compensations for hardware testing #13

Merged
merged 13 commits into from
Feb 23, 2019
Merged
18 changes: 9 additions & 9 deletions src/main/java/frc/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import frc.robot.commands.arm.Brake;
import frc.robot.commands.climb.Shift;
import frc.robot.commands.hatch.ExtendHatchManipulator;
import frc.robot.commands.hatch.RetractHatchManipulator;
import frc.robot.commands.hatch.SetHatchExtender;

public class OI {

Expand All @@ -26,8 +26,8 @@ public class OI {

private JoystickButton extendHatchManipulatorButton;
private JoystickButton retractHatchManipulatorButton;
private JoystickButton diskBrakeEngage;
private JoystickButton diskBrakeDisengage;
private JoystickButton extendHatcher;
private JoystickButton retractHatcher;

private JoystickButton engageButton;
private JoystickButton disengageButton;
Expand All @@ -38,14 +38,14 @@ private OI() {
xbox = new XboxController(RobotMap.OI.XBOX);

// Xbox binds
extendHatchManipulatorButton = new JoystickButton(xbox, RobotMap.OI.EXTEND_HATCH_MANIPULATOR_BUTTON);
retractHatchManipulatorButton = new JoystickButton(xbox, RobotMap.OI.RETRACT_HATCH_MANIPULATOR_BUTTON);
diskBrakeEngage = new JoystickButton(xbox, RobotMap.OI.ENGAGE_DISK_BRAKE);
diskBrakeDisengage = new JoystickButton(xbox, RobotMap.OI.DISENGAGE_DISK_BRAKE);
diskBrakeEngage.whenPressed(new Brake(true));
diskBrakeDisengage.whenPressed(new Brake(false));
extendHatchManipulatorButton = new JoystickButton(xbox, RobotMap.OI.EJECT_HATCH);
retractHatchManipulatorButton = new JoystickButton(xbox, RobotMap.OI.RESET_EJECTOR);
extendHatcher = new JoystickButton(xbox, RobotMap.OI.EXTEND_HATCHER);
retractHatcher = new JoystickButton(xbox, RobotMap.OI.RETRACT_HATCHER);
extendHatchManipulatorButton.whenPressed(new ExtendHatchManipulator());
retractHatchManipulatorButton.whenPressed(new RetractHatchManipulator());
extendHatcher.whenPressed(new SetHatchExtender(true));
retractHatcher.whenPressed(new SetHatchExtender(false));
// Driver joystick binds
disengageButton = new JoystickButton(leftFlight, RobotMap.OI.SHIFT_DISENGAGE_BUTTON);
engageButton = new JoystickButton(leftFlight, RobotMap.OI.SHIFT_ENGAGE_BUTTON);
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/frc/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class RobotMap {
// public static final int rangefinderModule = 1;

public class DRIVETRAIN {
public static final int LEFT_MASTER_CHANNEL = 0;
public static final int LEFT_MASTER_CHANNEL = 17;
Copy link
Member Author

@c-x-berger c-x-berger Feb 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blame REV.

CAN ID of 0 now considered ‘unconfigured’ and will not be enabled.

💢

public static final int LEFT_FOLLOWER_ONE_CHANNEL = 1;
public static final int LEFT_FOLLOWER_TWO_CHANNEL = 2;
public static final int RIGHT_MASTER_CHANNEL = 13;
Expand Down Expand Up @@ -55,6 +55,8 @@ public class HATCH_MANIPULATOR {

public static final int CENTER_FORWARD_CHANNEL = 5;
public static final int CENTER_REVERSE_CHANNEL = 6;

public static final int EXTENDER = 7;
}

public class CARGO_MANIPULATOR {
Expand All @@ -73,10 +75,10 @@ public class OI {
public static final int SHIFT_ENGAGE_BUTTON = 5;
public static final int SHIFT_DISENGAGE_BUTTON = 11;

public static final int ENGAGE_DISK_BRAKE = 1; // A
public static final int DISENGAGE_DISK_BRAKE = 2; // B
public static final int EXTEND_HATCH_MANIPULATOR_BUTTON = 3; // X
public static final int RETRACT_HATCH_MANIPULATOR_BUTTON = 4; // Y
public static final int EXTEND_HATCHER = 1; // A
public static final int RETRACT_HATCHER = 2; // B
public static final int EJECT_HATCH = 3; // X
public static final int RESET_EJECTOR = 4; // Y
}

public static final int PRESSURE_SENSOR_PORT = 0;
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/frc/robot/commands/arm/TwistArm.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ public TwistArm() {
protected void execute() {
boolean lBump = OI.getInstance().getXboxLeftBumper();
boolean rBump = OI.getInstance().getXboxRightBumper();
if (rBump) {
CargoManipulatorArm.getInstance().lift(0.5);
} else if (lBump) {
CargoManipulatorArm.getInstance().lift(-0.5);
if (lBump) {
CargoManipulatorArm.getInstance().setBrake(true);
CargoManipulatorArm.getInstance().lift(0.75);
} else if (rBump) {
CargoManipulatorArm.getInstance().setBrake(true);
CargoManipulatorArm.getInstance().lift(-0.20);
} else {
CargoManipulatorArm.getInstance().lift(0);
CargoManipulatorArm.getInstance().setBrake(false);
}
}

Expand Down
24 changes: 24 additions & 0 deletions src/main/java/frc/robot/commands/hatch/SetHatchExtender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package frc.robot.commands.hatch;

import edu.wpi.first.wpilibj.command.Command;
import frc.robot.subsystems.HatchManipulator;

public class SetHatchExtender extends Command {

private boolean extended;

public SetHatchExtender(boolean e) {
requires(HatchManipulator.getInstance());
this.extended = e;
}

@Override
protected void execute() {
HatchManipulator.getInstance().setExtended(extended);
}

@Override
protected boolean isFinished() {
return true;
}
}
5 changes: 2 additions & 3 deletions src/main/java/frc/robot/sensors/PressureSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ private double getVoltageOut() {
}

/**
* Return the pressure, in PSI. Has a tolerance of 1.5% according to REV.
* Return the pressure, in PSI. This function was made by a really confident linear regression.
*
* @return Measured pressure, in PSI.
* @see "http://www.revrobotics.com/content/docs/REV-11-1107-DS.pdf"
*/
public double getPressure() {
return (250 * (this.getVoltageOut() / VCC)) - 25;
return 31.8 * this.getVoltageOut() - 8.07;
}

public static PressureSensor getInstance() {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/frc/robot/subsystems/HatchManipulator.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package frc.robot.subsystems;

import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.command.Subsystem;
import frc.robot.RobotMap;

public class HatchManipulator extends Subsystem {
private static final HatchManipulator INSTANCE = new HatchManipulator();
private DoubleSolenoid pusher;
private DoubleSolenoid centerRod;
private Solenoid extender;
// Put methods for controlling this subsystem
// here. Call these from Commands.

Expand All @@ -21,6 +23,8 @@ private HatchManipulator() {

this.centerRod = new DoubleSolenoid(RobotMap.HATCH_MANIPULATOR.CENTER_FORWARD_CHANNEL, RobotMap.HATCH_MANIPULATOR.CENTER_REVERSE_CHANNEL);
this.centerRod.set(DoubleSolenoid.Value.kReverse);

extender = new Solenoid(RobotMap.HATCH_MANIPULATOR.EXTENDER);
}

public void ejectHatch() {
Expand All @@ -31,6 +35,10 @@ public void retractPusher() {
this.pusher.set(DoubleSolenoid.Value.kReverse);
}

public void setExtended(boolean extended) {
this.extender.set(extended);
}

public void initDefaultCommand() {
// TODO: Set the default command, if any, for a subsystem here. Example:
// setDefaultCommand(new MySpecialCommand());
Expand Down