add max z feedrate. fix first point x,y and z moves split

This commit is contained in:
Stewart Allen 2020-06-11 22:11:19 -04:00
commit 958c4b8d7f
7 changed files with 157 additions and 126 deletions

View file

@ -347,6 +347,7 @@
p:{ p:{
processName: "default", processName: "default",
camFastFeed: 6000, camFastFeed: 6000,
camFastFeedZ: 300,
roughingTool: 1000, roughingTool: 1000,
roughingSpindle: 1000, roughingSpindle: 1000,
roughingDown: 2, roughingDown: 2,

View file

@ -1292,9 +1292,6 @@
sliceSupportNozzle: UC.newSelect(LANG.sp_nozl_s, {title:LANG.sp_nozl_l, modes:FDM, expert:true}, "extruders"), sliceSupportNozzle: UC.newSelect(LANG.sp_nozl_s, {title:LANG.sp_nozl_l, modes:FDM, expert:true}, "extruders"),
sliceSupportEnable: UC.newBoolean(LANG.enable, onBooleanClick, {modes:FDM}), sliceSupportEnable: UC.newBoolean(LANG.enable, onBooleanClick, {modes:FDM}),
camCommon: UC.newGroup(LANG.cc_menu, null, {modes:CAM}),
camFastFeed: UC.newInput(LANG.cc_rapd_s, {title:LANG.cc_rapd_l, convert:UC.toInt, modes:CAM}),
roughing: UC.newGroup(LANG.cr_menu, null, {modes:CAM}), roughing: UC.newGroup(LANG.cr_menu, null, {modes:CAM}),
roughingTool: UC.newSelect(LANG.cc_tool, {modes:CAM}), roughingTool: UC.newSelect(LANG.cc_tool, {modes:CAM}),
roughingSpindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, modes:CAM}), roughingSpindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, modes:CAM}),
@ -1330,13 +1327,6 @@
drillLift: UC.newInput(LANG.cd_lift_s, {title:LANG.cd_lift_l, convert:UC.toFloat, modes:CAM}), drillLift: UC.newInput(LANG.cd_lift_s, {title:LANG.cd_lift_l, convert:UC.toFloat, modes:CAM}),
drillingOn: UC.newBoolean(LANG.enable, onBooleanClick, {modes:CAM}), drillingOn: UC.newBoolean(LANG.enable, onBooleanClick, {modes:CAM}),
camTabs: UC.newGroup(LANG.ct_menu, null, {modes:CAM}),
camTabsAngle: UC.newInput(LANG.ct_angl_s, {title:LANG.ct_angl_l, convert:UC.toInt, bound:UC.bound(0,360), modes:CAM}),
camTabsCount: UC.newInput(LANG.ct_numb_s, {title:LANG.ct_numb_l, convert:UC.toInt, bound:UC.bound(1,20), modes:CAM}),
camTabsWidth: UC.newInput(LANG.ct_wdth_s, {title:LANG.ct_wdth_l, convert:UC.toFloat, bound:UC.bound(0.1,100), modes:CAM}),
camTabsHeight: UC.newInput(LANG.ct_hght_s, {title:LANG.ct_hght_l, convert:UC.toFloat, bound:UC.bound(0.1,100), modes:CAM}),
camTabsOn: UC.newBoolean(LANG.enable, onBooleanClick, {title:LANG.ct_nabl_l, modes:CAM}),
output: UC.newGroup(LANG.fr_menu, null, {modes:FDM}), output: UC.newGroup(LANG.fr_menu, null, {modes:FDM}),
outputRaftSpacing: UC.newInput(LANG.fr_spac_s, {title:LANG.fr_spac_l, convert:UC.toFloat, bound:UC.bound(0.0,3.0), modes:FDM}), outputRaftSpacing: UC.newInput(LANG.fr_spac_s, {title:LANG.fr_spac_l, convert:UC.toFloat, bound:UC.bound(0.0,3.0), modes:FDM}),
outputRaft: UC.newBoolean(LANG.enable, onBooleanClick, {title:LANG.fr_nabl_l, modes:FDM}), outputRaft: UC.newBoolean(LANG.enable, onBooleanClick, {title:LANG.fr_nabl_l, modes:FDM}),
@ -1357,13 +1347,20 @@
outputFillMult: UC.newInput(LANG.ou_flml_s, {title:LANG.ou_exml_l, convert:UC.toFloat, bound:UC.bound(0.0,2.0), modes:FDM}), outputFillMult: UC.newInput(LANG.ou_flml_s, {title:LANG.ou_exml_l, convert:UC.toFloat, bound:UC.bound(0.0,2.0), modes:FDM}),
outputSparseMult: UC.newInput(LANG.ou_spml_s, {title:LANG.ou_exml_l, convert:UC.toFloat, bound:UC.bound(0.0,2.0), modes:FDM}), outputSparseMult: UC.newInput(LANG.ou_spml_s, {title:LANG.ou_exml_l, convert:UC.toFloat, bound:UC.bound(0.0,2.0), modes:FDM}),
outputFanLayer: UC.newInput(LANG.ou_fanl_s, {title:LANG.ou_fanl_l, convert:UC.toInt, bound:UC.bound(0,100), modes:FDM, expert:true}), outputFanLayer: UC.newInput(LANG.ou_fanl_s, {title:LANG.ou_fanl_l, convert:UC.toInt, bound:UC.bound(0,100), modes:FDM, expert:true}),
camTolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0.001,1.0), modes:CAM}),
camZTopOffset: UC.newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:UC.toFloat, modes:CAM}),
camZBottom: UC.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:UC.toFloat, modes:CAM}),
camZClearance: UC.newInput(LANG.ou_zclr_s, {title:LANG.ou_zclr_l, convert:UC.toFloat, bound:UC.bound(0.01,100), modes:CAM}),
outputClockwise: UC.newBoolean(LANG.ou_conv_s, onBooleanClick, {title:LANG.ou_conv_l, modes:CAM}), outputClockwise: UC.newBoolean(LANG.ou_conv_s, onBooleanClick, {title:LANG.ou_conv_l, modes:CAM}),
camEaseDown: UC.newBoolean(LANG.cr_ease_s, onBooleanClick, {title:LANG.cr_ease_l, modes:CAM}), camEaseDown: UC.newBoolean(LANG.cr_ease_s, onBooleanClick, {title:LANG.cr_ease_l, modes:CAM}),
camDepthFirst: UC.newBoolean(LANG.ou_depf_s, onBooleanClick, {title:LANG.ou_depf_l, modes:CAM}), camDepthFirst: UC.newBoolean(LANG.ou_depf_s, onBooleanClick, {title:LANG.ou_depf_l, modes:CAM}),
camZTopOffset: UC.newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:UC.toFloat, modes:CAM}),
camZBottom: UC.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:UC.toFloat, modes:CAM}),
camZClearance: UC.newInput(LANG.ou_zclr_s, {title:LANG.ou_zclr_l, convert:UC.toFloat, bound:UC.bound(0.01,100), modes:CAM}),
camTabs: UC.newGroup(LANG.ct_menu, null, {modes:CAM}),
camTabsAngle: UC.newInput(LANG.ct_angl_s, {title:LANG.ct_angl_l, convert:UC.toInt, bound:UC.bound(0,360), modes:CAM}),
camTabsCount: UC.newInput(LANG.ct_numb_s, {title:LANG.ct_numb_l, convert:UC.toInt, bound:UC.bound(1,20), modes:CAM}),
camTabsWidth: UC.newInput(LANG.ct_wdth_s, {title:LANG.ct_wdth_l, convert:UC.toFloat, bound:UC.bound(0.1,100), modes:CAM}),
camTabsHeight: UC.newInput(LANG.ct_hght_s, {title:LANG.ct_hght_l, convert:UC.toFloat, bound:UC.bound(0.1,100), modes:CAM}),
camTabsOn: UC.newBoolean(LANG.enable, onBooleanClick, {title:LANG.ct_nabl_l, modes:CAM}),
camStock: UC.newGroup(LANG.cs_menu, null, {modes:CAM}), camStock: UC.newGroup(LANG.cs_menu, null, {modes:CAM}),
camStockX: UC.newInput(LANG.cs_wdth_s, {title:LANG.cs_wdth_l, convert:UC.toFloat, bound:UC.bound(0,9999), modes:CAM}), camStockX: UC.newInput(LANG.cs_wdth_s, {title:LANG.cs_wdth_l, convert:UC.toFloat, bound:UC.bound(0,9999), modes:CAM}),
@ -1371,6 +1368,11 @@
camStockZ: UC.newInput(LANG.cs_hght_s, {title:LANG.cs_hght_l, convert:UC.toFloat, bound:UC.bound(0,9999), modes:CAM}), camStockZ: UC.newInput(LANG.cs_hght_s, {title:LANG.cs_hght_l, convert:UC.toFloat, bound:UC.bound(0,9999), modes:CAM}),
camStockOffset: UC.newBoolean(LANG.cs_offs_s, onBooleanClick, {title:LANG.cs_offs_l, modes:CAM}), camStockOffset: UC.newBoolean(LANG.cs_offs_s, onBooleanClick, {title:LANG.cs_offs_l, modes:CAM}),
camCommon: UC.newGroup(LANG.cc_menu, null, {modes:CAM}),
camFastFeedZ: UC.newInput(LANG.cc_rzpd_s, {title:LANG.cc_rzpd_l, convert:UC.toInt, modes:CAM}),
camFastFeed: UC.newInput(LANG.cc_rapd_s, {title:LANG.cc_rapd_l, convert:UC.toInt, modes:CAM}),
camTolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0.001,1.0), modes:CAM}),
outputOriginBounds: UC.newBoolean(LANG.or_bnds_s, onBooleanClick, {title:LANG.or_bnds_l, modes:LASER}), outputOriginBounds: UC.newBoolean(LANG.or_bnds_s, onBooleanClick, {title:LANG.or_bnds_l, modes:LASER}),
outputOriginCenter: UC.newBoolean(LANG.or_cntr_s, onBooleanClick, {title:LANG.or_cntr_l, modes:CAM_LASER}), outputOriginCenter: UC.newBoolean(LANG.or_cntr_s, onBooleanClick, {title:LANG.or_cntr_l, modes:CAM_LASER}),
camOriginTop: UC.newBoolean(LANG.or_topp_s, onBooleanClick, {title:LANG.or_topp_l, modes:CAM}), camOriginTop: UC.newBoolean(LANG.or_topp_s, onBooleanClick, {title:LANG.or_topp_l, modes:CAM}),
@ -1732,6 +1734,15 @@
function init_two() { function init_two() {
API.event.emit('init.two'); API.event.emit('init.two');
// call driver initializations, if present
Object.values(KIRI.driver).forEach(driver => {
if (driver.init) try {
driver.init(KIRI, API);
} catch (error) {
console.log({driver_init_fail: driver, error})
}
});
let current = settings(), let current = settings(),
control = current.controller; control = current.controller;

View file

@ -41,6 +41,7 @@
UI = {}, UI = {},
UC = KIRI.ui.prefix('kiri').inputAction(updateSettings).hideAction(updateDialogLeft), UC = KIRI.ui.prefix('kiri').inputAction(updateSettings).hideAction(updateDialogLeft),
MODE = MODES.FDM, MODE = MODES.FDM,
DRIVER = undefined,
onEvent = {}, onEvent = {},
currentPrint = null, currentPrint = null,
selectedMeshes = [], selectedMeshes = [],
@ -797,7 +798,7 @@
widget.slice(settings, function(sliced, error) { widget.slice(settings, function(sliced, error) {
let mark = UTIL.time(); let mark = UTIL.time();
// on done // on done
widget.render(renderMode, MODE === MODES.CAM); widget.render();
// clear wireframe // clear wireframe
widget.setWireframe(false, color.wireframe, color.wireframe_opacity); widget.setWireframe(false, color.wireframe, color.wireframe_opacity);
widget.setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity); widget.setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity);
@ -1922,32 +1923,13 @@
DBUG.log("invalid mode: "+mode); DBUG.log("invalid mode: "+mode);
mode = 'FDM'; mode = 'FDM';
} }
$('app-mode-name').innerHTML = mode; // change mode constants
$('set-tools').style.display = mode === 'CAM' ? '' : 'none';
settings.mode = mode; settings.mode = mode;
MODE = MODES[mode]; MODE = MODES[mode];
// restore cached device profile for this mode DRIVER = KIRI.driver[mode];
if (settings.cdev[mode]) { // update mode display
settings.device = clone(settings.cdev[mode]); $('app-mode-name').innerHTML = mode;
API.event.emit('device.set', currentDeviceName()); // highlight relevant device mode button
}
if (MODE === MODES.CAM) {
SPACE.platform.setColor(0xeeeeee);
} else {
SPACE.platform.setColor(0xcccccc);
}
if (MODE === MODES.SLA) {
UI.act.preview.classList.add('hide');
} else {
UI.act.preview.classList.remove('hide');
}
// updates right-hand menu by enabling/disabling fields
setViewMode(VIEWS.ARRANGE);
UC.setMode(MODE);
API.conf.load();
API.conf.save();
clearWidgetCache();
SPACE.update();
["fdm","sla","cam","laser"].forEach(dev => { ["fdm","sla","cam","laser"].forEach(dev => {
let cl = $(`mode-${dev}`).classList; let cl = $(`mode-${dev}`).classList;
if (dev === mode.toLowerCase()) { if (dev === mode.toLowerCase()) {
@ -1956,18 +1938,35 @@
cl.remove("dev-sel"); cl.remove("dev-sel");
} }
}); });
// restore cached device profile for this mode
if (settings.cdev[mode]) {
settings.device = clone(settings.cdev[mode]);
API.event.emit('device.set', currentDeviceName());
}
// really belongs in CAM driver (lots of work / abstraction needed)
if (camStock) { if (camStock) {
camStock.material.visible = settings.mode === 'CAM'; camStock.material.visible = settings.mode === 'CAM';
} }
API.space.restore(null, true); // updates right-hand menu by enabling/disabling fields
if (then) then(); setViewMode(VIEWS.ARRANGE);
UC.setMode(MODE);
// sanitize and persist settings
API.conf.load();
API.conf.save();
// other housekeeping
clearWidgetCache();
triggerSettingsEvent(); triggerSettingsEvent();
platformUpdateSelected(); platformUpdateSelected();
updateFields(); updateFields();
// because device dialog, if showing, needs to be updated
if (modalShowing()) { if (modalShowing()) {
API.show.devices(); API.show.devices();
} }
API.space.restore(null, true);
API.event.emit("mode.set", mode); API.event.emit("mode.set", mode);
if (then) {
then();
}
} }
function currentDeviceName() { function currentDeviceName() {

View file

@ -12,6 +12,7 @@
UTIL = BASE.util, UTIL = BASE.util,
POLY = BASE.polygons, POLY = BASE.polygons,
CAM = KIRI.driver.CAM = { CAM = KIRI.driver.CAM = {
init,
slice, slice,
sliceRender, sliceRender,
printSetup, printSetup,
@ -47,6 +48,14 @@
newPolygon = BASE.newPolygon, newPolygon = BASE.newPolygon,
time = UTIL.time; time = UTIL.time;
function init(kiri, api) {
api.event.on("mode.set", (mode) => {
let isCAM = mode === 'CAM';
$('set-tools').style.display = isCAM ? '' : 'none';
kiri.space.platform.setColor(isCAM ? 0xeeeeee : 0xcccccc);
});
}
function getToolById(settings, id) { function getToolById(settings, id) {
for (let i=0, t=settings.tools; i<t.length; i++) { for (let i=0, t=settings.tools; i<t.length; i++) {
if (t[i].id === id) return t[i]; if (t[i].id === id) return t[i];
@ -1341,12 +1350,12 @@
let rate = feedRate; let rate = feedRate;
if (!lastPoint) { if (!lastPoint) {
// before first point, move cutting head to point above it
layerPush(point.clone().setZ(zmax), 0, 0, tool.number);
// then set that as the lastPoint
lastPoint = newPoint(origin.x, origin.y, point.z); lastPoint = newPoint(origin.x, origin.y, point.z);
} }
// only when we have a previous point to compare to
// TODO obsolete check. lastPoint now synthesized.
if (lastPoint) {
let deltaXY = lastPoint.distTo2D(point), let deltaXY = lastPoint.distTo2D(point),
deltaZ = point.z - lastPoint.z, deltaZ = point.z - lastPoint.z,
absDeltaZ = Math.abs(deltaZ), absDeltaZ = Math.abs(deltaZ),
@ -1406,10 +1415,7 @@
} }
// console.log({deltaZ: deltaZ, deltaXY: deltaXY, threshold:threshold, modifier:modifier, rate:rate, plungeRate:plungeRate}); // console.log({deltaZ: deltaZ, deltaXY: deltaXY, threshold:threshold, modifier:modifier, rate:rate, plungeRate:plungeRate});
} }
} else {
// before first point, move cutting head to point above it
layerPush(point.clone().setZ(zmax), 0, 0, tool.number);
}
// todo synthesize move speed from feed / plunge accordingly // todo synthesize move speed from feed / plunge accordingly
layerPush( layerPush(
point, point,
@ -1779,12 +1785,6 @@
function moveTo(out) { function moveTo(out) {
let newpos = out.point; let newpos = out.point;
// first point out sets the current position (but not Z)
if (points === 0) {
pos.x = newpos.x;
pos.y = newpos.y;
}
// no point == dwell // no point == dwell
// out.speed = time to dwell in ms // out.speed = time to dwell in ms
if (!newpos) { if (!newpos) {
@ -1808,13 +1808,32 @@
filterEmit(cmdToolChange, consts); filterEmit(cmdToolChange, consts);
} }
// first point out sets the current position (but not Z)
// hacky AF way to split initial x,y,z into z then x,y
if (points === 0) {
pos.x = pos.y = pos.z = 0;
points++;
moveTo({
tool: out.tool,
point: { x: 0, y: 0, z: newpos.z },
speed: spro.camFastFeedZ
});
moveTo({
tool: out.tool,
point: { x: newpos.x, y: newpos.y, z: newpos.z },
speed: spro.camFastFeed
});
points--;
return;
}
let speed = out.speed, let speed = out.speed,
feed = speed || spro.camFastFeed,
nl = [speed ? 'G1' : 'G0'], nl = [speed ? 'G1' : 'G0'],
dx = newpos.x - pos.x, dx = newpos.x - pos.x,
dy = newpos.y - pos.y, dy = newpos.y - pos.y,
dz = newpos.z - pos.z, dz = newpos.z - pos.z,
dist = Math.sqrt(dx * dx + dy * dy + dz * dz); dist = Math.sqrt(dx * dx + dy * dy + dz * dz),
feed = Math.min(speed || spro.camFastFeed, dz ? spro.camFastFeedZ : spro.camFastFeed);
// drop dup points (all deltas are 0) // drop dup points (all deltas are 0)
if (!(dx || dy || dz)) { if (!(dx || dy || dz)) {

View file

@ -14,6 +14,7 @@
CONF = BASE.config, CONF = BASE.config,
POLY = BASE.polygons, POLY = BASE.polygons,
SLA = KIRI.driver.SLA = { SLA = KIRI.driver.SLA = {
init,
slice, slice,
sliceRender, sliceRender,
printSetup, printSetup,
@ -35,6 +36,16 @@
if (legacy) console.log("SLA Driver in Legacy Mode"); if (legacy) console.log("SLA Driver in Legacy Mode");
function init(kiri, api) {
api.event.on("mode.set", (mode) => {
if (mode === 'SLA') {
api.ui.act.preview.classList.add('hide');
} else {
api.ui.act.preview.classList.remove('hide');
}
});
}
/** /**
* DRIVER SLICE CONTRACT - runs in worker * DRIVER SLICE CONTRACT - runs in worker
* *

View file

@ -391,18 +391,6 @@
case cca('t'): case cca('t'):
Space.view.top(); Space.view.top();
break; break;
// case cca('f'):
// Space.view.front();
// break;
// case cca('l'):
// Space.view.left();
// break;
// case cca('r'):
// Space.view.right();
// break;
// case cca('b'):
// Space.view.back();
// break;
default: default:
handled = false; handled = false;
break; break;

View file

@ -243,9 +243,11 @@ kiri.lang['en-us'] = {
cc_pock_l: "constrain cuts to\npart boundaries", cc_pock_l: "constrain cuts to\npart boundaries",
// CNC COMMON // CNC COMMON
cc_menu: "common", cc_menu: "limits",
cc_rapd_s: "rapid feed", cc_rapd_s: "xy feed",
cc_rapd_l: "rapid moves feedrate\nin workspace units / minute", cc_rapd_l: "max xy moves feedrate\nin workspace units / minute",
cc_rzpd_s: "z feed",
cc_rzpd_l: "max z moves feedrate\nin workspace units / minute",
// CNC ROUGHING // CNC ROUGHING
cr_menu: "roughing", cr_menu: "roughing",
@ -333,7 +335,7 @@ kiri.lang['en-us'] = {
// OUTPUT CAM // OUTPUT CAM
ou_toll_s: "tolerance", ou_toll_s: "tolerance",
ou_toll_l: "surface precision\nin workspace units", ou_toll_l: "surface precision\nin workspace units\nlower is slower and\nuses more memory",
ou_ztof_s: "z top offset", ou_ztof_s: "z top offset",
ou_ztof_l: "offset from stock surface\nto top face of part\nin workspace units", ou_ztof_l: "offset from stock surface\nto top face of part\nin workspace units",
ou_zbot_s: "z bottom", ou_zbot_s: "z bottom",