Entity exists, but checkCollision is returning entity does not exist error

Typically: "How do I... ", "How can I... " questions
Post Reply
Defend
Posts: 3
Joined: 16 Mar 2024, 20:40

Entity exists, but checkCollision is returning entity does not exist error

Post by Defend »

Hey! I'am trying to implement my own RRT algorithm on Coppelia, but I'am having a strange problem.

I'am using addDrawingObject to draw my lines and check them for collision with another lines, nodes and obstacles. Even though it works mostly fine, anytime that the number of lines reaches 70, I'am greeted with a "Entity does not exist" error.

My nodes_list is a list made of the handle returned by sim.createDummy.

Code: Select all

function drawLine(x1, y1, x2, y2)
    local validNode = false
    local pos_vec = {x1, y1, 0, x2, y2, 0}
     line = sim.addDrawingObject(sim.drawing_lines, 1 , 0.0, -1, 1, {0, 0, 255})
    --print("line:", line)
    
    sim.addDrawingObjectItem(line|sim.handleflag_addmultiple, pos_vec)
    table.insert(lista_linhas, line)
    validNode = isLineColliding()
    
    return validNode
end

Code: Select all

function isLineColliding(line)
    local lineColliding = false

    for i=1, #nodes_list do
        print("index", i)
        print(nodes_list[1])
        print(line)
        colliding, _ = sim.checkCollision(line, nodes_list[i])
        if colliding == 1 then
            --print("colliding with another node")
            break
            lineColliding = true
        else
            lineColliding = false
        end
    end
The error always happen on the 100 line: colliding, _ = sim.checkCollision(line, nodes_list, {0, 0, 1})
printing the results of index, nodes_list and line always give me the same thing:

Image

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

Re: Entity exists, but checkCollision is returning entity does not exist error

Post by fferri »

You can check collision only between shapes or collection of shapes, not with drawing objects.

Defend
Posts: 3
Joined: 16 Mar 2024, 20:40

Re: Entity exists, but checkCollision is returning entity does not exist error

Post by Defend »

but it actually works? Everytime that one line have a collision with an object my code discards the node that would be created. Maybe I can upload my .ttt so that you can see it by yourself?

Defend
Posts: 3
Joined: 16 Mar 2024, 20:40

Re: Entity exists, but checkCollision is returning entity does not exist error

Post by Defend »

fferri wrote: 17 Mar 2024, 13:03 You can check collision only between shapes or collection of shapes, not with drawing objects.
Indeed, the collision check does not work. I'am sorry for my ignorance and lack of respect. Thanks for the help fferri!

Post Reply