Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to check if a target is inside an object?
#1
Hello everybody,

in my Python script I generate lots of targets. Some of them are inside an object so I don't want to generate these ones.
I tried the RDK.Collision(Item1, Item2) function but it seems that it doesn't work with targets. There is no error but it always results a 0 (no collision). The target I used for this test was definitely inside of the object.

The function works fine if I use two objects.

Code:
obj1 = RDK.Item('box1', ITEM_TYPE_OBJECT)
obj2 = RDK.Item('box2', ITEM_TYPE_OBJECT)
testtarget = RDK.Item('testTarget')

checkCol = RDK.Collision(obj1, obj2) #this works fine
checkCol = RDK.Collision(obj1, testtarget) #this never results a collision

How can I use this function with targets or is there any other way to check if a target is inside of an object?

Thanks for your help.
#2
Hi Matthias,

There is a function called IsInside which allows you to check if an object is inside another object (it also works with tools). This function does not work with targets but we'll add support for this with a new version in 1 week maximum.

An alternative option that would work with the current release would be to add a small sphere attached to your target (with the pose set to identity), then, check if that sphere is inside your object. 

Example:

Code:
sphere = RDK.AddItem("C:/RoboDK/Library/sphere_1m.sld")
sphere.setPose(eye(4))
sphere.setParent(target)
sphere.Scale(0.001) # Our default sphere object is 1m in diameter, you can scale it to 1 mm
if sphere.IsInside(object):
   print("Inside!")

Albert
#3
(12-09-2020, 01:50 PM)Albert Wrote: This function does not work with targets but we'll add support for this with a new version in 1 week maximum.

Thank you very much, Albert.
I'm looking foreward to the update. The alternative solution with the spheres is a good idea but the upcoming feature fits perfectly to my needs. So I'm very happy to hear, that this will be released very soon.

Matthias
  




Users browsing this thread:
1 Guest(s)