Limelight NT - more than one value is under tx

I’m trying to use object detection on the LL 3, but won’t the tx and ty values of the objects detected clash with the tx values of the april tags detected? How do I know that I’m getting the tx value of the object, and not of an april tag on the field? Also what happens if there is more than one object or april tag on the field? Will it output many tx values?

The object detection and AprilTags are on different limelight pipelines. You can only have one on at a time, but you can switch between them. In this case, you would want to switch between the pipelines and then read the tx and ty when you switch between them. Hope this helps!

Ah that makes sense. Thank you! How do I program it to switch pipelines?

The limelight uses the Network tables to store all of its data. You can read data from the NetworkTables to get information from the limelight and you can put information on the Network tables to get the Limelight to do things. The limelight has an entry in the network tables which chooses its pipeline. By changing the value in that entry you change the pipeline.

You can try this code. If you already have a variable storing the table holding the limelight data you can skip the first two lines of code.

public static void switchPipeline(int pipeline){
    // Get the network tables instance
    NetworkTableInstance ntInstance = NetworkTableInstance.getDefault();

    // Get the limelights table. You should already be accessing all of the data from here
    NetworkTable limelightTable = ntInstance.getTable("limelight");

    // Gets the entry of the pipeline
    // The limelight looks into the value here and switches to the pipeline with that value
    NetworkTableEntry pipelineEntry = limelightTable.getEntry("pipeline");

    // Sets the value in the entry which will cause the limelight to switch pipelines
    pipelineEntry.setNumber(pipeline);
}