Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
feat(arm): Add shoulder stops.
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenheroux committed Feb 9, 2024
1 parent 419238f commit 72a61bc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/main/java/frc/robot/arm/ArmConstants.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package frc.robot.arm;

import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.util.Units;
import frc.lib.CAN;

Expand All @@ -16,6 +17,12 @@ public static class ShoulderMotorConstants {
/** Maximum voltage that can be applied to the shoulder motor. */
public static final double MAXIMUM_VOLTAGE = 2.0;

/** Minumum angle of the shoulder joint. */
public static final Rotation2d MINIMUM_ANGLE = Rotation2d.fromDegrees(20);

/** Maximum angle of the shoulder joint. */
public static final Rotation2d MAXIMUM_ANGLE = Rotation2d.fromDegrees(90);

/** Shoulder pivot to elbow pivot distance in meters. */
public static final double SHOULDER_TO_ELBOW_DISTANCE = Units.inchesToMeters(16.775);
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/frc/robot/arm/ShoulderMotorIOSim.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public ShoulderMotorIOSim() {
ShoulderMotorConstants.GEARING,
0.1,
ShoulderMotorConstants.SHOULDER_TO_ELBOW_DISTANCE,
Units.degreesToRadians(10),
Units.degreesToRadians(90),
ShoulderMotorConstants.MINIMUM_ANGLE.getRadians(),
ShoulderMotorConstants.MAXIMUM_ANGLE.getRadians(),
true,
Units.degreesToRadians(90));

Expand Down Expand Up @@ -67,8 +67,6 @@ public void setSetpoint(double positionRotations) {
// TODO Remove, only for characterization
@Override
public void setVoltage(double volts) {
System.out.println(volts);

singleJointedArmSim.setInputVoltage(volts);
}

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/frc/robot/arm/ShoulderMotorIOSparkMax.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ public void setVoltage(double volts) {
MathUtil.clamp(
volts, -ShoulderMotorConstants.MAXIMUM_VOLTAGE, ShoulderMotorConstants.MAXIMUM_VOLTAGE);

if (volts > 0.0
&& getPositionRotations() > ShoulderMotorConstants.MAXIMUM_ANGLE.getRotations()) {
volts = 0.0;
} else if (volts < 0.0
&& getPositionRotations() < ShoulderMotorConstants.MINIMUM_ANGLE.getRotations()) {
volts = 0.0;
}

sparkMax.setVoltage(volts);
}

Expand Down

0 comments on commit 72a61bc

Please sign in to comment.