Hi guys,
Abstract:
I’m doing an emulator of drone flight and I have to use my own algorithm of drone driving but to build the way I need to find obstacles on my way to avoid them. I tried to use collisionSecmet to define a straightway between two points and then check if it collides with any obstacle so that I will be able to process a way around them.
Problem:
When I check the collision between points using CollisionSegment and CollisionBox as an obstacle, I get no events in the queue even though they are crossing.
I tried to use CollisionTube as well but it didn’t help.
bitmasks setting also does not work.
obstacle creation:
cube = loader.loadModel(“box”)
cube.reparentTo(base.render)
cube.setScale(self.area_config[‘obstacles’][‘autogenerated’][‘boxes’][‘scale’])
cube.node().setFinal(1)
# Get the tight bounds of the model
min_point, max_point = cube.getTightBounds()
collision_cube = CollisionBox(min_point, max_point//self.area_config['obstacles']['autogenerated']['boxes']['scale'])
collision_node_path = CollisionNode('collision')
collision_node_path.setFromCollideMask(BitMask32.bit(0))
collision_node_path.setIntoCollideMask(BitMask32.bit(0))
collision_node_path.addSolid(collision_cube)
collision_node_path = cube.attachNewNode(collision_node_path)
cube.setPos(random.randint(self.area_x1, self.area_x2-int(max_point.getX())),
random.randint(self.area_y1, self.area_y2-int(max_point.getY())),
random.randint(self.area_z1, self.area_z2-int(max_point.getZ())))
checking collisions:
def get_collision_between_points(self, start_point, end_point):
segment = CollisionSegment(start_point, end_point)
segment_node = CollisionNode('path_segment')
segment_node.addSolid(segment)
segment_node_path = self.render.attachNewNode(segment_node)
segment_node.setFromCollideMask(BitMask32.bit(0))
segment_node.setIntoCollideMask(BitMask32.bit(0))
base.cTrav.addCollider(segment_node_path, self.segmentQueue)
base.cTrav.traverse(segment_node_path)
if self.segmentQueue.getNumEntries() > 0:
self.logger.debug("Collision detected!")
self.segmentQueue.clearEntries()
return True
else
return False
additionally I getting the next error:
:collide(error): Invalid attempt to detect collision from CollisionBox into CollisionSegment!
This means that a CollisionBox object attempted to test for an
intersection into a CollisionSegment object. This intersection
test has not yet been defined; it is possible the CollisionSegment
object is not intended to be collidable. Consider calling
set_into_collide_mask(0) on the CollisionSegment object, or
set_from_collide_mask(0) on the CollisionBox object.
Could you please help me to resolve the issue or suggest another way to check path for collisions?