Page 1 of 1

How to export point cloud data

Posted: 24 Apr 2024, 23:28
by fraahs_
Hello,
I'm computing the workspace of a robot and visualizing it using a PointCloud object. How can I automatize the saving the x, y, z points of the point cloud in a .txt or .xyz text file? Any suggestions?

Re: How to export point cloud data

Posted: 25 Apr 2024, 08:05
by fferri
Read point cloud content with sim.getPointCloudPoints and write to text file:

Code: Select all

local points = sim.getPointCloudPoints(pointCloudHandle)
local f = assert(io.open(filename, 'w'))
for i = 1, #points, 3 do
    f:write(string.format('%f, %f, %f\n', points[i], points[i+1], points[i+2]))
end
f:close()