Page 1 of 1

Retrieve scene objects of a defined area

Posted: 21 Feb 2017, 13:43
by makbut

I have a big scene where I have placed a lot of cuboid scene objects and in each simulation step I want to get the position and orientation of all objects inside a specific area of interest which changes constantly as the robot moves.

I don't want to iterate through all objects, get their position and check if the position is inside my desired area. On the other hand I would like to know if there is any way of searching inside a defined area, find if there are any scene objects there, retrieve them and then get their position?

Is there any way to do so?

Re: Retrieve scene objects of a defined area

Posted: 23 Feb 2017, 15:05
by coppelia

why don't you want to iterate over every objects? I am afraid there is no alternative. You can do something like:

Code: Select all

local allObjects=simGetObjectsInTree(sim_handle_scene,sim_handle_all,0)
for i=1,#allObjects,1 do
    local pos=simGetObjectPosition(allObjects[i],-1)
    if pos[1]>xMin and pos[1]<xMax and pos[2]>yMin and pos[2]<yMax and pos[3]>zMin and pos[3]<zMax  then 
        print("inside the area!")

Re: Retrieve scene objects of a defined area

Posted: 27 Feb 2017, 12:53
by makbut
Yes, I am doing more or less the same.
It is just that I have a lot of objects and I was trying to find an optimal way of getting those that are of interest by minimizing the "for loop".
Thank you very much for the answer,