Point Cloud Importer.ttm not working

Report crashes, strange behaviour, or apparent bugs
kilian_ft
Posts: 6
Joined: 08 Oct 2019, 14:05

Point Cloud Importer.ttm not working

Post by kilian_ft »

I´m trying to import my Point Cloud of format .xyz into my Scene. For that I thought the easiest solution would be to take the implemented Point_Cloud_Importer.ttm from the "tools" category. Apperently I always get the following error message:

Code: Select all

Error: [string -unknown location]:?: simCallScriptFunctionEx: error (importClicked_callback)

Lua runtime error: [string "CUSTOMIZATION SCRIPT pointCloudImporter"]:22: One of the function's argument type is not correct. (sim.insertPointsIntoPointCloud)

--> Customization script temporarily disabled.

stack traceback:

[C]: in function 'insertPointsIntoPointCloud'

[string "CUSTOMIZATION SCRIPT pointCloudImporter"]:22: in function <[string "CUSTOMIZATION SCRIPT pointCloudImporter"]:11>

Error: [string -unknown location]:?: simCallScriptFunctionEx: error (importClicked_callback)
I tryed different files, the error is always the same. The V-Rep version used is 3.6.2 rev 0.
How can I fix this or rather what would be the easiest way to import my .xyz point cloud?
Is there maybe an updated point_cloud_importer.ttm that works?

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Point Cloud Importer.ttm not working

Post by coppelia »

Hello,

in the customization script attached to the model, can you replace line 18 with:

Code: Select all

for coord in line:gmatch("([^\9 ]+)") do
Cheers

kilian_ft
Posts: 6
Joined: 08 Oct 2019, 14:05

Re: Point Cloud Importer.ttm not working

Post by kilian_ft »

Hello,

changing line 18 did not change anything for me. The Error is still the same, both in Linux and Windows.
I was using Version 3.6.2. on both systems.

Best,
Kilian Freitag

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Point Cloud Importer.ttm not working

Post by coppelia »

Can you share the first few lines of your xyz file?

Cheers

kilian_ft
Posts: 6
Joined: 08 Oct 2019, 14:05

Re: Point Cloud Importer.ttm not working

Post by kilian_ft »

Here are the first lines. The syntax of the points stays the same for the whole file.

Code: Select all

-2.33270000 49.86260000 -1.92340000 39 35 20
-2.33280000 49.87500000 -1.92300000 37 35 28
-2.33200000 49.88530000 -1.92220000 49 47 36
-2.33220000 49.89820000 -1.92190000 57 58 32
-2.33220000 49.90330000 -1.92170000 78 66 33
-2.29500000 49.85650000 -1.92190000 36 26 25
-2.33000000 49.85770000 -1.92200000 40 34 31
-2.32810000 49.86020000 -1.92080000 40 34 26
-2.32390000 49.85790000 -1.92180000 40 35 29

Best, Kilian Freitag

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Point Cloud Importer.ttm not working

Post by coppelia »

Sorry Kilian,

I actually sent you the wrong line. Simply replace the while function importClicked_callback=function() with:

Code: Select all

importClicked_callback=function()
    local files=sim.fileDialog(sim.filedlg_type_load_multiple,'*.xyz point cloud import','','','*.xyz','xyz')
    if files then
        local pc=sim.createPointCloud(0.02,20,0,size)
        for token in (files..";"):gmatch("([^;]*);") do
            local pts={}
            local cols={}
            for line in io.lines(token) do
                local c=0
                for coord in line:gmatch("([^\9 ]+)") do
                    if c>=3 then
                        cols[#cols+1]=coord
                    else
                        pts[#pts+1]=coord
                    end
                    c=c+1
                end
            end
            local opt=0
            if #pts==#cols then
                opt=2
                col=cols
            end
            sim.insertPointsIntoPointCloud(pc,opt,pts,col)
        end
    end
end
Cheers

kilian_ft
Posts: 6
Joined: 08 Oct 2019, 14:05

Re: Point Cloud Importer.ttm not working

Post by kilian_ft »

Thank you for the time but unfortunately I still get the same error with using the new function.
It still says that one of the arguments of sim.insertPointsIntoPointCloud is not correct.

I don't know how I could solve that.

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Point Cloud Importer.ttm not working

Post by coppelia »

using your data and the modification I mentioned, I can import the data fine.
Maybe you can try to find out what is wrong? e.g. print some of the variables to see where the problem really lies.
Also if you can post the whole file somewhere, it could be helpful.

Cheers

Walty
Posts: 1
Joined: 10 Oct 2019, 10:50

Re: Point Cloud Importer.ttm not working

Post by Walty »

Hi, I am doing the same thing. I also modified the importer script:

Code: Select all

function sysCall_init()
    model=sim.getObjectAssociatedWithScript(sim.handle_self)
    size=1
    col={255,255,255}
    
    if sim.getSimulationState()==sim.simulation_stopped then
        showDlg()
    end
end

importClicked_callback=function()
    local files=sim.fileDialog(sim.filedlg_type_load_multiple,'*.xyz point cloud import','','','*.xyz','xyz')
    if files then
        local pc=sim.createPointCloud(0.02,20,0,size)
        for token in (files..";"):gmatch("([^;]*);") do
            local pts={}
            local cols={}
            for line in io.lines(token) do
                local c=0
                for coord in line:gmatch("([^\9 ]+)") do
                    if c>=3 then
                        cols[#cols+1]=coord
                    else
                        pts[#pts+1]=coord
                    end
                    c=c+1
                end
            end
            local opt=0
            if #pts==#cols then
                opt=2
                col=cols
            end
            sim.insertPointsIntoPointCloud(pc,opt,pts,col)
        end
    end
end

function ptSizeChange_callback(ui,id,newVal)
    local v=tonumber(newVal)
    if v then
        v=math.floor(v)
        if v<1 then v=1 end
        if v>5 then v=5 end
        size=v
    end
    simUI.setEditValue(ui,2,tostring(size),true)
end

function colorChange_callback(ui,id,newVal)
    local i=1
    for token in (newVal..","):gmatch("([^,]*),") do
        local v=tonumber(token)
        if v==nil then v=0 end
        if v>1 then v=1 end
        if v<0 then v=0 end
        col[i]=v*255
        i=i+1
    end
    simUI.setEditValue(ui,3,(col[1]/255)..','..(col[2]/255)..','..(col[3]/255),true)
end

function onCloseClicked()
    sim.removeObject(model) 
end

function createDlg()
    if not ui then
        xml = [[
        <ui title="Point Cloud Importer" closeable="true" on-close="onCloseClicked" resizable="false">
                <group layout="form" flat="true">
                <label text="Point size"/>
                <edit oneditingfinished="ptSizeChange_callback" id="2"/>
                <label text="RGB color"/>
                <edit oneditingfinished="colorChange_callback" id="3"/>
                </group>

                <button text="Import *.xyz file" checked="false"  on-click="importClicked_callback" id="1" />
                <label text="" style="* {margin-left: 380px;}"/>
        </ui>
        ]]
        ui=simUI.create(xml)
        if previousDlgPos then
            simUI.setPosition(ui,previousDlgPos[1],previousDlgPos[2],true)
        end
        simUI.setEditValue(ui,2,tostring(size),true)
        simUI.setEditValue(ui,3,(col[1]/255)..','..(col[2]/255)..','..(col[3]/255),true)
    end
end

function showDlg()
    if ui then
        simUI.show(ui)
    else
        createDlg()
    end
end

function removeDlg()
    if ui then
        local x,y=simUI.getPosition(ui)
        previousDlgPos={x,y}
        simUI.destroy(ui)
        ui=nil
    end
end


function sysCall_afterSimulation()
    showDlg()
end

function sysCall_beforeSimulation()
    removeDlg()
end

function sysCall_cleanup()
    removeDlg()
end
I get the same error

Code: Select all

stack traceback:
	[C]: in function 'insertPointsIntoPointCloud'
	[string "CUSTOMIZATION SCRIPT pointCloudImporter"]:34: in function <[string "CUSTOMIZATION SCRIPT pointCloudImporter"]:11>
Error: [string -unknown location]:?: simCallScriptFunctionEx: error (importClicked_callback)
The scene is an empty one and the object is a .xyz file of a chair found in the web.
Maybe I am not using the correct settings in the window with "Point size" = 1, and "RGB color" = 1,1,1.
Are those one to be modified accordingly to the file?
Some of the code lines:

Code: Select all

0.188121 -0.200840 0.030627
-0.182903 -0.006469 -0.000073
-0.205165 -0.277344 0.030627
-0.205094 -0.277209 0.031238
-0.207391 -0.310896 0.030933
-0.207505 -0.310389 0.030383
-0.207173 -0.325028 0.031879
I also tried the code lines posted by kilian_ft but got the same result.
Thanks in advance for your help

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Point Cloud Importer.ttm not working

Post by coppelia »

I am really not able to reproduce that bug....

Can you add following before sim.insertPointsIntoPointCloud:

Code: Select all

            print("pointCloudHandle",pc)
            print("options",opt)
            print("pts size",#pts)
            print("cols size",#col)
            for i=1,math.min(6,#pts),1 do
                print("pt",pts[i])
            end
            for i=1,math.min(6,#col),1 do
                print("col",col[i])
            end
and send me the output, including the full error message?

Cheers

Post Reply