Skip to content

Commit

Permalink
Merge pull request #17 from 2491-NoMythic/More-Inderxer-Works
Browse files Browse the repository at this point in the history
  • Loading branch information
rflood07 authored Jan 25, 2024
2 parents 9406542 + a5edf8c commit ebe1ca5
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 54 deletions.
Empty file modified gradlew
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void indexInit() {
indexer = new IndexerSubsystem();
}
private void indexCommandInst() {
defaulNoteHandlingCommand = new IndexCommand(indexer, operatorController::getL1Button, shooter, intake);
defaulNoteHandlingCommand = new IndexCommand(indexer, driverController::getR2Button, shooter, intake);
}

private void autoInit() {
Expand Down Expand Up @@ -261,7 +261,7 @@ private void registerNamedCommands() {
NamedCommands.registerCommand("shooterOn", new InstantCommand(()->shooter.shootThing(1), shooter));
NamedCommands.registerCommand("feedShooter", new InstantCommand(()->indexer.feederFeed(0.5), indexer));
NamedCommands.registerCommand("stopFeedingShooter", new InstantCommand(indexer::feederOff, indexer));
NamedCommands.registerCommand("intakeOn", new InstantCommand(intake))
NamedCommands.registerCommand("intakeOn", new InstantCommand(()-> intake.intakeYes(1)));
}

public void teleopPeriodic() {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/frc/robot/commands/IndexCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ public void initialize() {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if (Sensor.noseeing()) {
if (m_Indexer.getInchesFromSensor()>8) {
intake.intakeYes(1);
m_Indexer.holderRetrieve(0.5);
shooter.turnOff();
} else {
intake.intakeOff();
m_Indexer.holderOff();
shooter.shootThing(1);
}
if (shootButtonSupplier.getAsBoolean()) {
shooter.shootThing(1);
m_Indexer.feederFeed(0.5);
}
}
Expand Down
32 changes: 0 additions & 32 deletions src/main/java/frc/robot/commands/IndexerCommand.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/frc/robot/settings/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.ctre.phoenix6.signals.InvertedValue;
import com.ctre.phoenix6.signals.NeutralModeValue;
import com.pathplanner.lib.path.PathConstraints;
import com.revrobotics.Rev2mDistanceSensor.Port;

import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.geometry.Pose2d;
Expand Down Expand Up @@ -312,6 +313,7 @@ public static final class IndexerConstants{
public static final int HOLDER_1_MOTOR = 2491;
public static final int HOLDER_2_MOTOR = 2491;
public static final double INDEXER_SPEED = 0.75;
public static final Port DIST_SENSOR_PORT = Port.kOnboard;
}
public static final class IntakeConstants{
public static final int INTAKE_1_MOTOR = 2491;
Expand Down
47 changes: 30 additions & 17 deletions src/main/java/frc/robot/subsystems/IndexerSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,49 @@

import com.revrobotics.CANSparkMax;
import com.revrobotics.RelativeEncoder;
import com.revrobotics.SparkPIDController;
import com.revrobotics.Rev2mDistanceSensor;
import com.revrobotics.SparkPIDController;
import com.revrobotics.SparkRelativeEncoder;
import com.revrobotics.CANSparkBase.ControlType;
import com.revrobotics.CANSparkBase.IdleMode;
import com.revrobotics.CANSparkLowLevel.MotorType;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.settings.Constants.IndexerConstants;
import frc.robot.settings.Constants;
import frc.robot.settings.Constants.IndexerConstants;
import com.revrobotics.Rev2mDistanceSensor.*;

public class IndexerSubsystem extends SubsystemBase{
CANSparkMax holder1;
CANSparkMax holder2;
CANSparkMax feeder1;
CANSparkMax feeder2;
//sensor Sensorthingy;
Rev2mDistanceSensor distanceSensor; //sensor Sensorthingy;
boolean isHolding;
public IndexerSubsystem(){
CANSparkMax holder1 = new CANSparkMax(IndexerConstants.HOLDER_1_MOTOR, MotorType.kBrushless);
CANSparkMax holder2 = new CANSparkMax(IndexerConstants.HOLDER_2_MOTOR, MotorType.kBrushless);
CANSparkMax feeder1 = new CANSparkMax(IndexerConstants.FEEDER_1_MOTOR, MotorType.kBrushless);
CANSparkMax feeder2 = new CANSparkMax(IndexerConstants.FEEDER_2_MOTOR, MotorType.kBrushless);
//sensor sensorThingy = new ???;
boolean isHolding = false;
feeder2.follow(feeder1);
feeder2.setInverted(true);
holder2.follow(holder1);
holder2.setInverted(true);
holder1.setIdleMode(IdleMode.kBrake);
holder2.setIdleMode(IdleMode.kBrake);
feeder1.setIdleMode(IdleMode.kBrake);
feeder2.setIdleMode(IdleMode.kBrake);
CANSparkMax holder1 = new CANSparkMax(IndexerConstants.HOLDER_1_MOTOR, MotorType.kBrushless);
CANSparkMax holder2 = new CANSparkMax(IndexerConstants.HOLDER_2_MOTOR, MotorType.kBrushless);
CANSparkMax feeder1 = new CANSparkMax(IndexerConstants.FEEDER_1_MOTOR, MotorType.kBrushless);
CANSparkMax feeder2 = new CANSparkMax(IndexerConstants.FEEDER_2_MOTOR, MotorType.kBrushless);
//sensor sensorThingy = new ???;
boolean isHolding = false;
feeder2.follow(feeder1);
feeder2.setInverted(true);
holder2.follow(holder1);
holder2.setInverted(true);
holder1.setIdleMode(IdleMode.kBrake);
holder2.setIdleMode(IdleMode.kBrake);
feeder1.setIdleMode(IdleMode.kBrake);
feeder2.setIdleMode(IdleMode.kBrake);

distanceSensor = new Rev2mDistanceSensor(
Constants.IndexerConstants.DIST_SENSOR_PORT,
Unit.kInches,
RangeProfile.kHighAccuracy);
distanceSensor.setAutomaticMode(true);
}

public double getInchesFromSensor() {
return distanceSensor.getRange();
}
public void feederFeed(double generalSpeed){
feeder1.set(generalSpeed);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/frc/robot/subsystems/ShooterSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import com.revrobotics.SparkPIDController;
import com.revrobotics.SparkRelativeEncoder;
import com.revrobotics.CANSparkBase.ControlType;
import com.revrobotics.CANSparkLowLevel.MotorType;
import com.revrobotics.CANSparkBase.IdleMode;
import com.revrobotics.CANSparkLowLevel.MotorType;

import frc.robot.commands.AngleShooter;
import frc.robot.commands.RotateRobot;
Expand Down Expand Up @@ -86,6 +87,8 @@ public ShooterSubsystem(double runSpeed, BooleanSupplier aimAtAmp) {
shooter1.restoreFactoryDefaults();
shooter2.follow(shooter1);
shooter2.setInverted(true);
shooter1.setIdleMode(IdleMode.kCoast);
shooter2.setIdleMode(IdleMode.kCoast);


encoder1 = shooter1.getEncoder(SparkRelativeEncoder.Type.kQuadrature, 4096);
Expand Down
56 changes: 56 additions & 0 deletions vendordeps/REV2mDistanceSensor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"fileName": "REV2mDistanceSensor.json",
"name": "REV2mDistanceSensor",
"version": "0.4.0",
"frcYear": "2024",
"uuid": "9e352acd-4eec-40f7-8490-3357b5ed65ae",
"mavenUrls": [
"https://www.revrobotics.com/content/sw/max/sdk/maven/"
],
"jsonUrl": "https://www.revrobotics.com/content/sw/max/sdk/Rev2mDistanceSensor.json",
"javaDependencies": [
{
"groupId": "com.revrobotics.frc",
"artifactId": "DistanceSensor-java",
"version": "0.4.0"
}
],
"jniDependencies": [
{
"groupId": "com.revrobotics.frc",
"artifactId": "DistanceSensor-driver",
"version": "0.4.0",
"skipInvalidPlatforms": true,
"isJar": false,
"validPlatforms": [
"linuxathena"
]
}
],
"cppDependencies": [
{
"groupId": "com.revrobotics.frc",
"artifactId": "DistanceSensor-cpp",
"version": "0.4.0",
"libName": "libDistanceSensor",
"headerClassifier": "headers",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"linuxathena"
]
},
{
"groupId": "com.revrobotics.frc",
"artifactId": "DistanceSensor-driver",
"version": "0.4.0",
"libName": "libDistanceSensorDriver",
"headerClassifier": "headers",
"sharedLibrary": false,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"linuxathena"
]
}
]
}

0 comments on commit ebe1ca5

Please sign in to comment.