Compare commits
No commits in common. "ba2369623bbe587bfca6e4e343940d7545ab467c" and "627c1c925a4dd4025f3717369e13ce9c8a348e78" have entirely different histories.
ba2369623b
...
627c1c925a
@ -119,43 +119,33 @@ class Topic {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Unsubscribe from the topic.
|
||||
Future<void> unsubscribe() async {
|
||||
if (subscribeId != null) {
|
||||
// Send the request and reset the subscription variables.
|
||||
await safeSend(unsubscribeReq());
|
||||
await safeSend(Request(
|
||||
op: 'unsubscribe',
|
||||
id: subscribeId,
|
||||
topic: name,
|
||||
));
|
||||
// await ros.requestUnsubscribe(id);
|
||||
subscription = null;
|
||||
subscribeId = null;
|
||||
}
|
||||
}
|
||||
|
||||
Request unsubscribeReq() {
|
||||
return Request(
|
||||
op: 'unsubscribe',
|
||||
id: subscribeId,
|
||||
topic: name,
|
||||
);
|
||||
}
|
||||
|
||||
/// Publish a [message] to the topic.
|
||||
Future<void> publish(dynamic message) async {
|
||||
// Advertise the topic and then send the publish request.
|
||||
await advertise();
|
||||
publishId = ros.requestPublisher(name);
|
||||
await safeSend(publishReq(message));
|
||||
}
|
||||
|
||||
Request publishReq(dynamic message) {
|
||||
return Request(
|
||||
await safeSend(Request(
|
||||
op: 'publish',
|
||||
topic: name,
|
||||
id: publishId,
|
||||
msg: message,
|
||||
latch: latch,
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
/// Advertise the topic.
|
||||
@ -163,21 +153,17 @@ class Topic {
|
||||
if (!isAdvertised) {
|
||||
// Send the advertisement request.
|
||||
advertiseId = ros.requestAdvertiser(name);
|
||||
await safeSend(advertiseReq());
|
||||
// If the ROS connection closes show that we're not advertising anymore.
|
||||
watchForClose();
|
||||
}
|
||||
}
|
||||
|
||||
Request advertiseReq() {
|
||||
return Request(
|
||||
await safeSend(Request(
|
||||
op: 'advertise',
|
||||
id: advertiseId,
|
||||
type: type,
|
||||
topic: name,
|
||||
latch: latch,
|
||||
queueSize: queueSize,
|
||||
);
|
||||
));
|
||||
// If the ROS connection closes show that we're not advertising anymore.
|
||||
watchForClose();
|
||||
}
|
||||
}
|
||||
|
||||
/// Wait for the connection to close and then reset advertising variables.
|
||||
@ -201,8 +187,6 @@ class Topic {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Safely send a [message] to ROS.
|
||||
Future<void> safeSend(Request message) async {
|
||||
// Send the message but if we're not connected and the [reconnectOnClose] flag
|
||||
|
Loading…
Reference in New Issue
Block a user