Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

Commit

Permalink
commit 1
Browse files Browse the repository at this point in the history
  • Loading branch information
talhaefeustun committed Feb 11, 2024
1 parent 5f40556 commit 61798a0
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/main/java/frc/robot/commands/PidIntakeCommand.java
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;
}
}
47 changes: 47 additions & 0 deletions src/main/java/frc/robot/commands/ResetIntakeEncoder.java
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;
}
}
58 changes: 58 additions & 0 deletions src/main/java/frc/robot/subsystems/IntakeSubsystem.java
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() {

}
}
74 changes: 74 additions & 0 deletions vendordeps/REVLib.json
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"
]
}
]
}

0 comments on commit 61798a0

Please sign in to comment.