Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The problem is not related to the point cloud but to the fact that you're immediately destroying your publisher and exit the program. Publishing in ROS means your node needs to connect to the master, advertise that it is publishing on a topic and the other ROS nodes need to create one-to-one tcp connections to your node.

So, two things you can do to make this work:

  • add a rospy.spin() at the end of your main, so the program stays alive after publishing
  • use a latched publisher, so that when other nodes connect after a short while they will still receive the message you generate at startup: self.pub = rospy.Publisher('sonar_pointcloud', smsgs.PointCloud2, latch=True)

The problem is not related to the point cloud but to the fact that you're immediately destroying your publisher and exit the program. Publishing in ROS means your node needs to connect to the master, advertise that it is publishing on a topic and the other ROS nodes need to create one-to-one tcp connections to your node.

So, two things changes you can do have to make to your script to make this work:

  • add a rospy.spin() at the end of your main, so the program stays alive after publishing
  • use a latched publisher, so that when other nodes connect after a short while they will still receive the message you generate at startup: self.pub = rospy.Publisher('sonar_pointcloud', smsgs.PointCloud2, latch=True)