Merge pull request #2508 from strahlex/machinekit-gcode

added support Machinekit flavour GCode
This commit is contained in:
Alessandro Ranellucci 2015-02-15 17:00:08 +01:00
commit 1180a6d83f
11 changed files with 38 additions and 15 deletions

View File

@ -8,7 +8,7 @@ Slic3r [![Build Status](https://travis-ci.org/alexrj/Slic3r.png?branch=master)](
Slic3r takes 3D models (STL, OBJ, AMF) and converts them into G-code instructions for Slic3r takes 3D models (STL, OBJ, AMF) and converts them into G-code instructions for
3D printers. It's compatible with any modern printer based on the RepRap toolchain, 3D printers. It's compatible with any modern printer based on the RepRap toolchain,
including all those based on the Marlin, Sprinter and Repetier firmware. It also works including all those based on the Marlin, Sprinter and Repetier firmware. It also works
with Mach3 and LinuxCNC controllers. with Mach3, LinuxCNC and Machinekit controllers.
See the [project homepage](http://slic3r.org/) at slic3r.org and the See the [project homepage](http://slic3r.org/) at slic3r.org and the
[manual](http://manual.slic3r.org/) for more information. [manual](http://manual.slic3r.org/) for more information.
@ -30,7 +30,7 @@ Key features are:
* **multi-platform** (Linux/Mac/Win) and packaged as standalone-app with no dependencies required * **multi-platform** (Linux/Mac/Win) and packaged as standalone-app with no dependencies required
* complete **command-line interface** to use it with no GUI * complete **command-line interface** to use it with no GUI
* multi-material **(multiple extruders)** object printing * multi-material **(multiple extruders)** object printing
* multiple G-code flavors supported (RepRap, Makerbot, Mach3 etc.) * multiple G-code flavors supported (RepRap, Makerbot, Mach3, Machinekit etc.)
* ability to plate **multiple objects having distinct print settings** * ability to plate **multiple objects having distinct print settings**
* **multithread** processing * **multithread** processing
* **STL auto-repair** (tolerance for broken models) * **STL auto-repair** (tolerance for broken models)
@ -132,7 +132,7 @@ The author of the Silk icon set is Mark James.
(default: 100,100) (default: 100,100)
--z-offset Additional height in mm to add to vertical coordinates --z-offset Additional height in mm to add to vertical coordinates
(+/-, default: 0) (+/-, default: 0)
--gcode-flavor The type of G-code to generate (reprap/teacup/makerware/sailfish/mach3/no-extrusion, --gcode-flavor The type of G-code to generate (reprap/teacup/makerware/sailfish/mach3/machinekit/no-extrusion,
default: reprap) default: reprap)
--use-relative-e-distances Enable this to get relative E values (default: no) --use-relative-e-distances Enable this to get relative E values (default: no)
--use-firmware-retraction Enable firmware-controlled retraction using G10/G11 (default: no) --use-firmware-retraction Enable firmware-controlled retraction using G10/G11 (default: no)

View File

@ -243,7 +243,7 @@ sub validate {
if !first { $_ eq $self->gcode_flavor } @{$Options->{gcode_flavor}{values}}; if !first { $_ eq $self->gcode_flavor } @{$Options->{gcode_flavor}{values}};
die "--use-firmware-retraction is only supported by Marlin firmware\n" die "--use-firmware-retraction is only supported by Marlin firmware\n"
if $self->use_firmware_retraction && $self->gcode_flavor ne 'reprap'; if $self->use_firmware_retraction && $self->gcode_flavor ne 'reprap' && $self->gcode_flavor ne 'machinekit';
die "--use-firmware-retraction is not compatible with --wipe\n" die "--use-firmware-retraction is not compatible with --wipe\n"
if $self->use_firmware_retraction && first {$_} @{$self->wipe}; if $self->use_firmware_retraction && first {$_} @{$self->wipe};

View File

@ -249,6 +249,7 @@ sub export {
print $fh $gcodegen->writer->set_fan(0); print $fh $gcodegen->writer->set_fan(0);
printf $fh "%s\n", $gcodegen->placeholder_parser->process($self->config->end_gcode); printf $fh "%s\n", $gcodegen->placeholder_parser->process($self->config->end_gcode);
print $fh $gcodegen->writer->update_progress($gcodegen->layer_count, $gcodegen->layer_count, 1); # 100% print $fh $gcodegen->writer->update_progress($gcodegen->layer_count, $gcodegen->layer_count, 1); # 100%
print $fh $gcodegen->writer->end_program();
$self->print->total_used_filament(0); $self->print->total_used_filament(0);
$self->print->total_extruded_volume(0); $self->print->total_extruded_volume(0);

View File

@ -287,7 +287,7 @@ $j
(default: 100,100) (default: 100,100)
--z-offset Additional height in mm to add to vertical coordinates --z-offset Additional height in mm to add to vertical coordinates
(+/-, default: $config->{z_offset}) (+/-, default: $config->{z_offset})
--gcode-flavor The type of G-code to generate (reprap/teacup/makerware/sailfish/mach3/no-extrusion, --gcode-flavor The type of G-code to generate (reprap/teacup/makerware/sailfish/mach3/machinekit/no-extrusion,
default: $config->{gcode_flavor}) default: $config->{gcode_flavor})
--use-relative-e-distances Enable this to get relative E values (default: no) --use-relative-e-distances Enable this to get relative E values (default: no)
--use-firmware-retraction Enable firmware-controlled retraction using G10/G11 (default: no) --use-firmware-retraction Enable firmware-controlled retraction using G10/G11 (default: no)

View File

@ -22,7 +22,7 @@ _arguments -S \
'*--nozzle-diameter[specify nozzle diameter]:nozzle diameter in mm' \ '*--nozzle-diameter[specify nozzle diameter]:nozzle diameter in mm' \
'--print-center[specify print center coordinates]:print center coordinates in mm,mm' \ '--print-center[specify print center coordinates]:print center coordinates in mm,mm' \
'--z-offset[specify Z-axis offset]:Z-axis offset in mm' \ '--z-offset[specify Z-axis offset]:Z-axis offset in mm' \
'--gcode-flavor[specify the type of G-code to generate]:G-code flavor:(reprap teacup makerware sailfish mach3 no-extrusion)' \ '--gcode-flavor[specify the type of G-code to generate]:G-code flavor:(reprap teacup makerware sailfish mach3 machinekit no-extrusion)' \
'(--use-relative-e-distances --no-use-relative-e-distances)'--{no-,}use-relative-e-distances'[disable/enable relative E values]' \ '(--use-relative-e-distances --no-use-relative-e-distances)'--{no-,}use-relative-e-distances'[disable/enable relative E values]' \
'--extrusion-axis[specify letter associated with the extrusion axis]:extrusion axis letter' \ '--extrusion-axis[specify letter associated with the extrusion axis]:extrusion axis letter' \
'(--gcode-arcs --no-gcode-arcs)'--{no-,}gcode-arcs'[disable/enable G2/G3 commands for native arcs]' \ '(--gcode-arcs --no-gcode-arcs)'--{no-,}gcode-arcs'[disable/enable G2/G3 commands for native arcs]' \

View File

@ -83,7 +83,7 @@ GCodeWriter::set_temperature(unsigned int temperature, bool wait, int tool)
std::ostringstream gcode; std::ostringstream gcode;
gcode << code << " "; gcode << code << " ";
if (FLAVOR_IS(gcfMach3)) { if (FLAVOR_IS(gcfMach3) || FLAVOR_IS(gcfMachinekit)) {
gcode << "P"; gcode << "P";
} else { } else {
gcode << "S"; gcode << "S";
@ -118,7 +118,7 @@ GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait)
std::ostringstream gcode; std::ostringstream gcode;
gcode << code << " "; gcode << code << " ";
if (FLAVOR_IS(gcfMach3)) { if (FLAVOR_IS(gcfMach3) || FLAVOR_IS(gcfMachinekit)) {
gcode << "P"; gcode << "P";
} else { } else {
gcode << "S"; gcode << "S";
@ -153,7 +153,7 @@ GCodeWriter::set_fan(unsigned int speed, bool dont_save)
gcode << "M126"; gcode << "M126";
} else { } else {
gcode << "M106 "; gcode << "M106 ";
if (FLAVOR_IS(gcfMach3)) { if (FLAVOR_IS(gcfMach3) || FLAVOR_IS(gcfMachinekit)) {
gcode << "P"; gcode << "P";
} else { } else {
gcode << "S"; gcode << "S";
@ -434,6 +434,9 @@ GCodeWriter::_retract(double length, double restart_extra, const std::string &co
double dE = this->_extruder->retract(length, restart_extra); double dE = this->_extruder->retract(length, restart_extra);
if (dE != 0) { if (dE != 0) {
if (this->config.use_firmware_retraction) { if (this->config.use_firmware_retraction) {
if (FLAVOR_IS(gcfMachinekit))
gcode << "G22 ; retract\n";
else
gcode << "G10 ; retract\n"; gcode << "G10 ; retract\n";
} else { } else {
gcode << "G1 " << this->_extrusion_axis << E_NUM(this->_extruder->E) gcode << "G1 " << this->_extrusion_axis << E_NUM(this->_extruder->E)
@ -460,6 +463,9 @@ GCodeWriter::unretract()
double dE = this->_extruder->unretract(); double dE = this->_extruder->unretract();
if (dE != 0) { if (dE != 0) {
if (this->config.use_firmware_retraction) { if (this->config.use_firmware_retraction) {
if (FLAVOR_IS(gcfMachinekit))
gcode << "G23 ; unretract\n";
else
gcode << "G11 ; unretract\n"; gcode << "G11 ; unretract\n";
gcode << this->reset_e(); gcode << this->reset_e();
} else { } else {
@ -505,6 +511,15 @@ GCodeWriter::get_position() const
return this->_pos; return this->_pos;
} }
std::string
GCodeWriter::end_program()
{
std::ostringstream gcode;
if (FLAVOR_IS(gcfMachinekit))
gcode << "M2 ; end of program\n";
return gcode.str();
}
#ifdef SLIC3RXS #ifdef SLIC3RXS
REGISTER_CLASS(GCodeWriter, "GCode::Writer"); REGISTER_CLASS(GCodeWriter, "GCode::Writer");
#endif #endif

View File

@ -46,6 +46,7 @@ class GCodeWriter {
std::string lift(); std::string lift();
std::string unlift(); std::string unlift();
Pointf3 get_position() const; Pointf3 get_position() const;
std::string end_program();
private: private:
std::string _extrusion_axis; std::string _extrusion_axis;

View File

@ -380,12 +380,14 @@ PrintConfigDef::build_def() {
Options["gcode_flavor"].enum_values.push_back("makerware"); Options["gcode_flavor"].enum_values.push_back("makerware");
Options["gcode_flavor"].enum_values.push_back("sailfish"); Options["gcode_flavor"].enum_values.push_back("sailfish");
Options["gcode_flavor"].enum_values.push_back("mach3"); Options["gcode_flavor"].enum_values.push_back("mach3");
Options["gcode_flavor"].enum_values.push_back("machinekit");
Options["gcode_flavor"].enum_values.push_back("no-extrusion"); Options["gcode_flavor"].enum_values.push_back("no-extrusion");
Options["gcode_flavor"].enum_labels.push_back("RepRap (Marlin/Sprinter/Repetier)"); Options["gcode_flavor"].enum_labels.push_back("RepRap (Marlin/Sprinter/Repetier)");
Options["gcode_flavor"].enum_labels.push_back("Teacup"); Options["gcode_flavor"].enum_labels.push_back("Teacup");
Options["gcode_flavor"].enum_labels.push_back("MakerWare (MakerBot)"); Options["gcode_flavor"].enum_labels.push_back("MakerWare (MakerBot)");
Options["gcode_flavor"].enum_labels.push_back("Sailfish (MakerBot)"); Options["gcode_flavor"].enum_labels.push_back("Sailfish (MakerBot)");
Options["gcode_flavor"].enum_labels.push_back("Mach3/LinuxCNC"); Options["gcode_flavor"].enum_labels.push_back("Mach3/LinuxCNC");
Options["gcode_flavor"].enum_labels.push_back("Machinekit");
Options["gcode_flavor"].enum_labels.push_back("No extrusion"); Options["gcode_flavor"].enum_labels.push_back("No extrusion");
Options["infill_acceleration"].type = coFloat; Options["infill_acceleration"].type = coFloat;

View File

@ -6,7 +6,7 @@
namespace Slic3r { namespace Slic3r {
enum GCodeFlavor { enum GCodeFlavor {
gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfNoExtrusion, gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfMachinekit, gcfNoExtrusion,
}; };
enum InfillPattern { enum InfillPattern {
@ -29,6 +29,7 @@ template<> inline t_config_enum_values ConfigOptionEnum<GCodeFlavor>::get_enum_v
keys_map["makerware"] = gcfMakerWare; keys_map["makerware"] = gcfMakerWare;
keys_map["sailfish"] = gcfSailfish; keys_map["sailfish"] = gcfSailfish;
keys_map["mach3"] = gcfMach3; keys_map["mach3"] = gcfMach3;
keys_map["machinekit"] = gcfMachinekit;
keys_map["no-extrusion"] = gcfNoExtrusion; keys_map["no-extrusion"] = gcfNoExtrusion;
return keys_map; return keys_map;
} }
@ -410,7 +411,7 @@ class GCodeConfig : public virtual StaticPrintConfig
std::string get_extrusion_axis() const std::string get_extrusion_axis() const
{ {
if (this->gcode_flavor.value == gcfMach3) { if ((this->gcode_flavor.value == gcfMach3) || (this->gcode_flavor.value == gcfMachinekit)) {
return "A"; return "A";
} else if (this->gcode_flavor.value == gcfNoExtrusion) { } else if (this->gcode_flavor.value == gcfNoExtrusion) {
return ""; return "";

View File

@ -4,7 +4,7 @@ use strict;
use warnings; use warnings;
use Slic3r::XS; use Slic3r::XS;
use Test::More tests => 108; use Test::More tests => 110;
foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) { foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
$config->set('layer_height', 0.3); $config->set('layer_height', 0.3);
@ -51,6 +51,8 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
is $config->serialize('gcode_flavor'), 'teacup', 'serialize enum'; is $config->serialize('gcode_flavor'), 'teacup', 'serialize enum';
$config->set_deserialize('gcode_flavor', 'mach3'); $config->set_deserialize('gcode_flavor', 'mach3');
is $config->get('gcode_flavor'), 'mach3', 'deserialize enum (gcode_flavor)'; is $config->get('gcode_flavor'), 'mach3', 'deserialize enum (gcode_flavor)';
$config->set_deserialize('gcode_flavor', 'machinekit');
is $config->get('gcode_flavor'), 'machinekit', 'deserialize enum (gcode_flavor)';
$config->set_deserialize('fill_pattern', 'line'); $config->set_deserialize('fill_pattern', 'line');
is $config->get('fill_pattern'), 'line', 'deserialize enum (fill_pattern)'; is $config->get('fill_pattern'), 'line', 'deserialize enum (fill_pattern)';

View File

@ -45,6 +45,7 @@
std::string lift(); std::string lift();
std::string unlift(); std::string unlift();
Clone<Pointf3> get_position() const; Clone<Pointf3> get_position() const;
std::string end_program();
%{ %{
SV* SV*