PID Command not ending

Hello i am trying to make a autonomous period. I have 2 pid command, one of them intake and the other one is elevator. I am using Sequential Command Group class. In my code AutoElevator starts but not ends. Is that related of my pid is not perfect for example: My setPoint is 0.3 meters but my real position is like 0.301843. Here is my Elevator Pid Command:

on line 47 you have the isFinished() method always returning false. this should return true when you want it to end. So you could make some logic that returns true when you want your command to end and false when it is supposed to keep running.

1 Like

thanks a lot do you have any example github

Here is how I would do it by creating a Boolean in the liftSubsystem subsystem.

Create methods like this if you don’t already have them.

  public double getLiftHeight() {
    return liftEncoder.getPosition();

  public boolean isAtHeight() {
    double error = getLiftHeight() - liftSetpoint;
    return (Math.abs(error) < allowableError);

And then looking at that boolian in the isFinished() method of your AutoElevator Command.

  public boolean isFinished() {
          return this.liftSubsystem.isAtHeight();

A link to our code is below. It has a few more different things going on because we sometimes did not want it to end, but you can look at our

LHSPantherbots/2023-Swerve-X at Worlds (


thanks a lot