Commit d2101409 authored by Jake Read's avatar Jake Read

complete after system integration

parent d6dab2ac
......@@ -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))
......
......@@ -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
}
......
......@@ -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){
......
......@@ -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
......
......@@ -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"
}
},
......
......@@ -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]]
......
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