本文整理汇总了Python中sensor_msgs.point_cloud2.read_points方法的典型用法代码示例。如果您正苦于以下问题:Python point_cloud2.read_points方法的具体用法?Python point_cloud2.read_points怎么用?Python point_cloud2.read_points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sensor_msgs.point_cloud2
的用法示例。
在下文中一共展示了point_cloud2.read_points方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ros_to_pcl
# 需要导入模块: from sensor_msgs import point_cloud2 [as 别名]
# 或者: from sensor_msgs.point_cloud2 import read_points [as 别名]
def ros_to_pcl(ros_cloud):
""" Converts a ROS PointCloud2 message to a pcl PointXYZRGB
Args:
ros_cloud (PointCloud2): ROS PointCloud2 message
Returns:
pcl.PointCloud_PointXYZRGB: PCL XYZRGB point cloud
"""
points_list = []
for data in pc2.read_points(ros_cloud, skip_nans=True):
points_list.append([data[0], data[1], data[2], data[3]])
pcl_data = pcl.PointCloud_PointXYZRGB()
pcl_data.from_list(points_list)
return pcl_data
示例2: on_point_cloud
# 需要导入模块: from sensor_msgs import point_cloud2 [as 别名]
# 或者: from sensor_msgs.point_cloud2 import read_points [as 别名]
def on_point_cloud(self, data):
self._counter += 1
if self._counter % self._modulo_to_send != 0:
return
timestamp = erdos.Timestamp(coordinates=[self._msg_cnt])
points = []
for data in pc2.read_points(data,
field_names=('x', 'y', 'z'),
skip_nans=True):
points.append([data[0], data[1], data[2]])
points = np.array(points)
point_cloud = pylot.perception.point_cloud.PointCloud(
points, self._lidar_setup)
msg = PointCloudMessage(timestamp, point_cloud)
self._point_cloud_stream.send(msg)
watermark_msg = erdos.WatermarkMessage(timestamp)
self._point_cloud_stream.send(watermark_msg)
self._logger.debug('@{}: sent message'.format(timestamp))
self._msg_cnt += 1
示例3: get_depth
# 需要导入模块: from sensor_msgs import point_cloud2 [as 别名]
# 或者: from sensor_msgs.point_cloud2 import read_points [as 别名]
def get_depth(self, x, y):
gen = pc2.read_points(self.pc, field_names='z', skip_nans=False, uvs=[(x, y)]) #Questionable
print gen
return next(gen)
示例4: _cameraCb
# 需要导入模块: from sensor_msgs import point_cloud2 [as 别名]
# 或者: from sensor_msgs.point_cloud2 import read_points [as 别名]
def _cameraCb(self, msg):
'''
Parse points and fields from a pointcloud2 message. For more info:
https://answers.ros.org/question/208834/read-colours-from-a-pointcloud2-python/
Parameters:
-----------
msg: ros sensor_msgs/PointCloud2 message
'''
gen = pc2.read_points(msg, skip_nans=True)
print(gen)
raise RuntimeError('deprecated')
pass
示例5: load_snap_from_list
# 需要导入模块: from sensor_msgs import point_cloud2 [as 别名]
# 或者: from sensor_msgs.point_cloud2 import read_points [as 别名]
def load_snap_from_list(self, i):
self.cones = np.zeros((0, 2))
msg = self.list_snapshots[i]
gen = point_cloud2.read_points(msg)
for p in gen:
xy = np.array([p[0], p[1]])
self.cones = np.vstack([self.cones, xy])