Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
mods
Commits
84a6adeb
Commit
84a6adeb
authored
6 years ago
by
Jake Read
Browse files
Options
Downloads
Patches
Plain Diff
add planner bugfix
parent
c1aa62e4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/motion/neilParser
+209
-0
209 additions, 0 deletions
modules/motion/neilParser
modules/motion/planner
+6
-1
6 additions, 1 deletion
modules/motion/planner
with
215 additions
and
1 deletion
modules/motion/neilParser
0 → 100644
+
209
−
0
View file @
84a6adeb
//
// gets lines of neil's paths, turns into instructions for mods-machines
//
// Neil Gershenfeld and Jake Read
// (c) Massachusetts Institute of Technology 2018
//
// This work may be reproduced, modified, distributed, performed, and
// displayed for any purpose, but must acknowledge the mods
// project. Copyright is retained and must be preserved. The work is
// provided as is; no warranty is provided, and users accept all
// liability.
/*
turns lines of text into objects for machine controller
*/
//
// closure
//
(function() {
//
// module globals
//
var mod = {}
//
// name
//
var name = 'neil parser'
//
// initialization
//
var init = function() {
mod.g0SpeedIn.value = '100'
mod.g1SpeedIn.value = '400'
mod.codeMode.value = 'G0'
}
//
// inputs
//
var inputs = {
gcode: {
type: 'string',
label: 'gcode',
event: function(evt) {
parseGCode(evt.detail)
}
}
}
//
// outputs
//
var outputs = {
instruction: {
type: 'object',
label: 'instruction',
event: function(obj) {
mods.output(mod, 'instruction', obj)
}
}
}
//
// interface
//
var interface = function(div) {
mod.div = div
//
// inputs
//
// we're going to convert all of these DPIs to MMs because we live in the real world now
mod.g0SpeedIn = make_text_input(div, 'G0 speed, gcode units', 12)
mod.g1SpeedIn = make_text_input(div, 'G1 speed, gcode units', 12)
mod.codeMode = make_text_input(div, 'Modality', 12)
}
function parseGCode(str) {
// get letter-value pairs
var keyvals = getKeyValues(str)
// do modality
// check this for no-g moves?
if (keyvals.G == 0 | keyvals.G == 1) {
mod.codeMode.value = 'G' + keyvals.G.toString()
} else if (keyvals.M != null) {
mod.codeMode.value = 'M' + keyvals.M.toString()
}
// do parse and object
if (mod.codeMode.value == 'G0' | mod.codeMode.value == 'G1') {
var output = {
type: 'move',
position: {},
speed: 0
}
// loop to find position vals, check for feed update
for (key in keyvals) {
if (key.match('[A-CX-Z]')) {
output.position[key] = keyvals[key]
} else if (key.match('[F]')){
if(mod.codeMode.value == 'G0'){
// assert minimum speed
mod.g0SpeedIn.value = Math.max(10, keyvals.F)
} else {
mod.g1SpeedIn.value = Math.max(10, keyvals.F)
}
}
}
if(mod.codeMode.value == 'G0'){
output.speed = parseFloat(mod.g0SpeedIn.value)
} else {
output.speed = parseFloat(mod.g1SpeedIn.value)
}
outputs.instruction.event(output)
} else if (mod.codeMode.value == 'M3'){
var output = {
type: 'spindle',
speed: 0
}
if(keyvals.S != null){
output.speed = keyvals.S
outputs.instruction.event(output)
} else {
console.log('need S parameter on spindle instruction')
}
} else if (mod.codeMode.value == 'M5'){
var output = {
type: 'spindle',
speed: 0
}
output.instruction.event(output)
} else {
console.log('gcode instruction not recognized')
}
}
function getKeyValues(str) {
var kv = {}
for (var i = 0; i < str.length; i++) {
if (str[i].match('[A-Za-z]')) { // regex to match upper case letters
var lastIndex = str.indexOf(' ', i)
if (lastIndex < 0) {
lastIndex = str.length
}
var key = str[i].toUpperCase()
kv[key] = parseFloat(str.slice(i + 1, lastIndex))
}
}
return kv
}
/*
UI helpers
*/
function make_text_input(div, name, size) {
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode(name + ': '))
var input = document.createElement('input')
input.type = 'text'
input.size = size
div.appendChild(input)
return input
}
function make_button_input(div, text) {
div.appendChild(document.createElement('br'))
var button = document.createElement('button')
button.style.padding = mods.ui.padding
button.style.margin = 1
button.appendChild(document.createTextNode(text))
div.appendChild(button)
return button
}
function make_checkbox_input(div, prefix) {
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode(prefix + ': '))
var checkbox = document.createElement('input')
checkbox.type = 'checkbox'
div.appendChild(checkbox)
return checkbox
}
function make_text_display(div, prefix) {
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode(prefix + ': '))
var span = document.createElement('span')
span.innerHTML = ''
div.appendChild(span)
return span
}
//
// return values
//
return ({
mod: mod,
name: name,
init: init,
inputs: inputs,
outputs: outputs,
interface: interface
})
}())
\ No newline at end of file
This diff is collapsed.
Click to expand it.
modules/motion/planner
+
6
−
1
View file @
84a6adeb
...
@@ -50,7 +50,7 @@ motors
...
@@ -50,7 +50,7 @@ motors
mod.junctionDeviationIn.value = '1'
mod.junctionDeviationIn.value = '1'
mod.minSpeedIn.value = '4'
mod.minSpeedIn.value = '4'
mod.axisIdentifiers.value = 'X,Y
,Z
'
mod.axisIdentifiers.value = 'X,Y'
resetNetwork()
resetNetwork()
mod.netWindowIn.value = '12'
mod.netWindowIn.value = '12'
...
@@ -197,6 +197,10 @@ motors
...
@@ -197,6 +197,10 @@ motors
// see windowed state and push more data out if need be
// see windowed state and push more data out if need be
// TODO here
// TODO here
var ok = false
var ok = false
if(axisNetCounters[0] == axisNetCounters[1]){
ok = true
}
/*
for(var i = 0; i < axisNetCounters.length - 2; i ++){
for(var i = 0; i < axisNetCounters.length - 2; i ++){
if(axisNetCounters[i] == axisNetCounters[i + 1]){
if(axisNetCounters[i] == axisNetCounters[i + 1]){
ok = true
ok = true
...
@@ -204,6 +208,7 @@ motors
...
@@ -204,6 +208,7 @@ motors
ok = false
ok = false
}
}
}
}
*/
if(ok){
if(ok){
var opening = packetWindowSize - axisNetCounters[0]
var opening = packetWindowSize - axisNetCounters[0]
if(opening > moveQue.length){
if(opening > moveQue.length){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment