-
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
Coast Mode Elevator Zeroing (╬ಠ益ಠ) #245
base: main
Are you sure you want to change the base?
Changes from all commits
eea5600
c3ba10f
06a7dc2
ff622f0
63ee578
6165c72
18edcdc
7bfa45e
bfdcb61
c754794
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 |
---|---|---|
|
@@ -4,8 +4,11 @@ | |
|
||
package frc.robot.commands.Zeroing; | ||
|
||
import edu.wpi.first.units.DistanceUnit; | ||
import edu.wpi.first.units.Measure; | ||
import edu.wpi.first.units.Units; | ||
import edu.wpi.first.units.measure.AngularVelocity; | ||
import edu.wpi.first.units.measure.Distance; | ||
import edu.wpi.first.units.measure.Time; | ||
import edu.wpi.first.wpilibj.Timer; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
@@ -18,6 +21,8 @@ public class ManualZeroElevator extends Command { | |
boolean zeroingSuccess = false; | ||
Time zeroingTimestamp = Units.Seconds.of(0); | ||
|
||
public static boolean hasSetCoastMode = false; | ||
|
||
AngularVelocity lastRotorVelocity = Units.RotationsPerSecond.of(0); | ||
|
||
public ManualZeroElevator(Elevator subElevator) { | ||
|
@@ -33,6 +38,12 @@ public void initialize() { | |
|
||
@Override | ||
public void execute() { | ||
|
||
if (globalElevator.getElevatorPosition().lte(constElevator.ZEROED_ZONE) && !hasSetCoastMode) { | ||
globalElevator.setCoastMode(true); | ||
hasSetCoastMode = true; | ||
} | ||
|
||
// Check if we have raised the elevator above a certain speed | ||
if (globalElevator.getRotorVelocity().gte(constElevator.MANUAL_ZEROING_START_VELOCITY) | ||
|| globalElevator.attemptingZeroing) { | ||
|
@@ -67,6 +78,7 @@ public void end(boolean interrupted) { | |
if (!interrupted) { | ||
globalElevator.hasZeroed = true; | ||
globalElevator.resetSensorPosition(constElevator.ZEROED_POS); | ||
globalElevator.setCoastMode(false); | ||
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. Is this the best spot for this? Should we always do this in end or just when its not interrupted? how does it get set back if it doesnt finish? also what happens if the robot is mid elevation and goes into disable? |
||
System.out.println("Elevator Zeroing Successful!!!! Yippee and hooray!!! :3"); | ||
} else { | ||
System.out.println("Elevator was never zeroed :((( blame eli"); | ||
|
S0L0GUY marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,12 +6,14 @@ | |||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
import static edu.wpi.first.units.Units.Inches; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
import com.ctre.phoenix.motorcontrol.NeutralMode; | ||||||||||||||||||||||||||||||||
import com.ctre.phoenix6.controls.Follower; | ||||||||||||||||||||||||||||||||
import com.ctre.phoenix6.controls.MotionMagicVoltage; | ||||||||||||||||||||||||||||||||
import com.ctre.phoenix6.controls.NeutralOut; | ||||||||||||||||||||||||||||||||
import com.ctre.phoenix6.controls.PositionVoltage; | ||||||||||||||||||||||||||||||||
import com.ctre.phoenix6.controls.VoltageOut; | ||||||||||||||||||||||||||||||||
import com.ctre.phoenix6.hardware.TalonFX; | ||||||||||||||||||||||||||||||||
import com.ctre.phoenix6.signals.NeutralModeValue; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Comment on lines
+9
to
17
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. unused imports
Suggested change
|
||||||||||||||||||||||||||||||||
import edu.wpi.first.epilogue.Logged; | ||||||||||||||||||||||||||||||||
import edu.wpi.first.units.Units; | ||||||||||||||||||||||||||||||||
|
@@ -73,6 +75,16 @@ public Distance getLastDesiredPosition() { | |||||||||||||||||||||||||||||||
return lastDesiredPosition; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
public void setCoastMode(Boolean coastMode) { | ||||||||||||||||||||||||||||||||
if (coastMode) { | ||||||||||||||||||||||||||||||||
rightMotorLeader.getConfigurator().apply(constElevator.COAST_MODE_CONFIGURATION); | ||||||||||||||||||||||||||||||||
leftMotorFollower.getConfigurator().apply(constElevator.COAST_MODE_CONFIGURATION); | ||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||
rightMotorLeader.getConfigurator().apply(constElevator.ELEVATOR_CONFIG); | ||||||||||||||||||||||||||||||||
leftMotorFollower.getConfigurator().apply(constElevator.ELEVATOR_CONFIG); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
public boolean isRotorVelocityZero() { | ||||||||||||||||||||||||||||||||
return getRotorVelocity().isNear(Units.RotationsPerSecond.zero(), 0.01); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
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.
this is unused and can be removed