Commit 063a1519 authored by Jayant Khatkar's avatar Jayant Khatkar

prepare running of planners in bulk (#64)

parent dab2f41f
import sys
import subprocess as sp
import os
from math import pi
import yaml
import decmcts
import greedy
import zoneblocking
import gcode2contour as gc
import utils as tu
from math import pi
default_config = '../config/Slic3rConfig.ini'
......@@ -40,40 +44,51 @@ def slice_stls(filenames, out_address, config=default_config, overwrite=False):
return gcodes
def batch_decmcts(gcode_files, n_layers, mcts_nodes_per_layer):
def batch_run(
gcode_files,
output_notes_file,
output_stats_file,
layers,
mcts_nodes_per_layer):
"""
runs decmcts on multiple gcode files
runs various planning algos on multiple gcode files
"""
notes = open(output_notes_file, 'a')
stats = open(output_stats_file, 'w')
# create one env for all runs
home = [0, -pi/2, pi/4, -pi/4, -pi/2, -pi/4]
env_desc2 = tu.read_env('calibrations/r1_tforms.yaml',
'calibrations/r2_tforms.yaml')
env = tu.SimEnv(env_desc=env_desc2, gui=False, home=home)
decmcts_stats = {}
stats = {}
for f in gcode_files:
model = f.split('/')[-1].split('.')[0]
tracker = tu.get_tracker(model)
print("\n####################################")
print("Runnning for model {}".format(model))
print("####################################")
notes.write("\n####################################")
notes.write("Runnning for model {}".format(model))
notes.write("----")
notes.write("Running Dec-MCTS planner")
try:
cs, plan = decmcts.decmcts(tracker,
env,
n_layers=n_layers,
mcts_nodes=mcts_nodes_per_layer
)
#plan.visualise()
notes.write("plan successfully created, saving stats")
decmcts_stats[model] = {'total_time': plan.len(),
stats[model] = {'total_time': plan.len(),
'print_time': plan.extrusion_time()}
print(decmcts_stats[model])
stats.write(yaml.dump(stats))
except:
print("FAILED TO COMPLETE ON MODEL {}".format(model))
notes.write("FAILED TO COMPLETE ON MODEL {}".format(model))
notes.close()
stats.close()
return
if __name__ == '__main__':
......@@ -85,4 +100,4 @@ if __name__ == '__main__':
# slice
gcode_files = slice_stls(filenames, out)
batch_decmcts(gcode_files, 2, 500)
batch_run(gcode_files, 2, 500)
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