#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
TOPIC = "sub_topic"
class SubNode(Node):
def __init__(self):
node_name="pub"
super().__init__(node_name)
self.pub = self.create_subscription(String, TOPIC, self.callback, 10)
self.get_logger().info("Hello SUB")
def callback(self, msg):
self.get_logger().info(msg.data)
def main(args=None):
rclpy.init(args=args)
node = SubNode()
rclpy.spin(node)
node.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()