-
Notifications
You must be signed in to change notification settings - Fork 11
Finished final tweaks for lift, also includes tests #78
Changes from all commits
5bfb1c5
814628a
1879b6b
8d5328f
f2a2bec
7405909
07d1fb8
c2fba8b
9f30235
8ee9a13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,11 @@ | |
|
||
package org.usfirst.frc.team199.Robot2018; | ||
|
||
import org.usfirst.frc.team199.Robot2018.commands.CloseIntake; | ||
import org.usfirst.frc.team199.Robot2018.commands.IntakeCube; | ||
import org.usfirst.frc.team199.Robot2018.commands.LowerIntake; | ||
import org.usfirst.frc.team199.Robot2018.commands.OpenIntake; | ||
import org.usfirst.frc.team199.Robot2018.commands.OuttakeCube; | ||
import org.usfirst.frc.team199.Robot2018.commands.PIDMove; | ||
import org.usfirst.frc.team199.Robot2018.commands.PIDTurn; | ||
import org.usfirst.frc.team199.Robot2018.commands.ResetEncoders; | ||
|
@@ -35,21 +40,21 @@ public class OI { | |
private JoystickButton shiftLowGearButton; | ||
private JoystickButton shiftHighGearButton; | ||
private JoystickButton shiftDriveTypeButton; | ||
private JoystickButton PIDMoveButton; | ||
private JoystickButton PIDTurnButton; | ||
private JoystickButton pIDMoveButton; | ||
private JoystickButton pIDTurnButton; | ||
private JoystickButton resetEncButton; | ||
private JoystickButton MoveLiftUpButton; | ||
private JoystickButton MoveLiftDownButton; | ||
private JoystickButton moveLiftUpButton; | ||
private JoystickButton moveLiftDownButton; | ||
public Joystick rightJoy; | ||
private JoystickButton updatePIDConstantsButton; | ||
private JoystickButton updateEncoderDPPButton; | ||
public Joystick manipulator; | ||
private JoystickButton closeIntake; | ||
private JoystickButton openIntake; | ||
private JoystickButton raiseIntake; | ||
private JoystickButton lowerIntake; | ||
private JoystickButton intake; | ||
private JoystickButton outake; | ||
public static Joystick manipulator; | ||
private JoystickButton closeIntakeButton; | ||
private JoystickButton openIntakeButton; | ||
private JoystickButton raiseIntakeButton; | ||
private JoystickButton lowerIntakeButton; | ||
private JoystickButton intakeCubeButton; | ||
private JoystickButton outtakeCubeButton; | ||
|
||
public int getButton(String key, int def) { | ||
if (!SmartDashboard.containsKey("Button/" + key)) { | ||
|
@@ -65,13 +70,13 @@ public OI() { | |
leftJoy = new Joystick(0); | ||
shiftDriveTypeButton = new JoystickButton(leftJoy, getButton("Shift Drive Type", 2)); | ||
shiftDriveTypeButton.whenPressed(new ShiftDriveType()); | ||
PIDMoveButton = new JoystickButton(leftJoy, getButton("PID Move", 7)); | ||
PIDMoveButton | ||
pIDMoveButton = new JoystickButton(leftJoy, getButton("PID Move", 7)); | ||
pIDMoveButton | ||
.whenPressed(new PIDMove(Robot.sd.getConst("Move Targ", 24), Robot.dt, Robot.sd, RobotMap.distEncAvg)); | ||
PIDTurnButton = new JoystickButton(leftJoy, getButton("PID Turn", 8)); | ||
pIDTurnButton = new JoystickButton(leftJoy, getButton("PID Turn", 8)); | ||
// PIDTurnButton.whenPressed(new PIDTurn(Robot.getConst("Turn Targ", 90), | ||
// Robot.dt, Robot.sd RobotMap.fancyGyro)); | ||
PIDTurnButton | ||
pIDTurnButton | ||
.whenReleased(new PIDTurn(Robot.getConst("Turn Targ", 90), Robot.dt, Robot.sd, RobotMap.fancyGyro)); | ||
resetEncButton = new JoystickButton(leftJoy, getButton("Reset Dist Enc", 10)); | ||
resetEncButton.whenPressed(new ResetEncoders()); | ||
|
@@ -85,27 +90,24 @@ public OI() { | |
updatePIDConstantsButton.whenPressed(new UpdatePIDConstants()); | ||
updateEncoderDPPButton = new JoystickButton(rightJoy, getButton("Get Encoder Dist Per Pulse", 9)); | ||
updateEncoderDPPButton.whenPressed(new SetDistancePerPulse()); | ||
MoveLiftUpButton = new JoystickButton(rightJoy, getButton("Run Lift Motor Up", 10)); | ||
MoveLiftDownButton = new JoystickButton(rightJoy, getButton("Run Lift Motor Down", 11)); | ||
MoveLiftUpButton.whileHeld(new RunLift(Robot.lift, true)); | ||
MoveLiftDownButton.whileHeld(new RunLift(Robot.lift, false)); | ||
|
||
// manipulator = new Joystick(2); | ||
// closeIntake = new JoystickButton(manipulator, getButton("Close Intake | ||
// Button", 1)); | ||
// closeIntake.whenPressed(new CloseIntake()); | ||
// openIntake = new JoystickButton(manipulator, getButton("Open Intake Button", | ||
// 2)); | ||
// openIntake.whenPressed(new OpenIntake()); | ||
// raiseIntake = new JoystickButton(manipulator, getButton("Raise Intake | ||
// Button", 3)); | ||
// raiseIntake.whenPressed(new RaiseIntake()); | ||
// lowerIntake = new JoystickButton(manipulator, getButton("Lower Intake | ||
// Button", 4)); | ||
// lowerIntake.whenPressed(new LowerIntake()); | ||
// intake = new JoystickButton(manipulator, getButton("Intake Button", 5)); | ||
// intake.whenPressed(new IntakeCube()); | ||
// outake = new JoystickButton(manipulator, getButton("Outake Button", 6)); | ||
// outake.whenPressed(new OutakeCube()); | ||
// closeIntakeButton = new JoystickButton(manipulator, getButton("Close Intake Button", 1)); | ||
// closeIntakeButton.whenPressed(new CloseIntake()); | ||
// openIntakeButton = new JoystickButton(manipulator, getButton("Open Intake Button", 2)); | ||
// openIntakeButton.whenPressed(new OpenIntake()); | ||
// raiseIntakeButton = new JoystickButton(manipulator, getButton("Raise Intake Button", 3)); | ||
// raiseIntakeButton.whenPressed(new RaiseIntake()); | ||
// lowerIntakeButton = new JoystickButton(manipulator, getButton("Lower Intake Button", 4)); | ||
// lowerIntakeButton.whenPressed(new LowerIntake()); | ||
// intakeCubeButton = new JoystickButton(manipulator, getButton("Intake Button", 5)); | ||
// intakeCubeButton.whenPressed(new IntakeCube()); | ||
// outtakeCubeButton = new JoystickButton(manipulator, getButton("Outtake Button", 6)); | ||
// outtakeCubeButton.whenPressed(new OuttakeCube()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason you changed these comments to start with a tab rather than a space? Did you use the eclipse auto-formatter? |
||
|
||
/*MoveLiftUpButton = new JoystickButton(manipulator, getButton("Run Lift Motor Up", 7)); | ||
MoveLiftDownButton = new JoystickButton(manipulator, getButton("Run Lift Motor Down", 8)); | ||
MoveLiftUpButton.whileHeld(new RunLift(Robot.lift, true)); | ||
MoveLiftDownButton.whileHeld(new RunLift(Robot.lift, false));*/ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,12 +36,15 @@ public class RobotMap { | |
|
||
public static PowerDistributionPanel pdp; | ||
|
||
public static WPI_TalonSRX liftMotor; | ||
public static WPI_VictorSPX liftMotorA; | ||
public static WPI_TalonSRX liftMotorB; | ||
public static WPI_TalonSRX liftMotorC; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems fine for now, but according to Dean, there will be a master and two slaves, so just a thing to note right now so that we can change to names for readability later. |
||
public static SpeedControllerGroup liftMotors; | ||
public static Encoder liftEnc; | ||
public static DigitalSource liftEncPort1; | ||
public static DigitalSource liftEncPort2; | ||
|
||
public static WPI_TalonSRX climberMotor; | ||
//public static WPI_TalonSRX climberMotor; | ||
|
||
public static VictorSP leftIntakeMotor; | ||
public static VictorSP rightIntakeMotor; | ||
|
@@ -118,15 +121,18 @@ private void configSPX(WPI_VictorSPX mc) { | |
|
||
public RobotMap() { | ||
pdp = new PowerDistributionPanel(); | ||
|
||
liftMotor = new WPI_TalonSRX(getPort("LiftTalonSRX", 7)); | ||
configSRX(liftMotor); | ||
|
||
liftMotorA = new WPI_VictorSPX(getPort("LiftVictorSPX", 5)); | ||
configSPX(liftMotorA); | ||
liftMotorB = new WPI_TalonSRX(getPort("1LiftTalonSRX", 6)); | ||
configSRX(liftMotorB); | ||
liftMotorC = new WPI_TalonSRX(getPort("2LiftTalonSRX", 7)); | ||
configSRX(liftMotorC); | ||
liftMotors = new SpeedControllerGroup(liftMotorB, liftMotorA, liftMotorC); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, the keys are a bit weird because 1) The keys are sorted alphabetically so the keys will not appear together and 2) Viewing "LiftVictorSPX" w/o the others might make people think that that is the only lift VictorSPX. I suggest changing to "Lift Motor Master", "Lift Motor Slave 1" etc. |
||
liftEncPort1 = new DigitalInput(getPort("1LiftEnc", 4)); | ||
liftEncPort2 = new DigitalInput(getPort("2LiftEnc", 5)); | ||
liftEnc = new Encoder(liftEncPort1, liftEncPort2); | ||
liftEnc.setPIDSourceType(PIDSourceType.kDisplacement); | ||
climberMotor = new WPI_TalonSRX(getPort("ClimberTalonSRX", 6)); | ||
configSRX(climberMotor); | ||
|
||
leftIntakeMotor = new VictorSP(getPort("IntakeLeftVictorSP", 9)); | ||
rightIntakeMotor = new VictorSP(getPort("IntakeRightVictorSP", 8)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,55 +14,40 @@ | |
*/ | ||
public class AutoLift extends Command implements PIDOutput{ | ||
/** | ||
* All distances are - 1 foot for initial height of intake and + 3 inches for wiggle room for dropping cubes | ||
* Also, acutal distances are divided by 3 because according to cad, the lift will have a 1:3 ratio from winch | ||
* All distances are measured from bottom of cube and + 3 inches for wiggle room for dropping cubes | ||
* Also, actual distances are divided by 3 because according to cad, the lift will have a 1:3 ratio from winch | ||
* to actual height. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be clearer to just include the factor of 3 in the encoder's distance per pulse. |
||
*/ | ||
|
||
/** | ||
* Distance to switch | ||
* 18.75 inches in starting position (this measurement is the fence that surrounds the switch) | ||
* 9.75 / 3 for ratio = 3.25 | ||
* 21.75 / 3 for ratio = 7.25 | ||
*/ | ||
private final double SWITCH_DIST = 3.25; | ||
private final double SWITCH_DIST = 7.25; | ||
/** | ||
* Distance to scale | ||
* 5 feet starting | ||
* 51 / 3 = 17 | ||
* 63 / 3 = 21 | ||
*/ | ||
private final double SCALE_DIST = 17; | ||
private final double SCALE_DIST = 21; | ||
/** | ||
* Distance to bar | ||
* 72 / 3 = 24 | ||
* 87 / 3 = 29 | ||
* 7 feet starting; bar distance should be changed because I'm not aware how climber mech will be positioned | ||
*/ | ||
private final double BAR_DIST = 24; | ||
private final double BAR_DIST = 29; | ||
private double desiredDist = 0; | ||
private double currDist = 0; | ||
private double currDist; | ||
private LiftInterface lift; | ||
private Position desiredPos; | ||
|
||
private PIDController liftController; | ||
|
||
public AutoLift(Position stage, LiftInterface lift) { | ||
// Use requires() here to declare subsystem dependencies | ||
// eg. requires(chassis); | ||
this.lift = lift; | ||
requires(Robot.lift); | ||
switch(lift.getCurrPos()) { | ||
case GROUND: | ||
currDist = 0; | ||
break; | ||
case SWITCH: | ||
currDist = SWITCH_DIST; | ||
break; | ||
case SCALE: | ||
currDist = SCALE_DIST; | ||
break; | ||
case BAR: | ||
currDist = BAR_DIST; | ||
break; | ||
} | ||
currDist = lift.getHeight(); | ||
switch(stage) { | ||
case GROUND: | ||
desiredDist = -currDist; | ||
|
@@ -86,7 +71,6 @@ public AutoLift(Position stage, LiftInterface lift) { | |
|
||
// Called just before this Command runs the first time | ||
protected void initialize() { | ||
lift.resetEnc(); | ||
// input is in inches | ||
//liftController.setInputRange(-Robot.getConst("Max High Speed", 204), Robot.getConst("Max High Speed", 204)); | ||
// output in "motor units" (arcade and tank only accept values [-1, 1] | ||
|
@@ -104,7 +88,7 @@ protected void execute() { | |
// Make this return true when this Command no longer needs to run execute() | ||
protected boolean isFinished() { | ||
if(liftController.onTarget()) { | ||
lift.setTargetPosition(desiredPos); | ||
lift.setCurrPosition(desiredPos); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why this lift.setCur.... cannot be written in end()? |
||
return true; | ||
} | ||
return false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
*/ | ||
public class Climber extends Subsystem implements ClimberInterface { | ||
|
||
private final WPI_TalonSRX climberMotor = RobotMap.climberMotor; | ||
//private final WPI_TalonSRX climberMotor = RobotMap.climberMotor; | ||
|
||
|
||
/** | ||
|
@@ -52,7 +52,7 @@ public void attachToBar() { | |
* stops the climber | ||
*/ | ||
public void stopClimber() { | ||
climberMotor.stopMotor(); | ||
//climberMotor.stopMotor(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some commands/other people may call this and expect it to work, maybe change the javadoc? |
||
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the right track, can we get pidMoveButton instead of pIDMoveButton?