How to export point cloud data

Typically: "How do I... ", "How can I... " questions
Post Reply
fraahs_
Posts: 1
Joined: 24 Apr 2024, 23:23

How to export point cloud data

Post 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?

fferri
Posts: 1233
Joined: 09 Sep 2013, 19:28

Re: How to export point cloud data

Post 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()

Post Reply