At the urging of AdvantageScope (AS) I’m changing how my roboRIO code sends the robot Pose3D to AS.
Old way is NetworkTableEntry
and new way is type-specific Publisher and Subscriber classes
.
I have a separate Pose3D entry for each of the different tags detected in a camera frame.
old code:
Once:
NetworkTable tagsTable = NetworkTableInstance.getDefault().getTable("apriltags");
Periodically:
tagsTable
.getEntry("robotPose3D_" + detection.getId()) // pose according to this tag
.setDoubleArray(
new double[] {
robotInFieldFrame.getTranslation().getX(),
robotInFieldFrame.getTranslation().getY(),
robotInFieldFrame.getTranslation().getZ(),
robotInFieldFrame.getRotation().getQuaternion().getW(),
robotInFieldFrame.getRotation().getQuaternion().getX(),
robotInFieldFrame.getRotation().getQuaternion().getY(),
robotInFieldFrame.getRotation().getQuaternion().getZ()
});
The new code below works but only for an instant because the publish()
reaches its capacity quickly - obviously not intended to be in the periodic loop.
failing new code:
once:
NetworkTable tagsTable = NetworkTableInstance.getDefault().getTable("apriltags");
periodically:
StructPublisher<Pose3d> pubPose = tagsTable
.getStructTopic("robotPose3D_" + detection.getId(), Pose3d.struct).publish();
pubPose.set(robotPose);
How can I publish the dynamic, camera frame-by-frame, determination of all the tag ids and associated poses and retain the tag id in NetworkTables on the display in some manner - sub-table, channel, entry?