-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sub.py
More file actions
29 lines (24 loc) · 964 Bytes
/
test_sub.py
File metadata and controls
29 lines (24 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import rclpy
from rclpy.node import Node
from multi_agent_mapping.msg import GlobalDescriptor
class GlobalDescriptorSubscriber(Node):
def __init__(self):
super().__init__('global_descriptor_subscriber')
self.subscription = self.create_subscription(
GlobalDescriptor,
'a/distributedMapping/globalDescriptors', # Replace 'robot_name' with the actual robot name
self.listener_callback,
50 # QoS depth
)
self.subscription # prevent unused variable warning
def listener_callback(self, msg):
self.get_logger().info(f'Received Global Descriptor with index: {msg.index}')
def main(args=None):
rclpy.init(args=args)
global_descriptor_subscriber = GlobalDescriptorSubscriber()
rclpy.spin(global_descriptor_subscriber)
# Destroy the node explicitly
global_descriptor_subscriber.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()