We are using 2023 firmware of limelight. While we are trying to get the values from the NetworkTable API, we find that the value won’t be updated, though it seems to be tracking from the browser.
Things we have done:
configure the limelight port as well as the domain in RobotInit():
for (int port = 5800; port <= 5805; port++) {
PortForwarder.add(port, "limelight.local", port);
}
get NetworkTable which is written completely the same as the docs, so it may not matter.
We recently managed to deal with this problem as we can use NetworkTable API to read the value of the AprilTag, which indicated that we could now successfully connected to the limelight camera and the cam can identify the tags.
However, when I used the following code to get the 3D target area & angle, it failed to get anything.
(I can get the value using 2D targeting APIs, but I have to use 3D location so it’s useless. )
public class limelight extends SubsystemBase {
public limelight() {
limelightConfig.getEntry("camMode").setNumber(0);
}
NetworkTableEntry tableData = NetworkTableInstance.getDefault().getTable("limelight").getEntry("botpose");
public double defaultData[] = new double[6];
@Override
public void periodic() {
data = tableData.getDoubleArray(defaultData);
trackingStatus = (NetworkTableInstance.getDefault().getTable("limelight").getEntry("tv").getDouble(0) == 1 ? true : false);
if (data != defaultData) {
x = data[0]; //get the x position of limelight
y = data[1]; //get y
angle = data[4]; //get the angle of the bot
}
}
}
However, this code will lead to some issue “no robot code”.
I’ve tried the new entry called “targetpose_robotspace”, it solved the problem above, but still can’t fetch the data of the target area.
Did you see anything on our console? Does this code successfully build and deploy ? I don’t see a declaration in this class of the trackingStatus variable.
I’m sorry that I just forgot to paste it to the code. Excuse my poor expression, I suppose I have mentioned that the code ran rather well and I can now succeed to recognize the value of the tag while the target area can’t be gained through botpose API but still available in normal 2D tracking API.
I don’t know why is the reason and it’s rather urgent for me.
alright, it turns out to be some problems with an empty pointer, now we changed to parsing JSON and checking empty pointers in advance then it works well.