How to change Limelight pipelines with buttons?

How are teams changing Limelight pipelines by pressing buttons? We are trying to implement this logic in our code, and it worked once before, but now it doesn’t work anymore.

Ours is setup a bit differently, but the the main functionality should work just fine.

In RobotContainer with the rest of our controller bindings, we use a lambda expression to run the changePipeline() method and then plug in the parameters.

  driveJoy.getRight().onTrue(new RunCommand(() -> VisionSubsystem.setPipeline(Limelights.getDefaultLimelight(), Pipelines.getDefaultPipeline())));

The parameters for this example are custom classes for limelights and pipelines to make organizing things easier. So you can just replace those directly with whatever your setPipeline method needs.

Lambda is a super powerful tool to keep in mind when programming. Especially when dealing with buttons and commands.

Great, thank you so much for the help! Which parts of the lambda expression are the parameters?

1 Like

After rereading my original message, I realized that the second part makes absolutely no sense, so hopefully this clears up the confusion I caused.

The lambda is the () -> part which just calls the function setPipeline(). The parameters are what are plugged into the setPipeline function. Those being getDefaultLimelight and getDefaultPipeline which are methods that just return either a Limelight or Pipeline object to feed into setPipeline().

1 Like

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