-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
5e4932f
47d1c6a
3c65b7f
541be26
ca3390a
825ee4e
c629fbc
248ae18
27b120f
59bbb64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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){ | ||
ySpeed = gyro.getPitch() * 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A minimum speed of 10 sure is fast There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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