Skip to content

Commit

Permalink
Changes based on code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
BrownGenius committed Nov 30, 2023
1 parent e32b4c8 commit 66fdec9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/main/java/frc/robot/commands/ArmCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ArmCommand extends CommandBase {
private final double m_speedScale =
16; // to reduce stick sensitivity, this value indicates how much to scale the returned speed
// by
private final double m_minBaseRange = -1; // min range for the arm's base
private final double m_minBaseRange = 0; // min range for the arm's base
private final double m_maxBaseRange = 1; // max range for the arm's base

public ArmCommand(Arm arm, DoubleSupplier baseSpeed) {
Expand All @@ -38,12 +38,12 @@ public void execute() {
// Variable that will store the new calculated arm position
double newArmPosition;
// Determine the requested speed, but ignoring inputs near-zero (i.e. +/= m_deadband)
double currentShoulderSpeed = MathUtil.applyDeadband(m_baseSpeed.getAsDouble(), m_deadband);
double newBasePositionDelta = MathUtil.applyDeadband(m_baseSpeed.getAsDouble(), m_deadband);
// Scale the speed as desired to reduce sensitivity
currentShoulderSpeed /= m_speedScale;
newBasePositionDelta /= m_speedScale;

// Calculate the arm position by adding the computer speed to the arm base's current position
newArmPosition = m_arm.getArmBasePosition() + currentShoulderSpeed;
newArmPosition = m_arm.getArmBasePosition() + newBasePositionDelta;

// Clamp the arm's upper/lower position to the min/max range allowed
newArmPosition = MathUtil.clamp(newArmPosition, m_minBaseRange, m_maxBaseRange);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/subsystems/Arm.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class Arm extends SubsystemBase {
// private final Servo m_armElbowServo = new Servo(2);

/**
* Moves the arm base to the desired position. -1.0 is max down, and 1.0 is max up
* Moves the arm base to the desired position. 0.0 is max down and 1.0 is max up
*
* @param position desired target position for arm base [-1.0 to 1.0]
* @param position desired target position for arm base [0.0 to 1.0]
*/
public void setArmBasePosition(double position) {
// Note: This code doesn't validate the requested position. If we don't want the arm to move
Expand Down

0 comments on commit 66fdec9

Please sign in to comment.