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

merging intake + mode progress #13

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/main/java/frc/robot/commands/arm/ArmMove.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,27 @@
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.arm.ArmSubsystem;
import frc.robot.subsystems.arm.ArmSubsystem.ArmPositions;

public class ArmMove extends CommandBase {

private ArmSubsystem arm;
private double wristGoalRad, shooterPowerGoal;
private boolean intakeMotorStatus;
private ArmPositions armPos;

public ArmMove (ArmSubsystem arm, double wristGoalRad, double shooterPowerGoal, boolean intakeMotorStatus) {
public ArmMove (ArmSubsystem arm, ArmPositions armPos) {
this.arm = arm;
this.wristGoalRad = wristGoalRad;
this.shooterPowerGoal = shooterPowerGoal;
this.intakeMotorStatus = intakeMotorStatus;
this.armPos = armPos;
}

@Override
public void initialize() {
wristGoalRad = SmartDashboard.getNumber("wrist goal rad", wristGoalRad);
shooterPowerGoal = SmartDashboard.getNumber("shooter power goal", shooterPowerGoal);
intakeMotorStatus = SmartDashboard.getBoolean("intake motor activated", intakeMotorStatus);
arm.setWristGoalRads(wristGoalRad); arm.setShooterGoalPower(shooterPowerGoal);
arm.setMode(armPos);
}

@Override
public boolean isFinished() {
// TODO Auto-generated method stub
return super.isFinished();
return arm.getArmPos() == ArmPositions.Idle;
}


Expand Down
37 changes: 31 additions & 6 deletions src/main/java/frc/robot/subsystems/arm/ArmSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ public class ArmSubsystem extends SubsystemBase{
private double intakeGoalPower;


public static enum ArmPositions {

Intake(0,0,0),
ShootHigh(0,0,0),
ShootMid(0,0,0),
ShootLow(0,0,0),
Idle(0,0,0);

public final int wristPos, shooterPower, intakePower;

private ArmPositions(int wristPos, int shooterPower, int intakePower) {
this.wristPos = wristPos;
this.shooterPower = shooterPower;
this.intakePower = intakePower;
}
}

private ArmPositions currentArmPos = ArmPositions.Idle;

public ArmSubsystem() {
wristMotor = new CANSparkMax(Constants.ArmConstants.wristMotorID, MotorType.kBrushless);
intakeMotor = new CANSparkMax(Constants.ArmConstants.intakeMotorID, MotorType.kBrushless);
Expand All @@ -33,6 +52,18 @@ public ArmSubsystem() {

}


public void setMode(ArmPositions armPos) {
currentArmPos = armPos;
wristGoalRad = armPos.wristPos;
shooterGoalPower = armPos.shooterPower;
intakeGoalPower = armPos.intakePower;
}

public ArmPositions getArmPos() {
return currentArmPos;
}

////////////////////////////////////////////////////////////////////////////////////////////////////

public double getWristPositionRad() {
Expand All @@ -56,9 +87,6 @@ private void checkWristAmps() {
}
}

public void setWristGoalRads(double rad) {
wristGoalRad = rad;
}

private void wristControl() {
// add TrapezoidProfile + feedforward later?
Expand Down Expand Up @@ -91,9 +119,6 @@ private void checkShooterAmps() {
}
}

public void setShooterGoalPower(double power) {
shooterGoalPower = power;
}

public void shooterControl() {
setShooterMotorPower(shooterGoalPower);
Expand Down