title: Publisher/Subscriber ROS Python
body: <p>Good evening, I need to create a publisher that sends pointcloud2 after reading them from my previously acuisite bag. This is to simulate realtime execution.</p>
  <p>In rqt_graph, everything seems to be connected correctly but pub and sub don't seem to communicate at all.</p>
  <p>This is my publisher:</p>
  <pre><code>#!/usr/bin/env python
  import rospy
  
  from sensor_msgs.msg import PointCloud2
  import std_msgs.msg
  import sensor_msgs.point_cloud2 as pcl2
  import rosbag
  
  def talker(msg):
      pub = rospy.Publisher('chatter', PointCloud2)
      rospy.init_node('talker', anonymous=True)
      rate = rospy.Rate(1) #hz
      rospy.loginfo(msg)
      pub.publish(msg)
      rate.sleep()
   
  if __name__ == '__main__':
      bag = rosbag.Bag('bag2.bag')
      
      for msg in bag.read_messages(topics=['/d435/depth/color/points']):
          talker(msg)
  </code></pre>
  <p>And this is my subscriber:</p>
  <pre><code>#!/usr/bin/env python
  import rospy
  from sensor_msgs.msg import PointCloud2
  import std_msgs.msg
  import sensor_msgs.point_cloud2 as pcl2
  
  def callback(data):
     #rospy.loginfo(rospy.get_caller_id() + &quot;I heard %s&quot;, data.data)
      print(&quot;ptCloud received&quot;)
  
      ptc = Point
  
  def listener():
     rospy.init_node('listener', anonymous=True)
  
     rospy.Subscriber(&quot;chatter&quot;, PointCloud2, callback)
     rospy.spin()
  
  if __name__ == '__main__':
     listener()
  </code></pre>
  <p>Could someone help me? Trying with strings using</p>
  <pre><code>from std_msgs.msg import String
  </code></pre>
  <p>the communication worked, but not with pointclouds. I'm a newbie to ROS, help!</p>