This repository has been archived by the owner on Nov 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f40556
commit 61798a0
Showing
4 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package frc.robot.commands; | ||
|
||
import java.util.function.DoubleSupplier; | ||
import edu.wpi.first.math.controller.PIDController; | ||
import edu.wpi.first.wpilibj.Encoder; | ||
import edu.wpi.first.wpilibj2.command.PIDCommand; | ||
import frc.robot.subsystems.IntakeSubsystem; | ||
|
||
|
||
public class PidIntakeCommand extends PIDCommand { | ||
|
||
public PidIntakeCommand(IntakeSubsystem m_intake, double position) { | ||
super( | ||
|
||
new PIDController(1, 0, 0), | ||
|
||
() -> m_intake.getEncoderOutput(), | ||
|
||
() -> position, | ||
|
||
output -> { | ||
if (position > m_intake.getEncoderOutput()) { | ||
m_intake.intakeMotorOutput(-output);; | ||
} else if (position < m_intake.getEncoderOutput()) { | ||
m_intake.intakeMotorOutput(output);; | ||
} | ||
|
||
}); | ||
|
||
} | ||
|
||
|
||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
|
||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.IntakeSubsystem; | ||
|
||
public class ResetIntakeEncoder extends Command { | ||
|
||
IntakeSubsystem m_intake; | ||
|
||
public ResetIntakeEncoder(IntakeSubsystem m_intake){ | ||
this.m_intake = m_intake; | ||
|
||
} | ||
|
||
|
||
|
||
|
||
@Override | ||
public void initialize() {} | ||
|
||
|
||
|
||
|
||
@Override | ||
|
||
|
||
|
||
public void execute() { | ||
m_intake.reset(); | ||
} | ||
|
||
|
||
|
||
|
||
@Override | ||
public void end(boolean interrupted) {} | ||
|
||
|
||
|
||
|
||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
|
||
package frc.robot.subsystems; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.RelativeEncoder; | ||
import com.revrobotics.CANSparkBase.IdleMode; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
|
||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class IntakeSubsystem extends SubsystemBase { | ||
|
||
// intake nota motorları | ||
public static CANSparkMax intakeMotor1 = new CANSparkMax(0,MotorType.kBrushless); | ||
public static CANSparkMax intakeMotor2 = new CANSparkMax(0,MotorType.kBrushless); | ||
|
||
//intake main motor | ||
public static CANSparkMax intakeMotor = new CANSparkMax(0,MotorType.kBrushless); | ||
|
||
|
||
public RelativeEncoder IntakeEncoder; | ||
|
||
|
||
public IntakeSubsystem() { | ||
intakeMotor.setIdleMode(IdleMode.kBrake); | ||
IntakeEncoder = intakeMotor.getEncoder(); | ||
intakeMotor.setOpenLoopRampRate(1); | ||
} | ||
|
||
public void brakemode(){ | ||
intakeMotor.setIdleMode(IdleMode.kBrake); | ||
|
||
} | ||
public void coastmode(){ | ||
intakeMotor.setIdleMode(IdleMode.kCoast); | ||
} | ||
|
||
public double getRawEncoderOutput(){ | ||
return IntakeEncoder.getPosition(); | ||
} | ||
public double getEncoderOutput(){ | ||
return IntakeEncoder.getPosition() * -10; | ||
} | ||
public void reset() { | ||
IntakeEncoder.setPosition(0); | ||
} | ||
|
||
public void intakeMotorOutput(double value){ | ||
intakeMotor.set(value); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"fileName": "REVLib.json", | ||
"name": "REVLib", | ||
"version": "2024.2.1", | ||
"frcYear": "2024", | ||
"uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", | ||
"mavenUrls": [ | ||
"https://maven.revrobotics.com/" | ||
], | ||
"jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2024.json", | ||
"javaDependencies": [ | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-java", | ||
"version": "2024.2.1" | ||
} | ||
], | ||
"jniDependencies": [ | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-driver", | ||
"version": "2024.2.1", | ||
"skipInvalidPlatforms": true, | ||
"isJar": false, | ||
"validPlatforms": [ | ||
"windowsx86-64", | ||
"windowsx86", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"linuxathena", | ||
"linuxarm32", | ||
"osxuniversal" | ||
] | ||
} | ||
], | ||
"cppDependencies": [ | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-cpp", | ||
"version": "2024.2.1", | ||
"libName": "REVLib", | ||
"headerClassifier": "headers", | ||
"sharedLibrary": false, | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"windowsx86", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"linuxathena", | ||
"linuxarm32", | ||
"osxuniversal" | ||
] | ||
}, | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-driver", | ||
"version": "2024.2.1", | ||
"libName": "REVLibDriver", | ||
"headerClassifier": "headers", | ||
"sharedLibrary": false, | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"windowsx86", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"linuxathena", | ||
"linuxarm32", | ||
"osxuniversal" | ||
] | ||
} | ||
] | ||
} |