ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
read_points gives you a generator (keyword 'yield'). So you can just iterate over it to find your obstacles and not crash your shiny robot
from sensor_msgs.msg import PointCloud2
from sensor_msgs import point_cloud2
def callback_pointcloud(data):
assert isinstance(data, PointCloud2)
gen = point_cloud2.read_points(data)
print type(gen)
for p in gen:
print p # type depends on your data type, first three entries are probably x,y,z