Skip to content
Snippets Groups Projects
Commit dd300b37 authored by Jake Read's avatar Jake Read
Browse files

bugfix on wait blocks

parent 9afc75cc
No related branches found
No related tags found
No related merge requests found
...@@ -292,7 +292,7 @@ ...@@ -292,7 +292,7 @@
trap.accelLength = 0; // never accel trap.accelLength = 0; // never accel
// we really want speed by multiple times, and total distance we know, for vAvg // we really want speed by multiple times, and total distance we know, for vAvg
var tSum = (trap.cruise - trap.exit) / trap.accel + trap.deccelLength / trap.cruise var tSum = (trap.cruise - trap.exit) / trap.accel + trap.deccelLength / trap.cruise
trap.vAvg = trap.delta / tSum trap.vAvg = trap.length / tSum
} else if (trap.cruise == trap.exit) { } else if (trap.cruise == trap.exit) {
// accel, cruise? unless entry also cruise? // accel, cruise? unless entry also cruise?
//console.log('accel then cruise') //console.log('accel then cruise')
...@@ -301,7 +301,7 @@ ...@@ -301,7 +301,7 @@
trap.deccelLength = trap.length + 1; // and never deccel trap.deccelLength = trap.length + 1; // and never deccel
// wait // wait
var tSum = (trap.cruise - trap.entry) / trap.accel + (trap.delta - trap.accellength) / trap.cruise var tSum = (trap.cruise - trap.entry) / trap.accel + (trap.delta - trap.accellength) / trap.cruise
trap.vAvg = trap.dela / tSum trap.vAvg = trap.length / tSum
} else { } else {
// it's either a full trap, or a triangle // it's either a full trap, or a triangle
var accelDistance = (trap.cruise * trap.cruise - trap.entry * trap.entry) / (2 * trap.accel) var accelDistance = (trap.cruise * trap.cruise - trap.entry * trap.entry) / (2 * trap.accel)
...@@ -313,7 +313,7 @@ ...@@ -313,7 +313,7 @@
trap.deccelLength = trap.length - deccelDistance trap.deccelLength = trap.length - deccelDistance
// wait // wait
var tSum = (trap.cruise - trap.entry) / trap.accel + (trap.deccelLength - trap.accellength) / trap.cruise + (trap.cruise - trap.exit) / trap.accel var tSum = (trap.cruise - trap.entry) / trap.accel + (trap.deccelLength - trap.accellength) / trap.cruise + (trap.cruise - trap.exit) / trap.accel
trap.vAvg = trap.delta / tSum trap.vAvg = trap.length / tSum
} else { } else {
//console.log('triangle') //console.log('triangle')
trap.ramptype = 'triangle' trap.ramptype = 'triangle'
...@@ -323,8 +323,8 @@ ...@@ -323,8 +323,8 @@
var midPoint = (vPeak * vPeak - trap.entry * trap.entry) / (2 * trap.accel) var midPoint = (vPeak * vPeak - trap.entry * trap.entry) / (2 * trap.accel)
trap.accelLength = midPoint trap.accelLength = midPoint
trap.deccelLength = midPoint trap.deccelLength = midPoint
var tSum = (trap.vPeak - trap.entry) / trap.accel + (trap.vPeak - trap.exit) / trap.accel var tSum = (vPeak - trap.entry) / trap.accel + (vPeak - trap.exit) / trap.accel
trap.vAvg = trap.delta / tSum trap.vAvg = trap.length / tSum
} }
} }
...@@ -362,10 +362,10 @@ ...@@ -362,10 +362,10 @@
packet.push(132) packet.push(132)
// now we pack these values into C-readable bytes // now we pack these values into C-readable bytes
// int32_t steps, uint32_t entryspeed, accel, accellength, decellength // int32_t steps, uint32_t entryspeed, accel, accellength, decellength
packet = packet.concat(pack32(stepWait.delta)) packet = packet.concat(pack32(trap.delta))
if(isNaN(stepWait.vAvg)){ if(isNaN(stepWait.vAvg)){
console.log('maths failure on vAvg') console.log('maths failure on vAvg', trap.ramptype)
packet = packet.concat(pack32(1000)) packet = packet.concat(pack32(1000))
console.log('wait block', stepWait.steps, 1000) console.log('wait block', stepWait.steps, 1000)
} else { } else {
...@@ -396,7 +396,7 @@ ...@@ -396,7 +396,7 @@
function trapezoidToStepWait(trap) { function trapezoidToStepWait(trap) {
var stepWait = {} var stepWait = {}
// planner units -> steps // planner units -> steps
stepWait.steps = Math.round(trap.delta * mod.convert) stepWait.steps = Math.round(trap.length * mod.convert)
// //
stepWait.vAvg = Math.round(trap.vAvg * mod.convert) stepWait.vAvg = Math.round(trap.vAvg * mod.convert)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment