-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lifespan not working with transiet_local subscriber
https://github.com/ros2/rclpy/issues/1163 Signed-off-by: Tomoya Fujita <[email protected]>
- Loading branch information
1 parent
16be352
commit 1c8bbc6
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import rclpy | ||
from rclpy.node import Node | ||
from rclpy.qos import ( | ||
QoSDurabilityPolicy, | ||
QoSProfile, | ||
QoSReliabilityPolicy, | ||
) | ||
|
||
from std_msgs.msg import Bool | ||
|
||
|
||
class PubNode(Node): | ||
def __init__(self): | ||
super().__init__("pub_node") | ||
|
||
qos = QoSProfile( | ||
depth=5, | ||
durability=QoSDurabilityPolicy.TRANSIENT_LOCAL, | ||
reliability=QoSReliabilityPolicy.RELIABLE, | ||
) | ||
|
||
self.pub = self.create_publisher(Bool, "/some_topic", qos) | ||
self.pub.publish(Bool(data=False)) | ||
|
||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
node = PubNode() | ||
|
||
try: | ||
rclpy.spin(node) | ||
except KeyboardInterrupt: | ||
pass | ||
|
||
node.destroy_node() | ||
rclpy.shutdown() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from rclpy.node import Node | ||
from rclpy.qos import ( | ||
QoSDurabilityPolicy, | ||
QoSProfile, | ||
QoSReliabilityPolicy, | ||
) | ||
from std_msgs.msg import Bool | ||
from rclpy.duration import Duration | ||
import rclpy | ||
|
||
|
||
class SubNode(Node): | ||
def __init__(self): | ||
super().__init__("sub_node") | ||
|
||
qos = QoSProfile( | ||
depth=5, | ||
durability=QoSDurabilityPolicy.TRANSIENT_LOCAL, | ||
reliability=QoSReliabilityPolicy.RELIABLE, | ||
lifespan=Duration(seconds=2), | ||
) | ||
print(qos) | ||
self.sub = self.create_subscription( | ||
Bool, | ||
"/some_topic", | ||
self.my_callback, | ||
qos, | ||
) | ||
|
||
def my_callback(self, msg: Bool): | ||
self.get_logger().info("Received: {}".format(msg.data)) | ||
|
||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
node = SubNode() | ||
|
||
try: | ||
rclpy.spin(node) | ||
except KeyboardInterrupt: | ||
pass | ||
|
||
node.destroy_node() | ||
rclpy.shutdown() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |