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

Temp lime #4

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public final class CONSTANTS {
*/
public static final double NEUTRAL_DEADBAND = 0.05;
public static final int UNITS_PER_REVOLUTION = 2048; /* this is constant for Talon FX */

// Gains
public static final double GEAR_RATIO = 0.5;

public static final int TALON_PRIMARY_CLOSED_LOOP = 0;

// Turret Constants
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.XboxController;
import frc.robot.commands.ArcadeDrive;
import frc.robot.commands.AutoAim;
import frc.robot.subsystems.DriveTrain;
import frc.robot.commands.ExampleCommand;
import frc.robot.subsystems.ExampleSubsystem;
import frc.robot.subsystems.Limelight;
import frc.robot.subsystems.Shooter;
import frc.robot.subsystems.Turret;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.ScheduleCommand;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import frc.robot.CONSTANTS.*;
Expand Down Expand Up @@ -41,16 +43,18 @@ public class RobotContainer {
private final ArcadeDrive arcadeDrive = new ArcadeDrive(driveTrain, () -> movementJoystick.getY(),
() -> movementJoystick.getX(), () -> movementJoystick.getRawButtonPressed(CONTROLS.JOYSTICK.TRIGGER),
() -> movementJoystick.getRawButtonReleased(CONTROLS.JOYSTICK.TRIGGER));

private final AutoAim autoAim = new AutoAim(turret, limelight);
/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
public RobotContainer() {
// Configure the button bindings

final JoystickButton autoAimButton = new JoystickButton(movementJoystick, CONSTANTS.CONTROLS.JOYSTICK.TRIGGER);
driveTrain.setDefaultCommand(arcadeDrive);

autoAimButton.whenHeld(autoAim);
configureButtonBindings();

}

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

import edu.wpi.first.wpilibj2.command.CommandBase;

import frc.robot.CONSTANTS;
import frc.robot.subsystems.*;

public class AutoAim extends CommandBase {

Turret m_turret;
Limelight m_limelight;

public AutoAim(Turret turret, Limelight limelight){
m_turret = turret;
m_limelight = limelight;
addRequirements(turret);
addRequirements(limelight);
}

@Override
public void execute(){

if(m_limelight.canSeeTarget()){
m_turret.getVel();
}
else if(m_limelight.onTarget()){
m_turret.stop();
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/subsystems/Turret.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Turret extends SubsystemBase {

private WPI_TalonSRX turret = new WPI_TalonSRX(2); // config id later


public Turret() {

turret.configFactoryDefault();
Expand Down Expand Up @@ -42,6 +43,7 @@ public double getVel() {

public void stop() {
turret.stopMotor();

}

@Override
Expand Down