I am trying to print limelight.tx values to the console while an x-box “b” button is being held down, however, values are being sent constantly. What should I do to fix this?
Your println is in the execute of a command that (I assume) has isFinished() { return false; }
, so yes, its going to print continuously until that command completes or is interrupted.
I highly recommend using network tables for debugging rather than print statements. For example, you could use the various SmartDashboard.put methods then just read the value in your dashboard
We were just using the print.ln statement to make sure the command was running properly (which it isn’t). We realized we never added an end() function, but after adding it values are still printing continuously. The command should complete after the print statement, so we’re not sure why it is not. We also did not have an isFinished() function at the time of posting (we tried both with and without one after adding the end() function, both times had the same result).
Commands don’t inherently know how long you want them to run, so you have to tell them. That’s what the isFinished method does. If you only want it to run through once, you can have that method simply return true
. Want it to run forever, return false
(this is the default). Otherwise you can add whatever boolean end condition you need.
Change onTrue to whileTrue
You could also try changing .onTrue to .whileTrue so it has an interrupt. Additionally you can make a refrence to the command instead of making a new one every time.
Code is likely wrong since i’m writing this on my phone
private LimelightCenter m_limelightCenter = new LimeLightCenter(drivetrain, supplier)
new JoystickButton(m_driverController, 9)
.whileTrue(m_limelightCenter);
It still only creates a single instance. The reference as you did it doesn’t actually change that behavior.
My mistake, I meant to say a single reference to the command so that it is easily findable and reusable
You generally should not store command references; it runs the risk of putting commands in inconsistent state.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.