addSequential NOT Working for Servos

I have two programs to run a servo - if I assign the programs individually to buttons they work but if I build a command group with those two commands in it - so they go one after another - nothing happens - I assigned this command group to a button and it doesn’t work - nothing happens when I assign the group as the autonomous command either.

Here it is:

addSequential(new Move45());
addSequential(new Move0());

ANY help will be GREATLY appreciated! THANKS!

what do the commands look like? I’m guessing you’re sending the servo one command to go to 45 degrees (for ~20ms) then immediately telling it to go back to 0.

you might want to add :

addSequential(new Move45());
addSequential(new WaitCommand(timeout));
addSequential(new Move0());

This will pause for the specified amount of time between the two commands.

Here are the commands:

package edu.wpi.first.LFRobot2014.commands;

/**
 *
 * @author FrankyMonezz
 */
public class PrepBall extends CommandBase {
    
    public PrepBall() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        requires(launchservo);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        //move servo to 45 degrees
        launchservo.setPos(45);
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return (launchservo.getPos() == 45);
         
    }

    // Called once after isFinished returns true
    protected void end() {
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}

package edu.wpi.first.LFRobot2014.commands;

/**
 *
 * @author FrankyMonezz
 */
public class PrepBall2 extends CommandBase {
    
    public PrepBall2() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        requires(launchservo);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        //move servo back to default location
        launchservo.setPos(0);
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return (launchservo.getPos() == 0);
    }

    // Called once after isFinished returns true
    protected void end() {
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}

I will try putting in a wait command tomorrow - THANKS!

A delay should fix your problem. While you are using what seems like a logical isFinished condition the reality is that it won’t work. A servo provides no feedback to the rest of the system. A servo takes time to move from point A to point B. calling setPos(45) and then calling getPos() will yield 45. getPos() only tells you where the servo was last set. It doesn’t take into account where the servo actually is.

Kyle