本文整理汇总了Python中sensor_msgs.point_cloud2.create_cloud_xyz32方法的典型用法代码示例。如果您正苦于以下问题:Python point_cloud2.create_cloud_xyz32方法的具体用法?Python point_cloud2.create_cloud_xyz32怎么用?Python point_cloud2.create_cloud_xyz32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sensor_msgs.point_cloud2
的用法示例。
在下文中一共展示了point_cloud2.create_cloud_xyz32方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: publish_lidar
# 需要导入模块: from sensor_msgs import point_cloud2 [as 别名]
# 或者: from sensor_msgs.point_cloud2 import create_cloud_xyz32 [as 别名]
def publish_lidar(self, sensor_id, data):
"""
Function to publish lidar data
"""
header = self.get_header()
header.frame_id = 'ego_vehicle/lidar/{}'.format(sensor_id)
lidar_data = numpy.frombuffer(
data, dtype=numpy.float32)
lidar_data = numpy.reshape(
lidar_data, (int(lidar_data.shape[0] / 3), 3))
# we take the oposite of y axis
# (as lidar point are express in left handed coordinate system, and ros need right handed)
# we need a copy here, because the data are read only in carla numpy
# array
lidar_data = -1.0 * lidar_data
# we also need to permute x and y
lidar_data = lidar_data[..., [1, 0, 2]]
msg = create_cloud_xyz32(header, lidar_data)
self.publisher_map[sensor_id].publish(msg)
示例2: publish_pc2
# 需要导入模块: from sensor_msgs import point_cloud2 [as 别名]
# 或者: from sensor_msgs.point_cloud2 import create_cloud_xyz32 [as 别名]
def publish_pc2(pc, obj):
"""Publisher of PointCloud data"""
pub = rospy.Publisher("/points_raw", PointCloud2, queue_size=1000000)
rospy.init_node("pc2_publisher")
header = std_msgs.msg.Header()
header.stamp = rospy.Time.now()
header.frame_id = "velodyne"
points = pc2.create_cloud_xyz32(header, pc[:, :3])
pub2 = rospy.Publisher("/points_raw1", PointCloud2, queue_size=1000000)
header = std_msgs.msg.Header()
header.stamp = rospy.Time.now()
header.frame_id = "velodyne"
points2 = pc2.create_cloud_xyz32(header, obj)
r = rospy.Rate(0.1)
while not rospy.is_shutdown():
pub.publish(points)
pub2.publish(points2)
r.sleep()
示例3: sensor_data_updated
# 需要导入模块: from sensor_msgs import point_cloud2 [as 别名]
# 或者: from sensor_msgs.point_cloud2 import create_cloud_xyz32 [as 别名]
def sensor_data_updated(self, carla_lidar_measurement):
"""
Function to transform the a received lidar measurement into a ROS point cloud message
:param carla_lidar_measurement: carla lidar measurement object
:type carla_lidar_measurement: carla.LidarMeasurement
"""
header = self.get_msg_header()
lidar_data = numpy.frombuffer(
carla_lidar_measurement.raw_data, dtype=numpy.float32)
lidar_data = numpy.reshape(
lidar_data, (int(lidar_data.shape[0] / 3), 3))
# we take the oposite of y axis
# (as lidar point are express in left handed coordinate system, and ros need right handed)
# we need a copy here, because the data are read only in carla numpy
# array
lidar_data = -lidar_data
# we also need to permute x and y
lidar_data = lidar_data[..., [1, 0, 2]]
point_cloud_msg = create_cloud_xyz32(header, lidar_data)
self.publish_message(
self.get_topic_prefix() + "/point_cloud", point_cloud_msg)
示例4: publish_pc2
# 需要导入模块: from sensor_msgs import point_cloud2 [as 别名]
# 或者: from sensor_msgs.point_cloud2 import create_cloud_xyz32 [as 别名]
def publish_pc2(pc, obj, pre_obj=None, pc_1=None):
"""Publisher of PointCloud data"""
pub = rospy.Publisher("/points_raw", PointCloud2, queue_size=10)
rospy.init_node("pc2_publisher")
header = std_msgs.msg.Header()
header.stamp = rospy.Time.now()
header.frame_id = "velodyne"
points = pc2.create_cloud_xyz32(header, pc[:, :3])
pub2 = rospy.Publisher("/points_raw1", PointCloud2, queue_size=10)
header = std_msgs.msg.Header()
header.stamp = rospy.Time.now()
header.frame_id = "velodyne"
points2 = pc2.create_cloud_xyz32(header, obj)
if pre_obj is not None:
pub3 = rospy.Publisher("/points_raw2", PointCloud2, queue_size=10)
header = std_msgs.msg.Header()
header.stamp = rospy.Time.now()
header.frame_id = "velodyne"
points3 = pc2.create_cloud_xyz32(header, pre_obj)
if pc_1 is not None:
pub4 = rospy.Publisher("/points_raw3", PointCloud2, queue_size=10)
header = std_msgs.msg.Header()
header.stamp = rospy.Time.now()
header.frame_id = "velodyne"
points4 = pc2.create_cloud_xyz32(header, pc_1[:, :3])
r = rospy.Rate(0.1)
while not rospy.is_shutdown():
pub.publish(points)
pub2.publish(points2)
if pre_obj is not None:
pub3.publish(points3)
if pc_1 is not None:
pub4.publish(points4)
r.sleep()