We (our programming TEAM), have being trying to create a command for autonomous paths, that will rev our shooter up to speed, and angle our shooter to the correct °, however, we are having issues with the last command, which feeds a note into the shooter.
We need to have the Pivot° command, as well as our revShooter command run in parallel, and until the command ends, so we have to use a parallel command group.
However, we can’t seem to be able to delay our command which feeds a note into the shooter.
We currently have this, but can’t find a way to get a booleanSupplier for the .onlyWhile command:
Any ideas on how we can either delay the FeedNoteAuto command, or find a booleanSupplier for .onlyWhile()? (Assuming the supplier would be something similar to isShooterAtSpeed)
Maybe you could use .beforeStarting(new WaitCommand(x)) instead of .onlyWhile? You’d have to get the timing right, but I think that could work. x would be however many seconds you want to wait
If I’m understanding correct, could you do something like
new ParallelRaceGroup(
new AnglePivout(pivot),
new RevShooter(Shooter),
new SequentialCommandGroup(
new WaitCommand(4),
new FeedNoteAuto(storage)
)
)
if you just wanted to make a delay. Or if you wanted to wait for the anglePivot maybe you could make a function in Pivot.java that checks if the angle is close to the calculated one. Something like
return Math.isNear(pivotPID.calculate(pivotRelativeEncoder.getPosition(), calculateAngle()), povitRelativeEncoder.getPosition(), 0.1) // the order here might be different, 0.1 is tolerance
and then do .until() or onlyWhile(pivot::atAngle) or however.
I’m writing this on my phone right now so I cant check the syntax or anything right now, but I can later today when I get home.
but in your shooter subsystem you already have the static variable isatspeed, so for your boolean supplier you can just make a lambda function. .onlyWhile(()->{return Shooter.isatspeed;}
So you probably don’t want a race group in this case. Check out this link with a pretty picture of the various groups.
It sounds like what you want is in parallel
Angle the shooter pivot to a specific point.
Spin the wheels to the appropriate speed
and then
3. Index the note into the shooter.
Lots of ways to compose that, but one example could be:
new AnglePivot(pivot).until(pivot.atAngle())
.alongwith(new Revshooter(shooter).until(shooter::atSpeed)
.withTimeout(4)
.andthen(new FeedNoteAuto(storage)
.andThen(new StopShooter(shooter) // assuming you want to the motors to stop
If my Java understanding is correct, that will create a ParallelRaceGroup wherein the ParallelCommand Group(AnglePivot, Shooter Spin Up) and a timeout of 4 seconds are all racing.
That ParallelRaceGroup will then be the first command of the SequentialCommandGroup, which will then index the note, and stop the shooters.
These decorators compose commands within each other, and all work with each other. In this case, beforeStarting would create a SequentialCommandGroup containing a ParallelCommandGroup.