axi/planner_test.py

29 lines
807 B
Python
Raw Normal View History

2017-01-04 02:19:25 +00:00
from axi import Planner
from math import pi, sin, cos
def circle(cx, cy, r, n):
points = []
for i in range(n + 1):
a = 2 * pi * i / n
x = cx + cos(a) * r
y = cy + sin(a) * r
points.append((x, y))
return points
def main():
points = circle(0, 0, 100, 90)
points = [(-100, -100), (100, -100)] + points + [(100, 100), (-100, 100), (-100, -100)]
for r in range(20, 100, 20):
points = circle(0, 0, r, 90) + points
2017-01-04 20:38:23 +00:00
planner = Planner(
2017-01-06 21:35:27 +00:00
acceleration=50, max_velocity=200, corner_factor=1)
2017-01-05 19:50:33 +00:00
plan = planner.plan(points)
2017-01-04 02:19:25 +00:00
print 'var PIECES = ['
2017-01-05 19:50:33 +00:00
for b in plan.blocks:
2017-01-06 21:35:27 +00:00
record = (b.p1.x, b.p1.y, b.p2.x, b.p2.y, b.a, b.t)
2017-01-04 02:19:25 +00:00
print '[%s],' % ','.join(map(str, record))
print '];'
if __name__ == '__main__':
main()