Last active
January 21, 2021 16:39
-
-
Save Martzi/90d8943a93cb91fd54327f5f1602450b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def point_cloud_msg(points, parent_frame='base_link'): | |
ros_dtype = sensor_msgs.PointField.FLOAT32 # csak ezt eszi meg az rviz | |
dtype = np.float32 | |
itemsize = np.dtype(dtype).itemsize | |
data = points.astype(dtype).tobytes() | |
fields = [sensor_msgs.PointField( | |
name=n, offset=i*itemsize, datatype=ros_dtype, count=1) | |
for i, n in enumerate('rgbxyza')] | |
header = std_msgs.Header(frame_id=parent_frame, stamp=rospy.Time.now()) | |
return sensor_msgs.PointCloud2( | |
header=header, | |
height=points.shape[0], | |
width=points.shape[1], | |
is_dense=False, | |
is_bigendian=False, | |
fields=fields, | |
point_step=points.dtype.itemsize, | |
row_step=(points.dtype.itemsize * points.shape[1]), | |
data=data | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment