Skip to content

ArmTeleop() will immediately override any other commands that set a goal #24

@brettle

Description

@brettle

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions