Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #534 #563

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/webviz-core/src/players/RosbridgePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default class RosbridgePlayer implements Player {
_bobjects: BobjectMessage[] = []; // Queue of bobjects that we'll send in next _emitState() call.
_messageOrder: TimestampMethod = "receiveTime";
_requestTopicsTimeout: ?TimeoutID; // setTimeout() handle for _requestTopics().
_pendingTopicPublishers: ?(AdvertisePayload[]) = null;
_topicPublishers: { [topicName: string]: ROSLIB.Topic } = {};
_parsedMessageDefinitionsByTopic: ParsedMessageDefinitionsByTopic = {};
_bobjectTopics: Set<string> = new Set();
Expand Down Expand Up @@ -101,6 +102,12 @@ export default class RosbridgePlayer implements Player {
}
this._rosClient = rosClient;
this._requestTopics();

// If required, set publishers to what was requested before connection was established
if (this._pendingTopicPublishers) {
this.setPublishers(this._pendingTopicPublishers);
this._pendingTopicPublishers = null;
}
});

rosClient.on("error", (error) => {
Expand Down Expand Up @@ -326,6 +333,13 @@ export default class RosbridgePlayer implements Player {
publisher.unadvertise();
}
this._topicPublishers = {};

// If _rosClient is not set, defer publisher configuration to the connection event
if (!this._rosClient) {
this._pendingTopicPublishers = publishers;
return; // Stop here, otherwise topics will get created with ros = undefined
}

for (const { topic, datatype } of publishers) {
this._topicPublishers[topic] = new ROSLIB.Topic({
ros: this._rosClient,
Expand Down