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 deadband to alignment command rotation #88

Merged
merged 3 commits into from
Mar 25, 2024
Merged
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 @@ -145,10 +145,14 @@ public void execute() {

SmartDashboard.putNumber("Alignment/Translation Target Speed", speed.distance());

if (Math.abs(rotation) < Swerve.ALIGN_OMEGA_DEADBAND.get())
rotation = 0;

ChassisSpeeds clamped = new ChassisSpeeds(
speed.x, speed.y, rotation);

swerve.setChassisSpeeds(clamped);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.stuypulse.robot.Robot;
import com.stuypulse.robot.constants.Field;
import com.stuypulse.robot.constants.Settings.Alignment;
import com.stuypulse.robot.constants.Settings.Swerve;
import com.stuypulse.robot.constants.Settings.Alignment.Shoot;
import com.stuypulse.robot.subsystems.odometry.Odometry;
import com.stuypulse.robot.subsystems.swerve.SwerveDrive;
Expand Down Expand Up @@ -121,6 +122,9 @@ public void execute() {
speed,
toSpeaker.getAngle());

if (Math.abs(rotation) < Swerve.ALIGN_OMEGA_DEADBAND.get())
rotation = 0;

swerve.setFieldRelativeSpeeds(
new ChassisSpeeds(
speeds.getX(),
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/stuypulse/robot/constants/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ public interface Swerve {

double MODULE_VELOCITY_DEADBAND = 0.05;

SmartNumber ALIGN_OMEGA_DEADBAND = new SmartNumber("Swerve/Align Omega Deadband", 0.05); // TODO: make 0.25 and test

public interface Assist {
SmartNumber ALIGN_MIN_SPEAKER_DIST = new SmartNumber("SwerveAssist/Minimum Distance to Speaker", 4); //change

double BUZZ_INTENSITY = 1;

SmartNumber kP = new SmartNumber("SwerveAssist/kP", 2.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public Rotation2d getGyroRoll() {
public double getForwardAccelerationGs() {
return gyro.getWorldLinearAccelY();
}

@Override
public void periodic() {
Odometry odometry = Odometry.getInstance();
Expand Down
Loading