-
Notifications
You must be signed in to change notification settings - Fork 1
Description
ArmTeleop.execute() says:
| double speeds = getRequestedSpeeds(); | |
| double currTime = Timer.getFPGATimestamp(); | |
| double deltaT = currTime - lastTime; | |
| double goalArmRad = goalState.position + speeds * deltaT; | |
| 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); |
Because ArmTeleop is the default command, it will run whenever there is no other command scheduled that requires Arm. None of the arm's target-setting InstantCommands in RobotContainer require Arm and they all finish immediately anyway. That means that as soon as they finish ArmTeleop will start again and the above code will run. Note that it will set a new goal that is clamped to be close to the arm's current position. As a result, the goal set by the instant command will be overridden.
Suggested fix:
If speeds is 0 (ie. the joystick value is within Constants.OI.JOY_THRESH of 0) that means the user has not requested to move the arm, so return immediately (so the goal will not be modified). Otherwise, the rest of the method should run as written to enforce the user's most recent desired which should override the last goal set by an instant command.