Any idea why i'm getting this error when updating to the new 2023 wpilib suite when changing from .when pressed to .onTrue?

Hello, does anyone have any idea why we might be getting the error “The method onTrue(Command) in the type Trigger is not applicable for the arguments (void)” I just updated the wpilib vs code and in the docs it said we needed to switch from. when pressed to .onTrue. Now i’m getting this error, any help would be appreciated. Thanks

1 Like

With whenPressed, you only needed to pass a runnable. But onTrue accepts a command.

For example, if the previous code was
whenPressed(someSubsystem::doSomething);

Now what you need is
onTrue(new InstantCommand(someSubsystem::doSomething, someSubsystem));

you can also use their new way of write a command
Command.run(() → subsystem.runSomething(), subsystem);

you can even static import Commands so that the syntax is just runOnce, or use the Subsystem.runOnce method which implicitly requires the subsystem for you.

awesome! Thanks for the help. Looks like it worked

1 Like

Thank you! Answered my same question. There was just a couple little things I was missing/misplaced.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.