diff --git a/hunks/adhoc/saturn.js b/hunks/adhoc/saturn.js index f13733e7e68085b2b5eac61b0f5f63039aa960c0..3125fe350c6ba4b09b40f407aeb2da841b5d42f8 100644 --- a/hunks/adhoc/saturn.js +++ b/hunks/adhoc/saturn.js @@ -48,13 +48,7 @@ export default function Saturn() { let outp = this.output('array', 'posn') - let outx = this.output('number', 'outx') - let outy = this.output('number', 'outy') - let outz = this.output('number', 'outz') - - let allClear = () => { - return (!outx.io() && !outy.io() && !outz.io()) - } + let mdmsegOut = this.output('MDmseg', 'motionSegment') // settings, let deviation = 0.1 // virtual radius to junction about @@ -345,18 +339,24 @@ export default function Saturn() { } } + let writeMDmsegFromRamp = (ramp) => { + return { + p0: ramp.pi, + p1: ramp.pf, + t: ramp.t, + v0: ramp.vi, + a: (ramp.vf - ramp.vi) / ramp.t + } + } + let debugRuntime = false this.loop = () => { // handle output to stepper, if we have any existing blocks to issue: - if (ramps.length > 0 && allClear()) { - //console.log('op ramp', rpo.pf) - outx.put(1) - outy.put(1) - outz.put(1) - // our 'current position, from the end of the - // last ramp we shipped, is rpo.pf + if (ramps.length > 0 && !mdmsegOut.io()) { posUpdated = true + // multi-dimensional mseg, + mdmsegOut.put(writeMDmsegFromRamp(ramps[0])) // this means we are either inside of two old positions, // in which case we update p[0], or at the end of p[0], at p[1] let dtp = vDist(ramps[0].pf, positions[1]) diff --git a/hunks/adhoc/tpath.js b/hunks/adhoc/tpath.js index b0a4628488d71df35a66c4d99c5c2ee23485337a..04f67947f8a17f05b992a973df0488c9a0133944 100644 --- a/hunks/adhoc/tpath.js +++ b/hunks/adhoc/tpath.js @@ -19,8 +19,6 @@ import * as smallpath from '../../test_files/example-path-small.js' import * as sl2path from '../../test_files/example-path-sl2.js' import { vScalar } from '../../libs/smallvectors.js' -let dpi = 72 - export default function TPFCOUT(){ Hunkify(this) @@ -28,6 +26,9 @@ export default function TPFCOUT(){ let go = false let outPosn = this.output('array', 'position') + + let mmPerPixel = this.state('number', 'mm/pix', (1/72)*25.4) + let longSet = this.state('boolean', 'longpath', false) longSet.onChange = (value) => { go = true @@ -48,7 +49,7 @@ export default function TPFCOUT(){ this.loop = () => { if(path.length > 0 && go){ if(!outPosn.io()){ - let op = vScalar(path.shift(), (1/dpi)*25.4) + let op = vScalar(path.shift(), mmPerPixel.value) //console.log(op[1]) outPosn.put(op) } diff --git a/save/contexts/cuttlefish/dbg-25ms-ghost.json b/save/contexts/cuttlefish/dbg-25ms-ghost.json index 377bed8393f9538d62e559d2b34493021dd3ab09..f9ae7fffbc5d67b877a16309f0f4d6c82fba1736 100644 --- a/save/contexts/cuttlefish/dbg-25ms-ghost.json +++ b/save/contexts/cuttlefish/dbg-25ms-ghost.json @@ -63,7 +63,22 @@ ], "states": [ { - "name": "reset", + "name": "mm/pix", + "type": "number", + "value": "1" + }, + { + "name": "longpath", + "type": "boolean", + "value": "false" + }, + { + "name": "shortpath", + "type": "boolean", + "value": "false" + }, + { + "name": "sl2path", "type": "boolean", "value": "false" } diff --git a/save/contexts/cuttlefish/mdmsegtest.json b/save/contexts/cuttlefish/mdmsegtest.json new file mode 100644 index 0000000000000000000000000000000000000000..2cf45e9a8ec5045ea45b2036e624892526183e76 --- /dev/null +++ b/save/contexts/cuttlefish/mdmsegtest.json @@ -0,0 +1,136 @@ +{ + "interpreterName": "cuttlefish", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "nrol", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "view", + "name": "tlview", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "adhoc/saturn", + "name": "adhoc/saturn_2", + "inputs": [ + { + "name": "posn", + "type": "array" + } + ], + "outputs": [ + { + "name": "posn", + "type": "array" + }, + { + "name": "motionSegment", + "type": "MDmseg", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "data/logger", + "name": "data/logger_3", + "inputs": [ + { + "name": "tolog", + "type": "reference" + } + ], + "states": [ + { + "name": "prefix", + "type": "string", + "value": "LOG:" + }, + { + "name": "console", + "type": "boolean", + "value": "true" + } + ] + }, + { + "type": "adhoc/tpath", + "name": "adhoc/tpath_4", + "outputs": [ + { + "name": "position", + "type": "array", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "mm/pix", + "type": "number", + "value": "0.35277777777777775" + }, + { + "name": "longpath", + "type": "boolean", + "value": "false" + }, + { + "name": "shortpath", + "type": "boolean", + "value": "false" + }, + { + "name": "sl2path", + "type": "boolean", + "value": "false" + } + ] + } + ] +} \ No newline at end of file diff --git a/typeset.js b/typeset.js index ca65b80927cf550921413ba46132d56be9881e2c..81608e5ce9f3537c5ea5fa4ad35365bac8d0f615 100644 --- a/typeset.js +++ b/typeset.js @@ -520,6 +520,23 @@ const TSET = [ return arr } } + }, + { + name: 'MDmseg', + copy: { + MDmseg: (mdmseg) => { + return { + p0: mdmseg.p0, + p1: mdmseg.p1, + t: mdmseg.t, + v0: mdmseg.v0, + a: mdmseg.a + } + }, + reference: (mdmseg) => { + return mdmseg + } + } } // etc ] // end TSET