diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index 202f647..eb93394 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -20,6 +20,7 @@ import frc4388.robot.commands.DriveToDistanceMM; import frc4388.robot.commands.DriveToDistancePID; import frc4388.robot.commands.RunIntakeWithTriggers; import frc4388.robot.subsystems.Drive; +import frc4388.robot.subsystems.Elevator; import frc4388.robot.subsystems.Intake; import frc4388.robot.subsystems.LED; import frc4388.utility.LEDPatterns; @@ -38,6 +39,7 @@ public class RobotContainer { private final Drive m_robotDrive = new Drive(); private final LED m_robotLED = new LED(); private final Intake m_robotIntake = new Intake(); + private final Elevator m_robotElevator = new Elevator(); /* Controllers */ private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID); @@ -56,6 +58,10 @@ public class RobotContainer { getDriverController().getRightXAxis()), m_robotDrive)); // drives motor with input from triggers on the opperator controller m_robotIntake.setDefaultCommand(new RunIntakeWithTriggers(m_robotIntake, getOperatorController())); + // moves elevator with one-axis input from the driver controller + m_robotElevator.setDefaultCommand(new RunCommand(() -> m_robotElevator.moveElevator( + getOperatorController().getLeftYAxis()), m_robotElevator + )); // continually sends updates to the Blinkin LED controller to keep the lights on m_robotLED.setDefaultCommand(new RunCommand(() -> m_robotLED.updateLED(), m_robotLED)); } diff --git a/src/main/java/frc4388/robot/subsystems/Elevator.java b/src/main/java/frc4388/robot/subsystems/Elevator.java index 19712e8..4af5ef1 100644 --- a/src/main/java/frc4388/robot/subsystems/Elevator.java +++ b/src/main/java/frc4388/robot/subsystems/Elevator.java @@ -7,24 +7,42 @@ package frc4388.robot.subsystems; +import com.ctre.phoenix.motorcontrol.InvertType; +import com.ctre.phoenix.motorcontrol.NeutralMode; import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc4388.robot.Constants.ElevatorConstants; public class Elevator extends SubsystemBase { - - public WPI_TalonSRX m_talon1; - public WPI_TalonSRX m_talon2; + + public WPI_TalonSRX m_talon1 = new WPI_TalonSRX(ElevatorConstants.TALON_1); + public WPI_TalonSRX m_talon2 = new WPI_TalonSRX(ElevatorConstants.TALON_2); /** * Creates a new Elevator. */ public Elevator() { + m_talon1.configFactoryDefault(); + m_talon2.configFactoryDefault(); + m_talon2.follow(m_talon1); + + m_talon1.setNeutralMode(NeutralMode.Brake); + m_talon2.setNeutralMode(NeutralMode.Brake); + + m_talon1.setInverted(false); + m_talon2.setInverted(false); + m_talon1.setInverted(InvertType.FollowMaster); + m_talon2.setInverted(InvertType.FollowMaster); } @Override public void periodic() { // This method will be called once per scheduler run } + public void moveElevator(double speed) { + m_talon1.set(speed); + m_talon2.set(speed); + } }