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

Auto-Balance Update 0.1 #3

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class SwerveDrive extends SwerveDriveTemplate {
private WSSwerveHelper swerveHelper = new WSSwerveHelper();
private AimHelper limelight;

public enum driveType {TELEOP, AUTO, CROSS, LL};
public enum driveType {TELEOP, AUTO, CROSS, LL, AUTO_BALANCE};
public driveType driveState;

@Override
Expand Down Expand Up @@ -266,6 +266,24 @@ public void update() {
this.swerveSignal = swerveHelper.setDrive(xSpeed, ySpeed, rotSpeed, getGyroAngle());
drive();
}
if (driveState == driveType.AUTO_BALANCE){
if(gyro.getPitch() != 0){
if(Math.abs(gyro.getPitch()) >= 5){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the pitch/roll goes directly from 5 to 0?

Copy link
Contributor Author

@StabStabImAChicken StabStabImAChicken Jan 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the code sits now, the speed would not change. I should fix the != 0 part. Thank you

ySpeed = gyro.getPitch() * 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minimum speed of 10 sure is fast

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't have an accurate reference for how fast the different speeds are, so I just thought 10% of maximum speed would be pretty slow. Stuart suggested a speed of 30 should be our top speed on the ramp, so I assumed it was slow

}else{
ySpeed = 0;
}
}
if(gyro.getRoll() != 0){
if(Math.abs(gyro.getRoll()) >= 5){
xSpeed = gyro.getRoll() * 2;
}else{
xSpeed = 0;
}
}
this.swerveSignal = swerveHelper.setDrive(xSpeed, ySpeed, 0, 0);
drive();
}
SmartDashboard.putNumber("Gyro Reading", getGyroAngle());
SmartDashboard.putNumber("X speed", xSpeed);
SmartDashboard.putNumber("Y speed", ySpeed);
Expand Down