We have a few questions about encoders and auto. So, we had the encoders working perfectly until a fire at our first competition. Now they display a value but the auto code never stops them like it did. Also, our pistons do not fire in autonomous but they do in teleop. I was told I need to find a way to change the is finished() to true/false but I am not sure how to do so for pistons. Any ideas?
It is likely that your drive encoders command isn’t ending. then, the command group can’t start the next sequential command which in this case is your piston fire command. Add some code to set isFinished() to true in your DriveEncoders command and see if that works.
If you are asking about how to change your GearRelease command so that its isFinished() method returns true, you need to change the “false” to “true” as shown below:
public class GearRelease extends Command {
public GearRelease() {
requires(Robot.gearMech);
}
protected void initialize() {
}
protected void execute() {
Robot.gearMech.GearRelease();
}
protected boolean isFinished() {
// If false, then command never ends until interrupted
// return false;
// By returning true, command will end right away
return true;
}
protected void end() {
}
protected void interrupted() {
}
}
You might want to do this for all of your commands that are used in Autonomous that only manipulate a solenoid (piston).
However, this means the refactored commands will complete immediately. So, if you use them in a sequential command group, you may need to add small wait commands to give your pistons a small amount of time to move/settle into place before the next step. Whether or not you need this small delay will depend on your robot and what you are trying to do.
public static Command createAuton1() {
CommandGroup cg = new CommandGroup();
// ... add initial auton commands
// Open gear mechanism
cg.addSequential(new GearRelease());
// If we need to be sure that the mechanism is fully open
// before the next autonomous, then wait a small number of
// seconds to allow the mechanism to move into place
cq.addSequential(new WaitCommand(0.1));
// ... continue addition auton commands ...
return cg;
}