Newer
Older
// business
const Reps = require('./reps.js')
const Programs = require('./programs.js')
// the program object: real simple, just has a description, and a 'modules'
var program = Programs.new('new program')
/* ok
- robot reads robot joints
- robot takes joint angle samples into array like
[[t1, t2],[t1, t2],...,[t1,t2]]
- robot sends this array to python scripto
- python scripto does l1, l2 guesses
- robot does forward transform with live [t1, t2]
- robot displays forward transform with [t1, t2]
- modules needed
- object collector (i.e. collects inputs into a list, has 'output' and 'reset' input triggers / buttons as well)
- two-up contencator (i.e. takes two inputs, puts them into arrays)
- gate opens, lets a count thru, shuts
*/
var link = Programs.loadModuleFromSource(program, './modules/hardware/atkseriallink.js')
link.startUp()
var mrbotone = Programs.loadModuleFromSource(program, './modules/hardware/atkmrobot.js')
Programs.setUI(mrbotone, 600, 50)
var mrbottwo = Programs.loadModuleFromSource(program, './modules/hardware/atkmrobot.js')
Programs.setUI(mrbottwo, 600, 450)
var button = Programs.loadModuleFromSource(program, './modules/ui/button.js')
var delay = Programs.loadModuleFromSource(program, './modules/util/delay.js')
var gate = Programs.loadModuleFromSource(program, './modules/util/gate.js')
//delay.outputs.out.attach(gate.inputs.thru)
//gate.outputs.out.attach(delay.inputs.thru)
Programs.setUI(button, 90, 50)
Programs.setUI(delay, 90, 250)
Programs.setUI(gate, 90, 400)
button.outputs.whammy.attach(delay.inputs.thru)
delay.outputs.out.attach(gate.inputs.thru)
gate.outputs.out.attach(button.inputs.thru)
var log = Programs.loadModuleFromSource(program, './modules/util/log.js')
Programs.setUI(log, 1050, 520)
mrbotone.outputs.pos.attach(log.inputs.thru)
var canvas = Programs.loadModuleFromSource(program, './modules/ui/threeCanvas.js')
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
var stest = Programs.loadModuleFromSource(program, './modules/ui/stest.js')
var rep = Reps.makeFromModule(stest)
console.log('rep', rep)
/* example program-like-an-api
// load some modules
var multiline = Programs.loadModuleFromSource(program, './modules/ui/multiline.js')
var gcode = Programs.loadModuleFromSource(program, './modules/parsing/gcode.js')
// attaching: always like outputs to inputs
multiline.outputs.lineOut.attach(gcode.inputs.lineIn)
// we can move things around here as well
multiline.description.position = {
left: 50,
top: 50
}
gcode.description.position = {
left: 500,
top: 100
}
// if I have a public function in a module, I can also use that
multiline.load('./files/dogbone.gcode')
*/
// UI
const View = require('./views.js')
View.startHttp()
View.startWs()
Programs.assignSocket(View.uiSocket)
View.assignProgram(program)