ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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:
rospy.spin()
at the end of your main, so the program stays alive after publishingself.pub = rospy.Publisher('sonar_pointcloud', smsgs.PointCloud2, latch=True)
2 | No.2 Revision |
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:
rospy.spin()
at the end of your main, so the program stays alive after publishingself.pub = rospy.Publisher('sonar_pointcloud', smsgs.PointCloud2, latch=True)