Command Not ending

We have an issue where it seems a command is not executing. For mechanical reasons we need to rotate with the arm at level.

WE have a method that constructs a command like this. The until condition is met, we output the pid controllers atSetpoint to the shufflebord and it is at the setpoint but the angle setpoint being set

    public Command extendAndRotateCommand(Rotation2d angle, double length) {
        return run( () -> setExtensionSetpoint(length))
            .andThen( runOnce( () -> setAngleSetpointRadians(angle.getRadians())));

Can you run a print command after the and then to check if it is being interrupted?

If that works how are verifying setanglesetpoint isn’t being run? Can you print at the beginning of it

I knew it wasn’t running because the angleSetpointsRadians never changed on shuffleboard, the problem was a stupid mistake. This command wasn’t the one being run as later in the code another trigger was bound to the same button, that trigger happened to setExtensionSetpoint so it appeared that the first command in the sequence ran and the second didn’t but it was actually an entirely different command that ran.

I also noticed that you’re not requiring the subsystem. This makes it possible for two commands that use subsystem to run at once. You don’t want that.

Assuming the method is on your subsystem, you should pass this as a requirement:

   public Command extendAndRotateCommand(Rotation2d angle, double length) {
        return run( () -> setExtensionSetpoint(length), this)
            .andThen( runOnce( () -> setAngleSetpointRadians(angle.getRadians()), this));

The run factory within Subsystem automatically requires this.


  default CommandBase run(Runnable action) {
    return, this);

  default CommandBase runOnce(Runnable action) {
    return Commands.runOnce(action, this);

Oh that makes sense. With just the code snippet, I assumed there was a static import of

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.