Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

62 sysid shooter #64

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.IOException;
import java.sql.DriverPropertyInfo;

import org.littletonrobotics.junction.Logger;
import org.littletonrobotics.junction.networktables.LoggedDashboardChooser;

import com.pathplanner.lib.auto.AutoBuilder;
Expand All @@ -20,6 +21,7 @@
import edu.wpi.first.wpilibj2.command.StartEndCommand;
import edu.wpi.first.wpilibj2.command.button.CommandJoystick;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
import frc.robot.Constants.OIConstants;
import frc.robot.subsystems.Arm;
import frc.robot.subsystems.Bass;
Expand Down
23 changes: 13 additions & 10 deletions src/main/java/frc/robot/subsystems/UpBeat.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package frc.robot.subsystems;

import edu.wpi.first.math.controller.SimpleMotorFeedforward;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

Expand All @@ -19,6 +20,7 @@ public class UpBeat extends SubsystemBase {
private SparkPIDController bottomPid;
@AutoLogOutput(key = "upBeat/setPoint")
private double setPoint = 0;
private SimpleMotorFeedforward feedforward = new SimpleMotorFeedforward(0.25001, 0.1326, 0.02354);


public UpBeat() {
Expand All @@ -38,18 +40,18 @@ public UpBeat() {
bottomMotor.setIdleMode(IdleMode.kCoast);
bottomPid = bottomMotor.getPIDController();

topPid.setP(0.0003);
topPid.setI(0.0000001);
topPid.setP(1.2557E-08);
topPid.setI(0.0);
topPid.setD(0.0);
topPid.setFF(0.0001875);
topPid.setFF(0.0);
topPid.setIZone(100);
topPid.setOutputRange(0.0, 1.0);
topMotor.burnFlash();

bottomPid.setP(0.0003);
bottomPid.setI(0.0000001);
bottomPid.setP(1.2557E-08);
bottomPid.setI(0.0);
bottomPid.setD(0.0);
bottomPid.setFF(0.0001875);
bottomPid.setFF(0.0);
bottomPid.setIZone(100);
bottomPid.setOutputRange(0.0, 1.0);
bottomMotor.burnFlash();
Expand Down Expand Up @@ -84,8 +86,7 @@ private Command speedCommand(double speed){
public Command shootNote() {
return startEnd(
() -> setPoint = Constants.shoot,
() -> setPoint = Constants.stop
);
() -> setPoint = Constants.stop);
}

public Command reverseShootNote() {
Expand All @@ -102,9 +103,11 @@ public Command ampSpeed() {

@Override
public void periodic() {
topPid.setReference(setPoint, ControlType.kVelocity);
bottomPid.setReference(setPoint, ControlType.kVelocity);
double feedforwardVolts = feedforward.calculate(setPoint);
topPid.setReference(setPoint, ControlType.kVelocity, 0, feedforwardVolts);
bottomPid.setReference(setPoint, ControlType.kVelocity, 0, feedforwardVolts);

Logger.recordOutput("upBeat/feedForward", feedforwardVolts);
Logger.recordOutput("upBeat/topOutput", topMotor.getAppliedOutput());
Logger.recordOutput("upBeat/bottomOutput", bottomMotor.getAppliedOutput());
Logger.recordOutput("upBeat/topSpeed", topMotor.getEncoder().getVelocity());
Expand Down