Commit d2101409 authored by Jake Read's avatar Jake Read
Browse files

complete after system integration

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