Pathfinding Problem Definition




Pay Notebook Creator: Roy Hyunjin Han0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0
In [ ]:
# CrossCompute
obstacle_table_path = 'obstacles.csv'
source_xy = 0, 0
target_xy = 9, 9
target_folder = '/tmp'
In [ ]:
from pandas import read_csv
from shapely import wkt
from shapely.geometry import MultiPolygon
obstacle_table = read_csv(obstacle_table_path)
obstacle_polygons = [wkt.loads(x) for x in obstacle_table['WKT']]
MultiPolygon(obstacle_polygons)
In [ ]:
# !!! Put a pathfinding algorithm here
In [ ]:
from shapely.geometry import LineString
line = LineString([
    (0, 0),
    (5, 0),
    (5, 5),
    (3, 5),
    (3, 9),
    (9, 9),
])
line
In [ ]:
from shapely.geometry import GeometryCollection, Point
GeometryCollection(obstacle_polygons + [
    Point(source_xy),
    Point(target_xy),
    line,
])
In [ ]:
from pandas import DataFrame
waypoint_table = DataFrame(list(line.coords), columns=['x', 'y'])
waypoint_table
In [ ]:
from os.path import join
waypoint_table_path = join(target_folder, 'waypoints.csv')
waypoint_table.to_csv(waypoint_table_path, index=False)