Line Drawing Object not clearing on simulation stop

Report crashes, strange behaviour, or apparent bugs
Post Reply
ahundt
Posts: 109
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: 6175
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: 109
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: 109
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: 6175
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

Post Reply