Collision Detection¶
This module contains collision predicates and collision-space builders used by solvers and validators. It is one of the core geometric components in DiscoPygal.
Typical usage¶
from discopygal.geometry_utils.collision_detection import ObjectCollisionDetection
detector = ObjectCollisionDetection(obstacles, robot)
is_free = detector.is_point_valid(point)
See also¶
- class discopygal.geometry_utils.collision_detection.ArrTraits(aos2: object, Arrangement_2: type, Curve_2: type, X_monotone_curve_2: type, TPoint: type, Face: type, point_location: type, overlay_traits: type)¶
The arrangement types of a single traits flavour. Segment traits are cheaper and are used whenever the scene consists of straight edges only; circle-segment traits are needed as soon as a circular arc appears (an expanded disc, or the boundary of an approximated offset). The two cannot be mixed inside one arrangement, nor overlaid with each other, so a single flavour is chosen per arrangement.
- Arrangement_2: type¶
Alias for field number 1
- Curve_2: type¶
Alias for field number 2
- Face: type¶
Alias for field number 5
- TPoint: type¶
Alias for field number 4
- X_monotone_curve_2: type¶
Alias for field number 3
- aos2: object¶
Alias for field number 0
- overlay_traits: type¶
Alias for field number 7
- point_location: type¶
Alias for field number 6
- class discopygal.geometry_utils.collision_detection.ObjectCollisionDetection(obstaclces, robot, offset=0.05)¶
A class object that handles collision detection of a single object with obstacles. The collision detector builds a CGAL arrangement representing the scene and allows to (quickly) query the arrangement for collisions.
- Parameters:
- build_cspace()¶
Build the Cspace arrangement
- clean_redundant_halfedges(arr)¶
Given an arrangement, clear any halfedge that its both incident faces are nonfree.
- Parameters:
arr (
Arrangement_2) – arrangement to clean
- expanded_obstacle_arrangement(obstacle)¶
Given a robot shape and the current obstacle, generate an arrangement that contains the (single) expanded obstacle
- Parameters:
obstacle (
Obstacle) – obstacle to expand- Returns:
arrangement with expanded obstacle
- Return type:
- is_edge_valid(edge) bool¶
Check if a edge (start point with angle to end point with angle) is valid (i.e. not colliding with anything).
- Parameters:
edge (
Segment_2) – edge to check- Returns:
False if edge intersects with the interior of an obstacle
- Return type:
bool
- is_edge_valid_rod(edge, clockwise) bool¶
Check if a edge is valid (i.e. not colliding with anything).
- Parameters:
- Returns:
False if edge intersects with the interior of an obstacle
- Return type:
bool
- is_point_valid(point) bool¶
Check if a point is valid (i.e. not colliding with anything).
- Parameters:
point (
Point_2) – point to check- Returns:
False if point lies in the interior of an obstacle
- Return type:
bool
- is_point_valid_rod(point) bool¶
Check if (rod) point and rotation are valid (i.e., not colliding with anything).
- Parameters:
point – point to check: (point, angle)
- Returns:
False if point lies in the interior of an obstacle
- Return type:
bool
- discopygal.geometry_utils.collision_detection.collide_disc_with_disc(center1, r1, center2, r2)¶
Collide (center ,r) disc with (center ,r) disc
- discopygal.geometry_utils.collision_detection.collide_disc_with_polygon(center, r, polygon)¶
Collide (center ,r) disc with CGAL polygon
- discopygal.geometry_utils.collision_detection.collide_disc_with_rod(center, r, x, y, a, length) bool¶
Collide (center, r) disc with (x, y, a, length) rod
- discopygal.geometry_utils.collision_detection.collide_two_robots(robot1, edge1, robot2, edge2)¶
Get two robots and an edge of their movement, and check if at any point during their movement they intersect
- discopygal.geometry_utils.collision_detection.scene_traits(robot, obstacles) ArrTraits¶
Pick the arrangement traits needed to expand the given obstacles by the given robot.
A disc robot is offset by an approximated offset (arcs) against any obstacle, and a disc obstacle expands into arcs against any robot. Anything else stays polygonal.