Skip to content

Commit

Permalink
add more comments to the MechanismStateManager
Browse files Browse the repository at this point in the history
  • Loading branch information
varun7654 committed Apr 27, 2023
1 parent 52b4d28 commit faf747c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/frc/subsytem/MechanismStateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@ public MechanismStateAdjustment(double xMetersChange, double yMetersChange, doub
public static final MechanismStateAdjustment CONE_DUNK_MIDDLE_ADJUSTMENT
= new MechanismStateAdjustment(Units.inchesToMeters(4), -Units.inchesToMeters(6), 0);

private static final double CONE_HIGH_DUNK_ANGLE_CHANGE = -35;
public static final MechanismStateAdjustment CONE_DUNK_HIGH_ADJUSTMENT = new MechanismStateAdjustment(0, 0, -35, true);


public enum MechanismStates {
STOWED(
new MechanismStateCoordinates(-0.445, 0.285, MAX_WRIST_ANGLE - 2),
Expand Down Expand Up @@ -252,6 +250,11 @@ public static MechanismStateSubsystemPositions coordinatesToSubsystemPositions(M
return new MechanismStateSubsystemPositions(elevatorRealMovement, telescopingArmMovement, Math.toDegrees(angleRad));
}

/**
* Ensures that a coordinate is within the allowed range of the mechanism
*
* @return A new coordinate that is within the allowed range (or the same coordinate if it is already within the range)
*/
public static MechanismStateCoordinates limitCoordinates(MechanismStateCoordinates mechanismState) {
//wanted states
double mutableX = mechanismState.xMeters;
Expand Down Expand Up @@ -362,6 +365,8 @@ public synchronized void update() {


MechanismStateSubsystemPositions limitedStatePositions = coordinatesToSubsystemPositions(limitedStateCoordinates);

// Keepouts here are for ensuring that we don't hit field elements
if (!lastNotStowState.isKeepoutExempt && areKeepoutsEnabled) {
if (lastNotStowState != MechanismStates.DOUBLE_STATION_PICKUP) {
// Use scoring keepouts
Expand Down Expand Up @@ -433,10 +438,6 @@ public synchronized void update() {
Logger.getInstance().recordOutput("MechanismStateManager/Limited State Angle",
limitedStateCoordinates.grabberAngleDegrees);


// Check for changes


// Drive Subsystems
Robot.getElevator().setPosition(limitedStatePositions.elevatorPositionMeters);
Robot.getTelescopingArm().setPosition(limitedStatePositions.telescopingArmPositionMeters);
Expand Down

0 comments on commit faf747c

Please sign in to comment.