Skip to content

Commit

Permalink
Merge pull request #105 from DeepBlueRobotics/fix-Watcher-not-reusing…
Browse files Browse the repository at this point in the history
…-publishers

Fix Too many NT publishers error if getting sim state for many steps #104.
  • Loading branch information
CoolSpy3 committed Jul 13, 2024
2 parents 6c3df17 + 4658385 commit 5807f88
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ private Watcher(String defPath) {
}
}
});
}

private synchronized void reset() {
positionReady = new CompletableFuture<>();
rotationReady = new CompletableFuture<>();
velocityReady = new CompletableFuture<>();
var pubSubOptions = new PubSubOption[] {PubSubOption.sendAll(true), // Send every update
PubSubOption.keepDuplicates(true), // including duplicates
PubSubOption.periodic(Double.MIN_VALUE), // ASAP
Expand All @@ -127,16 +121,22 @@ private synchronized void reset() {
table.getDoubleArrayTopic(NTConstants.POSITION_TOPIC_NAME);
positionPublisher = positionTopic.publish(pubSubOptions);
positionTopic.setCached(false);
positionPublisher.set(dummyPosition);
rotationTopic =
table.getDoubleArrayTopic(NTConstants.ROTATION_TOPIC_NAME);
rotationPublisher = rotationTopic.publish(pubSubOptions);
rotationTopic.setCached(false);
rotationPublisher.set(dummyRotation);
velocityTopic =
table.getDoubleArrayTopic(NTConstants.VELOCITY_TOPIC_NAME);
velocityPublisher = velocityTopic.publish(pubSubOptions);
velocityTopic.setCached(false);
}

private synchronized void reset() {
positionReady = new CompletableFuture<>();
rotationReady = new CompletableFuture<>();
velocityReady = new CompletableFuture<>();
positionPublisher.set(dummyPosition);
rotationPublisher.set(dummyRotation);
velocityPublisher.set(dummyVelocity);
inst.flush();
}
Expand Down

0 comments on commit 5807f88

Please sign in to comment.