Commit ae9aa016 authored by Jayant Khatkar's avatar Jayant Khatkar

updated greedy interface (#68)

parent 732a6957
......@@ -10,7 +10,7 @@ import pickle
home = [0, -pi/2, pi/4, -pi/4, -pi/2, -pi/4]
def greedy(
def greedy_layer(
contours,
contour_tracker,
env,
......@@ -43,7 +43,7 @@ def greedy(
# while contours left to do
while n_contours>0:
# choose robot with the shortest plan
arm = np.argmin([plan.cumul_time[arm][-1] for arm in range(plan.n)])
j_last = plan.trajs[arm][-1].positions[-1]
......@@ -154,6 +154,33 @@ def greedy(
return plan
def greedy(sim_env, tracker, nth_layer=1, layers=None):
"""
plan whole print with greedy using greedy_layer
"""
if layers is None:
n_layers = len(tracker.layers)
layers = list(range(0, n_layers, nth_layer))
plan = None
fin_home = False
for i in layers:
# take arms home if final layer
if i == layers[-1]:
fin_home = True
plan = greedy_layer(
tracker.layers[i],
tracker,
sim_env,
plan=plan,
finish_home=fin_home)
return plan
if __name__ == "__main__":
# Read gcode file
......@@ -172,5 +199,4 @@ if __name__ == "__main__":
# Greedily plan first n contours
sim_env = tu.SimEnv(env_desc=env_desc2, gui=True, home=home)
plan = greedy(tracker.layers[1], tracker, sim_env, finish_home=False)
plan = greedy(tracker.layers[5], tracker, sim_env, plan=plan)
greedy(sim_env, tracker, layers=[1,5])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment