From 8c58b2f78a096cd6b0cbb2de200ce79eb0e939f8 Mon Sep 17 00:00:00 2001 From: NirNadiv Date: Thu, 18 Jan 2024 19:10:26 +0200 Subject: [PATCH 1/5] Started feeder Subsystem kaki baki --- .../frc/robot/subsystems/FeederSubsystem.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/frc/robot/subsystems/FeederSubsystem.java diff --git a/src/main/java/frc/robot/subsystems/FeederSubsystem.java b/src/main/java/frc/robot/subsystems/FeederSubsystem.java new file mode 100644 index 0000000..516db82 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/FeederSubsystem.java @@ -0,0 +1,17 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.subsystems; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class FeederSubsystem extends SubsystemBase { + /** Creates a new FeederSubsystem. */ + public FeederSubsystem() {} + + @Override + public void periodic() { + // This method will be called once per scheduler run + } +} From 382d30aa81ce2e233ebb531f2df0e9250e7e19b1 Mon Sep 17 00:00:00 2001 From: NirNadiv Date: Thu, 18 Jan 2024 22:27:35 +0200 Subject: [PATCH 2/5] finished feeder subsystem i added a set speed function, and two constants one for a motor id and another form speed. --- src/main/java/frc/robot/Constants.java | 7 +++++ .../frc/robot/subsystems/FeederSubsystem.java | 27 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 7432df0..a426e14 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -197,4 +197,11 @@ public static class Vision { public static final Pose2d target = new Pose2d(1, 1, new Rotation2d(Units.degreesToRadians(0))); } + + public static class FeederConstants{ + + public static final int FeederMotorId = 3; + public static final double FeederMotorSpeed = 0.8; + + } } diff --git a/src/main/java/frc/robot/subsystems/FeederSubsystem.java b/src/main/java/frc/robot/subsystems/FeederSubsystem.java index 516db82..f18a60b 100644 --- a/src/main/java/frc/robot/subsystems/FeederSubsystem.java +++ b/src/main/java/frc/robot/subsystems/FeederSubsystem.java @@ -4,11 +4,36 @@ package frc.robot.subsystems; +import com.ctre.phoenix.motorcontrol.ControlMode; +import com.ctre.phoenix.motorcontrol.DemandType; +import com.ctre.phoenix.motorcontrol.can.TalonSRX; + import edu.wpi.first.wpilibj2.command.SubsystemBase; +import static frc.robot.Constants.FeederConstants.*; + public class FeederSubsystem extends SubsystemBase { /** Creates a new FeederSubsystem. */ - public FeederSubsystem() {} + + //the feeder's motor + TalonSRX m_Feeder = new TalonSRX(FeederMotorId); + + // singelton + public static FeederSubsystem instance; + + public static FeederSubsystem getInstance() { + if (instance == null) { + instance = new FeederSubsystem(); + } + return instance; + } + + // set speed function + public void setSpeed(double MotorSpeed){ + + MotorSpeed = FeederMotorSpeed; + m_Feeder.set(ControlMode.PercentOutput, MotorSpeed, DemandType.Neutral, 0); + } @Override public void periodic() { From 08bac0d3507a9a4dc1eb34bc6af26df2d3ce581f Mon Sep 17 00:00:00 2001 From: NirNadiv Date: Fri, 19 Jan 2024 13:47:05 +0200 Subject: [PATCH 3/5] fixed feeder subsystem? --- .../frc/robot/subsystems/FeederSubsystem.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/FeederSubsystem.java b/src/main/java/frc/robot/subsystems/FeederSubsystem.java index f18a60b..a4e793d 100644 --- a/src/main/java/frc/robot/subsystems/FeederSubsystem.java +++ b/src/main/java/frc/robot/subsystems/FeederSubsystem.java @@ -7,6 +7,7 @@ import com.ctre.phoenix.motorcontrol.ControlMode; import com.ctre.phoenix.motorcontrol.DemandType; import com.ctre.phoenix.motorcontrol.can.TalonSRX; +import com.fasterxml.jackson.annotation.JsonCreator.Mode; import edu.wpi.first.wpilibj2.command.SubsystemBase; @@ -16,23 +17,26 @@ public class FeederSubsystem extends SubsystemBase { /** Creates a new FeederSubsystem. */ //the feeder's motor - TalonSRX m_Feeder = new TalonSRX(FeederMotorId); + TalonSRX m_Feeder; + + //constructor + private FeederSubsystem(){ + m_Feeder = new TalonSRX(FeederMotorId); + } // singelton - public static FeederSubsystem instance; + private static FeederSubsystem instance; public static FeederSubsystem getInstance() { if (instance == null) { - instance = new FeederSubsystem(); + instance = new FeederSubsystem(); } return instance; } // set speed function - public void setSpeed(double MotorSpeed){ - - MotorSpeed = FeederMotorSpeed; - m_Feeder.set(ControlMode.PercentOutput, MotorSpeed, DemandType.Neutral, 0); + public void setSpeed(){ + m_Feeder.set(ControlMode.PercentOutput, FeederMotorSpeed); } @Override From dc664cb513066c23e0867835ff6af17f54887a69 Mon Sep 17 00:00:00 2001 From: NirNadiv Date: Fri, 19 Jan 2024 13:58:50 +0200 Subject: [PATCH 4/5] finished subsystem --- src/main/java/frc/robot/subsystems/FeederSubsystem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/FeederSubsystem.java b/src/main/java/frc/robot/subsystems/FeederSubsystem.java index a4e793d..af6fae3 100644 --- a/src/main/java/frc/robot/subsystems/FeederSubsystem.java +++ b/src/main/java/frc/robot/subsystems/FeederSubsystem.java @@ -35,8 +35,8 @@ public static FeederSubsystem getInstance() { } // set speed function - public void setSpeed(){ - m_Feeder.set(ControlMode.PercentOutput, FeederMotorSpeed); + public void setSpeed(double motorSpeed){ + m_Feeder.set(ControlMode.PercentOutput, motorSpeed); } @Override From e993de16340fa73f6060f70fba384d4b6b956c88 Mon Sep 17 00:00:00 2001 From: NirNadiv Date: Sat, 20 Jan 2024 11:14:45 +0200 Subject: [PATCH 5/5] Finished my commands --- .../java/frc/robot/commands/FeedShooter.java | 34 +++++++++++++++++++ .../frc/robot/commands/FeederSetSpeed.java | 33 ++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/main/java/frc/robot/commands/FeedShooter.java create mode 100644 src/main/java/frc/robot/commands/FeederSetSpeed.java diff --git a/src/main/java/frc/robot/commands/FeedShooter.java b/src/main/java/frc/robot/commands/FeedShooter.java new file mode 100644 index 0000000..88a4b1a --- /dev/null +++ b/src/main/java/frc/robot/commands/FeedShooter.java @@ -0,0 +1,34 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.InstantCommand; + +import frc.robot.subsystems.FeederSubsystem; + +import frc.robot.Constants.FeederConstants;; + +// NOTE: Consider using this command inline, rather than writing a subclass. For more +// information, see: +// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html +public class FeedShooter extends InstantCommand { + + // feeder subsystem + private FeederSubsystem feeder; + + // constructor + public FeedShooter(FeederSubsystem feeder) { + addRequirements(feeder); + this.feeder = feeder; + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + // set speed to motor + feeder.setSpeed(FeederConstants.FeederMotorSpeed); + + } +} diff --git a/src/main/java/frc/robot/commands/FeederSetSpeed.java b/src/main/java/frc/robot/commands/FeederSetSpeed.java new file mode 100644 index 0000000..8702df6 --- /dev/null +++ b/src/main/java/frc/robot/commands/FeederSetSpeed.java @@ -0,0 +1,33 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands; + +import com.ctre.phoenix.motorcontrol.TalonSRXSimCollection; + +import edu.wpi.first.wpilibj2.command.InstantCommand; +import frc.robot.subsystems.FeederSubsystem; + +// NOTE: Consider using this command inline, rather than writing a subclass. For more +// information, see: +// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html +public class FeederSetSpeed extends InstantCommand { + // variables + private FeederSubsystem feeder;// feeder subsystem + double speed; + + // constructor + public FeederSetSpeed(FeederSubsystem feeder, double speed) { + addRequirements(feeder); + this.feeder = feeder; + this.speed = speed; + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + // set speed to motor + feeder.setSpeed(speed); + } +}