fferri wrote: ↑17 Jul 2021, 17:28
Yes
You have various
item types, e.g. pixel-sized points, pixel-sized lines, triangles, "triangle points", "rectangle points", "disc points", "cube points", "sphere points".
Additionally, you can dynamically create and destroy primitive shapes and meshes.
See also:
Hi, I've tried to use the "rectangle points" item, but it returns me a very big area that doesn't link the two minimum distance points (as the line does), but that's set in a random place in the space between the two object.
That's the code I used:
Code: Select all
function sysCall_init()
local Stand_Enter_Handle=sim.getObjectHandle('Stand_Enter')
Stand_TP_Handle=sim.getObjectHandle('Teach_Pendant_Stand')
Stand_Exit_Handle=sim.getObjectHandle('Stand_Exit')
EnterCollection=sim.createCollection(0)
sim.addItemToCollection(EnterCollection,sim.handle_tree,Stand_Enter_Handle,0)
TPCollection=sim.createCollection(0)
sim.addItemToCollection(TPCollection,sim.handle_tree,Stand_TP_Handle,0)
ExitCollection=sim.createCollection(0)
sim.addItemToCollection(ExitCollection,sim.handle_tree,Stand_Exit_Handle,0)
distanceSegment_true=sim.addDrawingObject(sim.drawing_lines,4,0,-1,1,{0,1,0})
distanceSegment_false=sim.addDrawingObject(sim.drawing_lines,4,0,-1,1,{1,0,0})
SafeExit_true=sim.addDrawingObject(sim.drawing_cubepoints,0.1,0,-1,1,{0,1,0})
SafeExit_false=sim.addDrawingObject(sim.drawing_cubepoints,0.1,0,-1,1,{1,0,0,})
end
function sysCall_sensing()
local result,distData,objectPair=sim.checkDistance(EnterCollection,sim.handle_all)
local result_1,distData_1,objectPair_1=sim.checkDistance(EnterCollection,Stand_TP_Handle)
local result_2,distData_2,objectPair_2=sim.checkDistance(EnterCollection,ExitCollection)
local result_3,distData_3,objectPair_3=sim.checkDistance(TPCollection,ExitCollection)
if distData[7] <0.5 and distData_1[7]>0.5 and distData_2[7]>0.5 and distData_3[7]>0.5 then
sim.addDrawingObjectItem(distanceSegment_false,nil)
sim.addDrawingObjectItem(distanceSegment_false,distData)
sim.addDrawingObjectItem(SafeExit_true,nil)
sim.addDrawingObjectItem(SafeExit_true,distData_1)
sim.addDrawingObjectItem(SafeExit_true,nil)
sim.addDrawingObjectItem(SafeExit_true,distData_2)
sim.addDrawingObjectItem(SafeExit_true,nil)
sim.addDrawingObjectItem(SafeExit_true,distData_3)
local txt='Enter clearance is '..distData[7]
txt=txt..'m, minimum distance object pair is '..getAsString(objectPair)
print(txt)
else
sim.addDrawingObjectItem(distanceSegment_true,nil)
sim.addDrawingObjectItem(distanceSegment_true,distData)
sim.addDrawingObjectItem(SafeExit_false,nil)
sim.addDrawingObjectItem(SafeExit_false,distData_1)
sim.addDrawingObjectItem(SafeExit_false,nil)
sim.addDrawingObjectItem(SafeExit_false,distData_2)
sim.addDrawingObjectItem(SafeExit_false,nil)
sim.addDrawingObjectItem(SafeExit_false,distData_3)
local txt='Enter clearance is '..distData[7]
txt=txt..'m, minimum distance object pair is '..getAsString(objectPair)
print(txt)
end
end
This is what I get using the sim.drawing_quadpoints type:
This is what I get using the cubepoints type:
I would like to get a rectangle with the same dimension of the green line (that's the distance between the objects) and an height h= 1 m that is green/red according to the minimum distance value, but I was not able to figure out what I've to change my code in order to get what I want.
In addition, I set the code for generate three different cubes, but it only returns one (which has, however, the wrong color, because the distance shown into the picture is d >0.5 m, so it should be green, but, as you can see, it's red)
There's any tutorial to understand properly how the command works when a different item type is selected?