Skip to content

Commit

Permalink
rad for lower upper angle
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonS09 committed Mar 4, 2024
1 parent 33520ca commit dd1ac71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/carlmontrobotics/commands/ArmTeleop.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void execute() {
double deltaT = currTime - lastTime;

double goalArmRad = goalState.position + speeds * deltaT;
goalArmRad = MathUtil.clamp(goalArmRad, UPPER_ANGLE_LIMIT, LOWER_ANGLE_LIMIT);
goalArmRad = MathUtil.clamp(goalArmRad, UPPER_ANGLE_LIMIT_RAD, LOWER_ANGLE_LIMIT_RAD);
goalArmRad = MathUtil.clamp(goalArmRad, armSubsystem.getArmPos()+ARM_TELEOP_MAX_GOAL_DIFF_FROM_CURRENT_RAD, armSubsystem.getArmPos()-ARM_TELEOP_MAX_GOAL_DIFF_FROM_CURRENT_RAD);
goalState = new TrapezoidProfile.State(goalArmRad, 0);
armSubsystem.setArmTarget(goalState.position);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/carlmontrobotics/subsystems/Arm.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public Arm() {

armPIDMaster.setFeedbackDevice(armMasterEncoder);
armPIDMaster.setPositionPIDWrappingEnabled(true);
armPIDMaster.setPositionPIDWrappingMinInput(LOWER_ANGLE_LIMIT);
armPIDMaster.setPositionPIDWrappingMaxInput(UPPER_ANGLE_LIMIT);
armPIDMaster.setPositionPIDWrappingMinInput(LOWER_ANGLE_LIMIT_RAD);
armPIDMaster.setPositionPIDWrappingMaxInput(UPPER_ANGLE_LIMIT_RAD);
//two PIDs?

SmartDashboard.putData("Arm", this);
Expand Down Expand Up @@ -150,7 +150,7 @@ private void driveArm(){

setPoint = armProfile.calculate(kDt, setPoint, goalState);
double armFeedVolts = armFeed.calculate(goalState.position, goalState.velocity);
if ((getArmPos() < LOWER_ANGLE_LIMIT && getCurrentArmGoal().velocity > 0) || (getArmPos() > UPPER_ANGLE_LIMIT && getCurrentArmGoal().velocity > 0)){
if ((getArmPos() < LOWER_ANGLE_LIMIT_RAD && getCurrentArmGoal().velocity > 0) || (getArmPos() > UPPER_ANGLE_LIMIT_RAD && getCurrentArmGoal().velocity > 0)){
armFeedVolts = armFeed.calculate(getCurrentArmGoal().position, 0);
}
armPIDMaster.setReference(setPoint.position, CANSparkBase.ControlType.kVelocity, 0, armFeedVolts);
Expand Down Expand Up @@ -227,6 +227,6 @@ public boolean armAtSetpoint() {
}

public double getArmClampedGoal(double goal) {
return MathUtil.clamp(MathUtil.inputModulus(goal, ARM_DISCONT_RAD, ARM_DISCONT_RAD + 2 * Math.PI), LOWER_ANGLE_LIMIT, UPPER_ANGLE_LIMIT);
return MathUtil.clamp(MathUtil.inputModulus(goal, ARM_DISCONT_RAD, ARM_DISCONT_RAD + 2 * Math.PI), LOWER_ANGLE_LIMIT_RAD, UPPER_ANGLE_LIMIT_RAD);
}
}

0 comments on commit dd1ac71

Please sign in to comment.