Triggers with constant conditions never trigger #5608
Labels
component: command-based
WPILib Command Based Library
type: fix
Iterations on existing features or infrastructure.
(Adapted from https://discord.com/channels/176186766946992128/368993897495527424/1147691290365005835)
If a
Trigger
's condition maintains the same value as when it was started, no bindings will ever be triggered. For example,new Trigger(() -> true).whileTrue(cmd.repeatedly())
will never schedulecmd
, because the storedm_pressedLast
/previous
field of theEventLoop
callback is initialized with the value of the trigger's condition at binding time (true
) and no changes from that value occur, which is the condition to schedulecmd
.Desired behavior is for it to be possible to make something like
new Trigger(() -> true).whileTrue(Commands.print("Hi").repeatedly())
spam print "Hi" on every poll of the command scheduler's default event loop. This issue is still open for discussion of how this should be done- For example, I was considering having an enum parameter to the constructor which would specify the initial value of the previous input variable (always true, always false, the value of the condition at binding time (current behavior), and the negated value of the condition at binding time), but there are probably other possibilities. (For example, maybe we only want to support the variable being initialized with a single boolean value regardless of the condition's state, so we can just have a boolean parameter instead of an enum)The text was updated successfully, but these errors were encountered: