Skip to content

Commit

Permalink
changed motor type for the Indexer. added distance sensor back to ind…
Browse files Browse the repository at this point in the history
…exer
  • Loading branch information
XiaoHan2491 committed Feb 13, 2024
1 parent 4cd27a3 commit cbd8bb7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/commands/IndexCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void execute() {
} else {
auto = false;
}
if (!intake.isNoteIn()) {
if (!m_Indexer.isNoteIn()) {
intake.intakeYes(1);
m_Indexer.on();
if(!auto) {
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/frc/robot/subsystems/IndexerSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import frc.robot.settings.Constants.IndexerConstants;

public class IndexerSubsystem extends SubsystemBase {
TalonFX m_IndexerMotor;
CANSparkMax m_IndexerMotor;
SparkAnalogSensor m_DistanceSensor;

public IndexerSubsystem() {
m_IndexerMotor = new TalonFX(IndexerConstants.INDEXER_MOTOR);
m_IndexerMotor = new CANSparkMax(IndexerConstants.INDEXER_MOTOR, MotorType.kBrushless);
m_DistanceSensor = m_IndexerMotor.getAnalog(Mode.kAbsolute);
}

public void on() {
Expand All @@ -28,4 +30,12 @@ public void off() {
public void reverse() {
m_IndexerMotor.set(-IndexerConstants.INDEXER_SPEED);
}
public boolean isNoteIn() {
return m_DistanceSensor.getVoltage()>2;
}

@Override
public void periodic() {
SmartDashboard.putNumber("voltage sensor output", m_DistanceSensor.getVoltage());
}
}
12 changes: 0 additions & 12 deletions src/main/java/frc/robot/subsystems/IntakeSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@

import com.revrobotics.CANSparkMax;
import com.revrobotics.RelativeEncoder;
import com.revrobotics.SparkAnalogSensor;
import com.revrobotics.SparkPIDController;
import com.revrobotics.SparkRelativeEncoder;
import com.revrobotics.CANSparkBase.ControlType;
import com.revrobotics.CANSparkBase.IdleMode;
import com.revrobotics.CANSparkLowLevel.MotorType;
import com.revrobotics.SparkAnalogSensor.Mode;

import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
Expand All @@ -24,13 +22,11 @@ public class IntakeSubsystem extends SubsystemBase {
CANSparkMax brush1;
CANSparkMax brush2;
CANSparkMax brush3;
SparkAnalogSensor distanceSensor;

double intakeRunSpeed;
public IntakeSubsystem() {
intake1 = new CANSparkMax(IntakeConstants.INTAKE_1_MOTOR, MotorType.kBrushless);
intake2 = new CANSparkMax(IntakeConstants.INTAKE_1_MOTOR, MotorType.kBrushless);
distanceSensor = intake1.getAnalog(Mode.kAbsolute);
brush1 = new CANSparkMax(IntakeConstants.BRUSH_1_MOTOR, MotorType.kBrushless);
brush2 = new CANSparkMax(IntakeConstants.BRUSH_2_MOTOR, MotorType.kBrushless);
brush3 = new CANSparkMax(IntakeConstants.BRUSH_3_MOTOR, MotorType.kBrushless);
Expand Down Expand Up @@ -63,12 +59,4 @@ public void intakeOff() {
brush1.set(0);
brush3.set(0);
}
public boolean isNoteIn() {
return distanceSensor.getVoltage()>2;
}

@Override
public void periodic() {
SmartDashboard.putNumber("voltage sensor output", distanceSensor.getVoltage());
}
}

0 comments on commit cbd8bb7

Please sign in to comment.