Skip to content

Commit

Permalink
arm boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
stwiggy committed Mar 3, 2024
1 parent 6dd5c89 commit 1c54cf6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/org/carlmontrobotics/subsystems/Arm.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// Arm angle is measured from horizontal on the intake side of the robot and bounded between -3π/2 and π/2
// Wrist angle is measured relative to the arm with 0 being parallel to the arm and bounded between -π and π (Center of Mass of Roller)
public class Arm extends SubsystemBase {

private final CANSparkMax armMotorMaster = MotorControllerFactory.createSparkMax(ARM_MOTOR_PORT_1, MotorConfig.NEO);
private final CANSparkMax armMotorFollower = MotorControllerFactory.createSparkMax(ARM_MOTOR_PORT_2, MotorConfig.NEO);
private final SparkAbsoluteEncoder armEncoder = armMotorMaster.getAbsoluteEncoder(SparkAbsoluteEncoder.Type.kDutyCycle);
Expand Down Expand Up @@ -147,7 +147,9 @@ public void driveArm(double goalAngle){
TrapezoidProfile.State goalState = new TrapezoidProfile.State(goalAngle, 0);
TrapezoidProfile.State setPoint = armProfile.calculate(kDt, getCurrentArmState(), goalState);
double armFeedVolts = armFeed.calculate(goalState.velocity, 0);

if ((getArmPos() < ARM_LOWER_LIMIT_RAD && getCurrentArmGoal().velocity > 0) || (getArmPos() > ARM_UPPER_LIMIT_RAD && getCurrentArmGoal().velocity > 0)){
armFeedVolts = armFeed.calculate(getCurrentArmGoal().position, 0);
}
armPID1.setReference(setPoint.position, CANSparkBase.ControlType.kVelocity, 0, armFeedVolts);
}

Expand Down

0 comments on commit 1c54cf6

Please sign in to comment.