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

add check if stalling to prep for hardstop in physical turret #4

Open
wants to merge 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.stuypulse.stuylib.math.Angle;
import com.stuypulse.stuylib.streams.angles.filters.ARateLimit;

import com.stuypulse.robot.Robot;
import com.stuypulse.robot.constants.Motors;
import com.stuypulse.robot.constants.Settings.Swerve;
import com.stuypulse.robot.constants.Settings.Swerve.Drive;
Expand Down Expand Up @@ -91,7 +90,7 @@ public SL_SwerveModule(String id, Translation2d location, int turnCANId, Rotatio
Motors.disableStatusFrames(driveMotor, 3, 4, 5, 6);

driveController = new PIDController(Drive.kP, Drive.kI, Drive.kD)
.setOutputFilter(x -> true ? 0 : x)
.setOutputFilter(x -> true ? 0 : x) //XXX: This doesnt work
.add(new MotorFeedforward(Drive.kS, Drive.kV, Drive.kA).velocity());

targetState = new SwerveModuleState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public SimModule(String id, Translation2d location) {
driveSim = new LinearSystemSim<>(identifyVelocityPositionSystem(Drive.kV, Drive.kA));

driveController = new PIDController(Drive.kP, Drive.kI, Drive.kD)
.setOutputFilter(x -> true ? 0 : x)
.setOutputFilter(x -> true ? 0 : x) //Same issue as SL_SwerveModule
.add(new MotorFeedforward(Drive.kS, Drive.kV, Drive.kA).velocity());

targetState = new SwerveModuleState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class TurretImpl extends Turret {
public TurretImpl(int port) {
motor = new CANSparkMax(port, MotorType.kBrushless);
encoder = motor.getAbsoluteEncoder(Type.kDutyCycle);
encoder.setPositionConversionFactor(-1); //TODO: figure out the conversion factor
}

@Override
Expand All @@ -25,9 +26,12 @@ public void setTurretVoltage(double voltage) {
motor.setVoltage(voltage);
}

public boolean isStalling() {
return motor.getOutputCurrent() > 40;
}

@Override
public void periodic2() {

}
}

Loading