Skip to content

Commit 209dd56

Browse files
committed
Merge branch 'master' of https://github.com/FRC1519/2020-Robot
2 parents 2bd86cd + c708917 commit 209dd56

File tree

6 files changed

+173
-57
lines changed

6 files changed

+173
-57
lines changed

src/main/java/org/mayheminc/robot2020/RobotContainer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class RobotContainer {
3939
public static final Targeting targeting = new Targeting();
4040
// public static final Compressor compressor = new Compressor();
4141
public static PidTuner pidtuner;
42+
public static final Chimney chimney = new Chimney();
4243

4344
// Operator Inputs
4445
public static final MayhemDriverStick DRIVER_STICK = new MayhemDriverStick();
@@ -67,7 +68,8 @@ public static void init() {
6768

6869
private void configureDefaultCommands() {
6970
drive.setDefaultCommand(new DriveDefault());
70-
intake.setDefaultCommand(new IntakeExtenderVBus());
71+
// intake.setDefaultCommand(new IntakeExtenderVBus());
72+
magazine.setDefaultCommand(new MagazineDefault());
7173
}
7274

7375
private void configureAutonomousPrograms() {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package org.mayheminc.robot2020.commands;
9+
10+
import org.mayheminc.robot2020.RobotContainer;
11+
12+
import edu.wpi.first.wpilibj2.command.CommandBase;
13+
14+
public class MagazineDefault extends CommandBase {
15+
/**
16+
* Creates a new MagazineDefault.
17+
*/
18+
public MagazineDefault() {
19+
// Use addRequirements() here to declare subsystem dependencies.
20+
addRequirements(RobotContainer.magazine);
21+
}
22+
23+
// Called when the command is initially scheduled.
24+
@Override
25+
public void initialize() {
26+
}
27+
28+
// Called every time the scheduler runs while the command is scheduled.
29+
@Override
30+
public void execute() {
31+
RobotContainer.magazine.setTurntableSpeed(RobotContainer.OPERATOR_PAD.getLeftYAxis());
32+
33+
}
34+
35+
// Called once the command ends or is interrupted.
36+
@Override
37+
public void end(boolean interrupted) {
38+
}
39+
40+
// Returns true when the command should end.
41+
@Override
42+
public boolean isFinished() {
43+
return false;
44+
}
45+
}

src/main/java/org/mayheminc/robot2020/commands/MagazineSetChimney.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public MagazineSetChimney(double d) {
2626
// Called when the command is initially scheduled.
2727
@Override
2828
public void initialize() {
29-
RobotContainer.magazine.setChimneySpeed(m_speed);
29+
RobotContainer.chimney.setChimneySpeed(m_speed);
3030
}
3131

3232
// Called once the command ends or is interrupted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package org.mayheminc.robot2020.subsystems;
9+
10+
import com.ctre.phoenix.motorcontrol.ControlMode;
11+
import com.ctre.phoenix.motorcontrol.NeutralMode;
12+
13+
import org.mayheminc.robot2020.Constants;
14+
import org.mayheminc.util.MayhemTalonSRX;
15+
16+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
17+
import edu.wpi.first.wpilibj2.command.SubsystemBase;
18+
19+
public class Chimney extends SubsystemBase {
20+
private final MayhemTalonSRX chimneyTalon = new MayhemTalonSRX(Constants.Talon.MAGAZINE_CHIMNEY);
21+
22+
/**
23+
* Creates a new Chimney.
24+
*/
25+
public Chimney() {
26+
chimneyTalon.setNeutralMode(NeutralMode.Coast);
27+
chimneyTalon.configNominalOutputVoltage(+0.0f, -0.0f);
28+
chimneyTalon.configPeakOutputVoltage(+12.0, -12.0);
29+
}
30+
31+
@Override
32+
public void periodic() {
33+
// This method will be called once per scheduler run
34+
updateSmartDashboard();
35+
monitorTurntableMovement();
36+
}
37+
38+
void updateSmartDashboard() {
39+
SmartDashboard.putNumber("Magazine Turntable", chimneyTalon.getSpeed());
40+
}
41+
42+
void monitorTurntableMovement() {
43+
44+
}
45+
46+
public void setChimneySpeed(double speed) {
47+
chimneyTalon.set(ControlMode.PercentOutput, speed);
48+
}
49+
}

src/main/java/org/mayheminc/robot2020/subsystems/Magazine.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111
import edu.wpi.first.wpilibj2.command.SubsystemBase;
1212

1313
import com.ctre.phoenix.motorcontrol.ControlMode;
14+
import com.ctre.phoenix.motorcontrol.FeedbackDevice;
1415
import com.ctre.phoenix.motorcontrol.NeutralMode;
1516

1617
import org.mayheminc.robot2020.Constants;
1718
import org.mayheminc.util.MayhemTalonSRX;
1819

1920
public class Magazine extends SubsystemBase {
2021
private final MayhemTalonSRX turntableTalon = new MayhemTalonSRX(Constants.Talon.MAGAZINE_TURNTABLE);
21-
private final MayhemTalonSRX chimneyTalen = new MayhemTalonSRX(Constants.Talon.MAGAZINE_CHIMNEY);
2222

2323
/**
2424
* Creates a new Magazine.
2525
*/
2626
public Magazine() {
2727
ConfigureTalon(turntableTalon);
28-
ConfigureTalon(chimneyTalen);
28+
turntableTalon.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder);
2929
}
3030

3131
private void ConfigureTalon(MayhemTalonSRX talon) {
@@ -37,15 +37,20 @@ private void ConfigureTalon(MayhemTalonSRX talon) {
3737
@Override
3838
public void periodic() {
3939
// This method will be called once per scheduler run
40+
updateSmartDashboard();
41+
monitorTurntableMovement();
42+
}
43+
44+
void updateSmartDashboard() {
4045
SmartDashboard.putNumber("Magazine Turntable", turntableTalon.getSpeed());
4146
}
4247

43-
public void setTurntableSpeed(double speed) {
44-
turntableTalon.set(ControlMode.PercentOutput, speed);
48+
void monitorTurntableMovement() {
49+
4550
}
4651

47-
public void setChimneySpeed(double speed) {
48-
chimneyTalen.set(ControlMode.PercentOutput, speed);
52+
public void setTurntableSpeed(double speed) {
53+
turntableTalon.set(ControlMode.PercentOutput, speed);
4954
}
5055

5156
}

src/main/java/org/mayheminc/util/MayhemOperatorPad.java

Lines changed: 64 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,76 @@
66

77
public class MayhemOperatorPad {
88

9-
public final class OPERATOR_PAD_AXIS {
10-
public static final int OPERATOR_PAD_LEFT_X_AXIS = 0;
11-
public static final int OPERATOR_PAD_LEFT_Y_AXIS = 1;
12-
public static final int OPERATOR_PAD_RIGHT_X_AXIS = 2;
13-
public static final int OPERATOR_PAD_RIGHT_Y_AXIS = 3;
14-
}
15-
16-
public final Joystick OPERATOR_PAD = new Joystick(Joysticks.OPERATOR_GAMEPAD);
17-
public final Button OPERATOR_PAD_BUTTON_ONE = new JoystickButton(OPERATOR_PAD, 1);
18-
public final Button OPERATOR_PAD_BUTTON_TWO = new JoystickButton(OPERATOR_PAD, 2);
19-
public final Button OPERATOR_PAD_BUTTON_THREE = new JoystickButton(OPERATOR_PAD, 3);
20-
public final Button OPERATOR_PAD_BUTTON_FOUR = new JoystickButton(OPERATOR_PAD, 4);
21-
public final Button OPERATOR_PAD_BUTTON_FIVE = new JoystickButton(OPERATOR_PAD, 5);
22-
public final Button OPERATOR_PAD_BUTTON_SIX = new JoystickButton(OPERATOR_PAD, 6);
23-
public final Button OPERATOR_PAD_BUTTON_SEVEN = new JoystickButton(OPERATOR_PAD, 7);
24-
public final Button OPERATOR_PAD_BUTTON_EIGHT = new JoystickButton(OPERATOR_PAD, 8);
25-
public final Button OPERATOR_PAD_BUTTON_NINE = new JoystickButton(OPERATOR_PAD, 9);
26-
public final Button OPERATOR_PAD_BUTTON_TEN = new JoystickButton(OPERATOR_PAD, 10);
27-
public final Button OPERATOR_PAD_BUTTON_ELEVEN = new JoystickButton(OPERATOR_PAD, 11);
28-
public final Button OPERATOR_PAD_BUTTON_TWELVE = new JoystickButton(OPERATOR_PAD, 12);
29-
public final Button FORCE_FIRE_BUTTON = new AndJoystickButton(OPERATOR_PAD, 5, OPERATOR_PAD, 7);
30-
31-
public final JoystickPOVButton OPERATOR_PAD_D_PAD_LEFT = new JoystickPOVButton(OPERATOR_PAD, 270);
32-
public final JoystickPOVButton OPERATOR_PAD_D_PAD_RIGHT = new JoystickPOVButton(OPERATOR_PAD, 90);
33-
public final JoystickPOVButton OPERATOR_PAD_D_PAD_UP = new JoystickPOVButton(OPERATOR_PAD, 0);
34-
public final JoystickPOVButton OPERATOR_PAD_D_PAD_DOWN = new JoystickPOVButton(OPERATOR_PAD, 180);
35-
36-
// Operator Control Buttons
37-
public final JoystickAxisButton OPERATOR_PAD_LEFT_Y_AXIS_UP = new JoystickAxisButton(OPERATOR_PAD,
38-
OPERATOR_PAD_AXIS.OPERATOR_PAD_LEFT_Y_AXIS, JoystickAxisButton.NEGATIVE_ONLY);
39-
public final JoystickAxisButton OPERATOR_PAD_LEFT_Y_AXIS_DOWN = new JoystickAxisButton(OPERATOR_PAD,
40-
OPERATOR_PAD_AXIS.OPERATOR_PAD_LEFT_Y_AXIS, JoystickAxisButton.POSITIVE_ONLY);
41-
public final JoystickAxisButton OPERATOR_PAD_RIGHT_Y_AXIS_UP = new JoystickAxisButton(OPERATOR_PAD,
42-
OPERATOR_PAD_AXIS.OPERATOR_PAD_RIGHT_Y_AXIS, JoystickAxisButton.NEGATIVE_ONLY);
43-
public final JoystickAxisButton OPERATOR_PAD_RIGHT_Y_AXIS_DOWN = new JoystickAxisButton(OPERATOR_PAD,
44-
OPERATOR_PAD_AXIS.OPERATOR_PAD_RIGHT_Y_AXIS, JoystickAxisButton.POSITIVE_ONLY);
45-
9+
public final class OPERATOR_PAD_AXIS {
4610
public static final int OPERATOR_PAD_LEFT_X_AXIS = 0;
4711
public static final int OPERATOR_PAD_LEFT_Y_AXIS = 1;
4812
public static final int OPERATOR_PAD_RIGHT_X_AXIS = 2;
4913
public static final int OPERATOR_PAD_RIGHT_Y_AXIS = 3;
14+
}
15+
16+
public final Joystick OPERATOR_PAD = new Joystick(Joysticks.OPERATOR_GAMEPAD);
17+
public final Button OPERATOR_PAD_BUTTON_ONE = new JoystickButton(OPERATOR_PAD, 1);
18+
public final Button OPERATOR_PAD_BUTTON_TWO = new JoystickButton(OPERATOR_PAD, 2);
19+
public final Button OPERATOR_PAD_BUTTON_THREE = new JoystickButton(OPERATOR_PAD, 3);
20+
public final Button OPERATOR_PAD_BUTTON_FOUR = new JoystickButton(OPERATOR_PAD, 4);
21+
public final Button OPERATOR_PAD_BUTTON_FIVE = new JoystickButton(OPERATOR_PAD, 5);
22+
public final Button OPERATOR_PAD_BUTTON_SIX = new JoystickButton(OPERATOR_PAD, 6);
23+
public final Button OPERATOR_PAD_BUTTON_SEVEN = new JoystickButton(OPERATOR_PAD, 7);
24+
public final Button OPERATOR_PAD_BUTTON_EIGHT = new JoystickButton(OPERATOR_PAD, 8);
25+
public final Button OPERATOR_PAD_BUTTON_NINE = new JoystickButton(OPERATOR_PAD, 9);
26+
public final Button OPERATOR_PAD_BUTTON_TEN = new JoystickButton(OPERATOR_PAD, 10);
27+
public final Button OPERATOR_PAD_BUTTON_ELEVEN = new JoystickButton(OPERATOR_PAD, 11);
28+
public final Button OPERATOR_PAD_BUTTON_TWELVE = new JoystickButton(OPERATOR_PAD, 12);
29+
public final Button FORCE_FIRE_BUTTON = new AndJoystickButton(OPERATOR_PAD, 5, OPERATOR_PAD, 7);
30+
31+
public final JoystickPOVButton OPERATOR_PAD_D_PAD_LEFT = new JoystickPOVButton(OPERATOR_PAD, 270);
32+
public final JoystickPOVButton OPERATOR_PAD_D_PAD_RIGHT = new JoystickPOVButton(OPERATOR_PAD, 90);
33+
public final JoystickPOVButton OPERATOR_PAD_D_PAD_UP = new JoystickPOVButton(OPERATOR_PAD, 0);
34+
public final JoystickPOVButton OPERATOR_PAD_D_PAD_DOWN = new JoystickPOVButton(OPERATOR_PAD, 180);
35+
36+
// Operator Control Buttons
37+
public final JoystickAxisButton OPERATOR_PAD_LEFT_Y_AXIS_UP = new JoystickAxisButton(OPERATOR_PAD,
38+
OPERATOR_PAD_AXIS.OPERATOR_PAD_LEFT_Y_AXIS, JoystickAxisButton.NEGATIVE_ONLY);
39+
public final JoystickAxisButton OPERATOR_PAD_LEFT_Y_AXIS_DOWN = new JoystickAxisButton(OPERATOR_PAD,
40+
OPERATOR_PAD_AXIS.OPERATOR_PAD_LEFT_Y_AXIS, JoystickAxisButton.POSITIVE_ONLY);
41+
public final JoystickAxisButton OPERATOR_PAD_RIGHT_Y_AXIS_UP = new JoystickAxisButton(OPERATOR_PAD,
42+
OPERATOR_PAD_AXIS.OPERATOR_PAD_RIGHT_Y_AXIS, JoystickAxisButton.NEGATIVE_ONLY);
43+
public final JoystickAxisButton OPERATOR_PAD_RIGHT_Y_AXIS_DOWN = new JoystickAxisButton(OPERATOR_PAD,
44+
OPERATOR_PAD_AXIS.OPERATOR_PAD_RIGHT_Y_AXIS, JoystickAxisButton.POSITIVE_ONLY);
45+
46+
public static final int OPERATOR_PAD_LEFT_X_AXIS = 0;
47+
public static final int OPERATOR_PAD_LEFT_Y_AXIS = 1;
48+
public static final int OPERATOR_PAD_RIGHT_X_AXIS = 2;
49+
public static final int OPERATOR_PAD_RIGHT_Y_AXIS = 3;
50+
51+
private static final double Y_AXIS_DEAD_ZONE_PERCENT = 0.15;
52+
private static final double X_AXIS_DEAD_ZONE_PERCENT = 0.15;
53+
54+
public double getLeftYAxis() {
55+
double value = OPERATOR_PAD.getRawAxis(OPERATOR_PAD_LEFT_Y_AXIS);
56+
return ApplyDeadZone(value, Y_AXIS_DEAD_ZONE_PERCENT);
57+
}
58+
59+
public double getLeftXAxis() {
60+
double value = OPERATOR_PAD.getRawAxis(OPERATOR_PAD_LEFT_X_AXIS);
61+
return ApplyDeadZone(value, X_AXIS_DEAD_ZONE_PERCENT);
62+
}
63+
64+
public double getRightYAxis() {
65+
double value = OPERATOR_PAD.getRawAxis(OPERATOR_PAD_RIGHT_Y_AXIS);
66+
return ApplyDeadZone(value, Y_AXIS_DEAD_ZONE_PERCENT);
67+
}
5068

51-
private static final double Y_AXIS_DEAD_ZONE_PERCENT = 0.15;
69+
public double getRightXAxis() {
70+
double value = OPERATOR_PAD.getRawAxis(OPERATOR_PAD_LEFT_X_AXIS);
71+
return ApplyDeadZone(value, X_AXIS_DEAD_ZONE_PERCENT);
72+
}
5273

53-
public double getLeftYAxis() {
54-
// SteeringX is the "X" axis of the right stick on the Driver Gamepad.
55-
double value = OPERATOR_PAD.getRawAxis(OPERATOR_PAD_LEFT_Y_AXIS);
56-
if (Math.abs(value) < Y_AXIS_DEAD_ZONE_PERCENT) {
57-
value = 0.0;
58-
}
74+
private double ApplyDeadZone(double value, double deadZone) {
5975

60-
// if the slow button is pressed, cut the steering value in half.
61-
// if (DRIVER_PAD_RIGHT_LOWER_TRIGGER_BUTTON.get()) {
62-
// value = value / 2.0;
63-
// }
64-
return value;
76+
if (Math.abs(value) < deadZone) {
77+
return 0;
6578
}
79+
return value;
80+
}
6681
}

0 commit comments

Comments
 (0)