Line Drawing Object not clearing on simulation stop

Report crashes, strange behaviour, or apparent bugs
Post Reply
ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Line Drawing Object not clearing on simulation stop

Post by ahundt » 09 Nov 2017, 04:31

I'm creating drawing objects using the following function, however the drawing object does not clear properly when I stop and then run the simulation again:

Code: Select all


addDrawingObject_function=function(inInts, inFloats, inStrings, inBuffer)
    -- Create a dummy object with specific name and coordinates
    if #inStrings>=1 and #inFloats>=6 and #inInts>=2 then
        local drawingHandle=-1
        local parent_handle=inInts[1]
        local linewidth = 2
        local minTolerance = 0.0
        local maxItemCount = 100
        -- drawingHandle=simAddDrawingObject(sim_drawing_lines+sim_drawing_cyclic, linewidth, minTolerance, parent_handle, maxItemCount, nil, nil, nil, nil)
        -- Get the existing dummy object's handle or create a new one
        if pcall(function()
            -- please note that as of vrep 3.4 there is a bug where sometimes a handle will be found when none exists.
            -- If you encounter it please completely exit and restart V-REP
            -- simAddStatusbarMessage('getting drawing handle ' .. inStrings[1])
            drawingHandle=simGetObjectHandle(inStrings[1])
        end) == false then
            -- simAddStatusbarMessage('adding drawing object')
            drawingHandle=simAddDrawingObject(sim_drawing_lines+sim_drawing_cyclic, linewidth, minTolerance, parent_handle, maxItemCount, nil, nil, nil, nil)
            setObjectName(drawingHandle, inStrings[1])
        end
        -- Set the dummy position
        -- setObjectRelativeToParentWithPoseArray(drawingHandle, parent_handle, inFloats)

        -- please note that as of vrep 3.4 there is a bug where sometimes a handle will be found when none exists.
        -- If you encounter it please completely exit and restart V-REP
        simAddDrawingObjectItem(drawingHandle, inFloats)
        -- local lineCount=inInts[2]
        -- for i=0,lineCount do
        --     local startFloats=(i*6)+7
        --     local line = {unpack(inFloats, startFloats, startFloats+6)}
        --     simAddStatusbarMessage('line: ' .. line)
        --     simAddDrawingObjectItem(drawingHandle, {0,0,0,1,1,1})
        --     simAddDrawingObjectItem(drawingHandle, line)
        -- end

        return {drawingHandle},{},{},'' -- return the handle of the created dummy
    else
        simAddStatusbarMessage('addDrawingObject_function call failed because incorrect parameters were passed.')
    end
end


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

Re: Line Drawing Object not clearing on simulation stop

Post by coppelia » 09 Nov 2017, 17:49

Hello,

in which type of script is the code executed? Only simulation scripts (i.e. scripts that have a state only when simulation is running) will automatically remove the drawing objects they have created.

Cheers

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Line Drawing Object not clearing on simulation stop

Post by ahundt » 12 Nov 2017, 01:02

It was in a child script. I believe that’s a simulation script right?

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Line Drawing Object not clearing on simulation stop

Post by ahundt » 12 Nov 2017, 01:03

It was in a child script. I believe that’s a simulation script right?

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

Re: Line Drawing Object not clearing on simulation stop

Post by coppelia » 13 Nov 2017, 22:05

Yes, but that shouldn't happen.. are you using version 3.4.0? Does this also happen if you create the drawing object in the child script init phase?

Cheers

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Line Drawing Object not clearing on simulation stop

Post by ahundt » 20 Nov 2017, 01:01

Yes, I'm using 3.4 on OS X primarily, but also occasionally Linux.
I'm also running into strange behavior when I try to get the handle of the drawing object from the string name I assign it. I will also try to give the drawing object a string name, but some other object's name will be modified & deleted when I try to delete the drawing object. I haven't been able to figure out a pattern, but perhaps the drawing handles don't have the full capabilities that other objects do?

Code: Select all


            drawingHandle=simAddDrawingObject(sim_drawing_lines+sim_drawing_cyclic, linewidth, minTolerance, parent_handle, maxItemCount, nil, nil, nil, nil)
            setObjectName(drawingHandle, inStrings[1])
Right now I've just been stopping the simulation and resuming when I need to clear out the drawing.

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

Re: Line Drawing Object not clearing on simulation stop

Post by coppelia » 20 Nov 2017, 20:08

A drawing object handle is not the same thing as a scene object handle. So you can't use scene object API functions with drawing object handles..

Cheers

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Line Drawing Object not clearing on simulation stop

Post by ahundt » 09 Dec 2017, 19:27

Can that be changed, perhaps there is an alternative way to remove drawn lines from a running scene?

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

Re: Line Drawing Object not clearing on simulation stop

Post by coppelia » 10 Dec 2017, 22:04

You have always the possibility to remote the drawing object in the destruction phase of the child script.

But I still cannot reproduce your problem...

Cheers

Post Reply