diff --git a/client/ui/threeCanvas.js b/client/ui/threeCanvas.js index eed388c1b3cda1562f78d0c23209da3eb18f5fde..dd5868ba5e13bc9049ca8cebdbac462a4d43d6c0 100644 --- a/client/ui/threeCanvas.js +++ b/client/ui/threeCanvas.js @@ -27,7 +27,7 @@ */ // one line - var material = new THREE.LineBasicMaterial({ color: 0x00ffff }) + var material = new THREE.LineBasicMaterial({ color: 0x000000 }) var geometry = new THREE.Geometry() geometry.vertices.push(new THREE.Vector3(0, 0, 0)) geometry.vertices.push(new THREE.Vector3(0.5, 0, 0.5)) diff --git a/modules/robot/forwardTransform.js b/modules/robot/forwardTransform.js index 22280b492c9ccbb8bb0f930271e731dfa784a175..33894b71719bcd3b0378537ce5ef0374564b1ab0 100644 --- a/modules/robot/forwardTransform.js +++ b/modules/robot/forwardTransform.js @@ -88,7 +88,7 @@ function forwardTransform() { } points.jointpt = [state.l1*Math.cos(theta1), state.l1*Math.sin(theta1)] - points.touchpt = [state.l1*Math.cos(theta1)+state.l2*Math.cos(theta2), state.l1*Math.sin(theta1)+state.l2*Math.sin(theta2)] + points.touchpt = [state.l1*Math.cos(theta1)+state.l2*Math.cos(theta2+theta1), state.l1*Math.sin(theta1)+state.l2*Math.sin(theta2+ theta1)] return points } diff --git a/modules/robot/leastSquares.js b/modules/robot/leastSquares.js index 2f2c0224992d5fdadd2aaa0a6ef0d9a96491d69d..11f508856ed664e92529e5f661e92027656a4f4f 100644 --- a/modules/robot/leastSquares.js +++ b/modules/robot/leastSquares.js @@ -7,14 +7,14 @@ const spawn = require("child_process").spawn //const express = require('express') //const app = express() - let Input = JSUnit.Input let Output = JSUnit.Output let State = JSUnit.State function leastSquares() { - var theta1s = 0 - var theta2s = 0 + var thetas = 0 + var theta1s = [] + var theta2s = [] var leastSquares = { description: { @@ -34,8 +34,8 @@ function leastSquares() { // leastSquares.state.G1 = 400 leastSquares.inputs = { - theta1s: Input('any', intakeTheta1s), // can be taken in as a string - theta2s: Input('any', intakeTheta2s) + thetas: Input('any', intakeThetas), // can be taken in as a string + //theta2s: Input('any', intakeTheta2s) } leastSquares.outputs = { @@ -45,27 +45,41 @@ function leastSquares() { // modeChange: Output('string') } - function intakeTheta1s(list){ - theta1s = list + function intakeThetas(list){ + makeTheta1Theta2(list) + console.log(theta1s, theta2s) var lengths = parseleastSquares() } + function makeTheta1Theta2(list){ + var n = list.length + var i; + for (i = 0; i < n; i++) + { + theta1s.push(list[i][0]) + theta2s.push(list[i][1]) + } + } + + /* function intakeTheta2s(list){ theta2s = list var lengths = parseleastSquares() //console.log('theta2 input') } + */ - + /* function thetasToStrings(list){ } + */ function parseleastSquares() { var lengths = { - //l1: 0, - //l2: 0 - test: 'something' + l1: 0, + l2: 0//, + //test: 'something' } theta1sString = theta1s.toString() @@ -79,11 +93,17 @@ function leastSquares() { //console.log(pythonProcess) pythonProcess.stdout.on('data', (data) => { - console.log('got here yay python!!') - console.log(data.toString()) - lengths.test = data.toString() - leastSquares.outputs.l1.emit(lengths.test) - leastSquares.outputs.l2.emit(lengths.test) + //console.log('got here yay python!!') + //console.log(data.toString()) + var temp = JSON.parse(data.toString()) + console.log(temp) + lengths.l1 = temp[0] + lengths.l2 = temp[1] + console.log(typeof(lengths.l1)) + console.log(lengths.l1,lengths.l2) + //lengths.test = data.toString() + leastSquares.outputs.l1.emit(lengths.l1) + leastSquares.outputs.l2.emit(lengths.l2) }) pythonProcess.stderr.on('data', function(data){ diff --git a/modules/util/collector.js b/modules/util/collector.js index d34e8aba2664b7d80628ef2ad97d2daf2880416d..a5cb44a6f780dafea5adcc0f3af7b4430c5be674 100644 --- a/modules/util/collector.js +++ b/modules/util/collector.js @@ -36,6 +36,7 @@ function Collector() { var state = collector.state state.count = 0 + state.dumpOnGo = false var collection = new Array() @@ -65,8 +66,10 @@ function Collector() { function onDumpDesire(){ collector.outputs.pass.emit(collection) - collection = new Array() - state.count = collection.length + if(state.dumpOnGo){ + collection = new Array() + state.count = collection.length + } } // gotta give the program this thing we made diff --git a/programs/temp.json b/programs/temp.json index 8305737d41382e0a639d48b458670b37625e4946..a8a8a11a60b76effbfaff02b2c3d91e66d06c910 100644 --- a/programs/temp.json +++ b/programs/temp.json @@ -81,8 +81,8 @@ "message": "no packet yet", "route": "0,0", "enc_cnt": 16384, - "enc_offset": -6000, - "enc_reverse": false, + "enc_offset": 13500, + "enc_reverse": true, "pc_t": 2048, "pKp": 4.5, "pKi": 0, @@ -148,8 +148,8 @@ "message": "no packet yet", "route": "0,1", "enc_cnt": 16384, - "enc_offset": 550, - "enc_reverse": true, + "enc_offset": 1350, + "enc_reverse": false, "pc_t": 2048, "pKp": 4.5, "pKi": 0, @@ -268,7 +268,7 @@ } }, "state": { - "message": "closed" + "message": "open" }, "ui": { "openButton": { @@ -301,7 +301,7 @@ }, "state": { "prefix": "JTN1:", - "message": "2.9398741799828314" + "message": "6.069578482466511" }, "ui": {} }, @@ -356,11 +356,16 @@ "outputs": { "pass": { "emits": "any", - "calls": [] + "calls": [ + { + "parentId": "leastSquares Parser-16", + "key": "thetas" + } + ] } }, "state": { - "count": 0 + "count": 1 }, "ui": { "onDumpButton": { @@ -403,7 +408,7 @@ } }, "state": { - "addThis": 10, + "addThis": 1, "count": 0 }, "ui": { @@ -490,7 +495,7 @@ } }, "state": { - "addThis": 10, + "addThis": 1, "count": 0 }, "ui": { @@ -568,7 +573,7 @@ }, "state": { "prefix": "JTN2:", - "message": "5.845233792238235" + "message": "0.14802914603096437" }, "ui": {} }, @@ -639,10 +644,7 @@ } }, "inputs": { - "theta1s": { - "accepts": "any" - }, - "theta2s": { + "thetas": { "accepts": "any" } }, diff --git a/py/leastSquares.py b/py/leastSquares.py index 965dd0ec66916c4238cfae3d845440538b21605c..0840679efbf6901dc3e2c81d3514ae77df410f41 100644 --- a/py/leastSquares.py +++ b/py/leastSquares.py @@ -54,13 +54,13 @@ dString = sys.argv[4] theta1s = theta1sString.split(',') theta2s = theta2sString.split(',') -c = int(cString) -d = int(dString) +c = float(cString) +d = float(dString) A = constructmatA(c, theta1s, theta2s) b = constructmatb(d, theta1s) -fullRes = np.linalg.lstsq(A,b) +fullRes = np.linalg.lstsq(A,b, rcond=None) lengths = [fullRes[0][0][0], fullRes[0][1][0]]