Skip to content

Commit

Permalink
Edit Constants
Browse files Browse the repository at this point in the history
(this will finish adding all changes currently on origin for all subsystem branches
  • Loading branch information
Jacob1010-h committed Jan 22, 2024
1 parent da30c84 commit 3dfb911
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 125 deletions.
29 changes: 0 additions & 29 deletions src/main/java/frc/robot/subsystems/Shooter/Pivot.java

This file was deleted.

62 changes: 0 additions & 62 deletions src/main/java/frc/robot/subsystems/Shooter/Shooter.java

This file was deleted.

43 changes: 16 additions & 27 deletions src/main/java/frc/robot/subsystems/shooter/Pivot.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,29 @@
package frc.robot.subsystems.shooter;
package frc.robot.subsystems.Shooter;

import com.revrobotics.CANSparkLowLevel.PeriodicFrame;
public class Pivot {
pivot = new Neo(ShooterConstants.SHOOTER_PIVOT_CAN_ID);
configMotor();
}

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.util.Neo;
import frc.robot.util.Constants.ShooterConstants;

public class Pivot extends SubsystemBase {
private Neo pivot;

public Pivot() {
this.pivot = new Neo(ShooterConstants.SHOOTER_PIVOT_CAN_ID);

configMotor();
}


public void configMotor() {
pivot.setSmartCurrentLimit(ShooterConstants.PIVOT_CURRENT_LIMIT);
public void configMotor() {
pivot.setSmartCurrentLimit(PivotConstants.PIVOT_CURRENT_LIMIT);
// See https://docs.revrobotics.com/sparkmax/operating-modes/control-interfaces
pivot.setPeriodicFramePeriod(PeriodicFrame.kStatus3, 65535);
pivot.setPeriodicFramePeriod(PeriodicFrame.kStatus5, 65535);
pivot.setInverted(false);

pivot.setPID(
ShooterConstants.PIVOT_P,
ShooterConstants.PIVOT_I,
ShooterConstants.PIVOT_D,
ShooterConstants.PIVOT_MIN_OUTPUT,
ShooterConstants.PIVOT_MAX_OUTPUT);
Pivot.setPID(
ShooterConstants.SHOOTER_P,
ShooterConstants.SHOOTER_I,
ShooterConstants.SHOOTER_D,
ShooterConstants.SHOOTER_MIN_OUTPUT,
ShooterConstants.SHOOTER_MAX_OUTPUT);


//sets brake mode
pivot.setBrakeMode();
}

public void setAngle(double angle) {
pivot.setTargetPosition(angle);
}
public void setAngle(double angle) {
pivot.setTargetPosition(angle);
}
26 changes: 19 additions & 7 deletions src/main/java/frc/robot/subsystems/shooter/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,37 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.subsystems.shooter;
package frc.robot.subsystems;

import java.util.Optional;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.util.Neo;
import frc.robot.util.SpeedAnglePair;
import frc.robot.util.Constants.FieldConstants;
import frc.robot.util.Constants.ShooterConstants;

public class Shooter extends SubsystemBase {
/** Creates a new shooter. */
private final Neo motorLeft;
private final Neo motorRight;
private final Neo pivotMotor;

public Shooter() {

motorLeft = new Neo(ShooterConstants.LEFT_SHOOTER_CAN_ID);
motorRight = new Neo(ShooterConstants.RIGHT_SHOOTER_CAN_ID);

pivotMotor = new Neo(ShooterConstants.SHOOTER_PIVOT_CAN_ID);

configMotors();

}

public void configMotors() {
motorLeft.setSmartCurrentLimit(ShooterConstants.SHOOTER_CURRENT_LIMIT);
motorRight.setSmartCurrentLimit(ShooterConstants.SHOOTER_CURRENT_LIMIT);
motorLeft.setPID(
ShooterConstants.SHOOTER_P,
ShooterConstants.SHOOTER_I,
Expand All @@ -33,18 +41,22 @@ public void configMotors() {
ShooterConstants.SHOOTER_MAX_OUTPUT);

motorLeft.addFollower(motorRight, true);
// Current limit
// Velocity conversion factor (make gear ratio in constants)

}

@Override
public void periodic() {
// This method will be called once per scheduler run
}

public void setSpeed(double calc) {
motorLeft.setTargetVelocity(calc);
public void setTargetVelocity(double calc) {
motorLeft.getPIDController().setTargetVelocity(calc);
}

public void stop() {
motorLeft.setTargetVelocity(0);
public void setTargetVelocity() {
motorLeft.getPIDController().setTargetVelocity(0);
}
}

0 comments on commit 3dfb911

Please sign in to comment.