Permalink
Browse files

Have AnchorProcessor pull its start position from the profile.

* Adds start x, y, & z to all profiles
* ProcessorFactory adds profile to each Processor
* Minor change to AnchorProcessor.get_start_position
  • Loading branch information...
1 parent 465eb90 commit 550f545820c286a14fc3929d1e305a3255347964 @tedbrandston tedbrandston committed Jan 8, 2013
@@ -103,4 +103,10 @@ def calc_euclidean_distance(self, p1, p2):
return distance
def get_start_position(self):
- return "G1 X-112 Y-73 Z150 F3300.0 (move to waiting position)"
+ start_position = (-112, -73, 150)
+ if hasattr(self, 'profile') and None != self.profile:
+ sp = self.profile.values['print_start_sequence']['start_position']
+ start_position = (sp['start_x'], sp['start_y'], sp['start_z'])
+ start_codes = "G1 X%.3f Y%.3f Z%.3f F3300.0 (move to waiting position)"
+ start_codes = start_codes % start_position
+ return start_codes
@@ -14,9 +14,11 @@ def list_processors(self):
pros.remove('errors')
return pros
- def create_processor_from_name(self, name):
+ def create_processor_from_name(self, name, profile = None):
try:
- return getattr(makerbot_driver.GcodeProcessors, name)()
+ processor = getattr(makerbot_driver.GcodeProcessors, name)()
+ processor.profile = profile
+ return processor
except AttributeError:
raise makerbot_driver.GcodeProcessors.ProcessorNotFoundError
@@ -28,8 +30,8 @@ def process_list_with_commas(self, string):
strings.remove(s)
return strings
- def get_processors(self, processors):
+ def get_processors(self, processors, profile = None):
if isinstance(processors, str):
processors = self.process_list_with_commas(processors)
for processor in processors:
- yield self.create_processor_from_name(processor)
+ yield self.create_processor_from_name(processor, profile)
@@ -52,11 +52,14 @@
]
},
"start_position" : {
- "replicator_start_position": [
+ "replicator_start_position" : [
"G92 X152 Y75 Z0 A0 B0",
- "G1 X-112 Y-73 Z150 F3300.0 (move to waiting position)",
+ "G1 X#START_X Y#START_Y Z#START_Z F3300.0 (move to waiting position)",
@skalnik

skalnik Mar 27, 2013

My Replicator 2 is having issues with this line. Do I need to update the firmware for it to handle variables like this?

@tedbrandston

tedbrandston Mar 27, 2013

No, this should be handled by the GCode parser.
Are you running this through MakerWare, or Conveyor? Have you tried contacting MakerBot support?

@skalnik

skalnik Mar 27, 2013

It's running straight through s3g to the Repliactor 2 via command line. It's part of https://github.com/make-me/make-me. https://github.com/make-me/make-me/blob/master/bin/print_gcode.py this script to be exact

@tedbrandston

tedbrandston Mar 27, 2013

Very cool project, though it looks like you might be rewriting some things that already exist in https://github.com/makerbot/conveyor
Anyway, I'm not 100% sure, but I think you have to pass an environment (a dict) with those variables to the GCode parser, and it'll do the variable replacement.

@msamsonoff

msamsonoff Mar 27, 2013

Ted is correct about the environment dict. Please see these sections of conveyor to see how we configure the parser to handle g-code variables:

https://github.com/makerbot/conveyor/blob/master/src/main/python/conveyor/machine/s3g.py#L249
Here we create a g-code 'scaffold' object. This object contains the start g-code, the end g-code, and the environment dict. We use s3g's GcodeAssembler to fetch these from the machine's profile.

https://github.com/makerbot/conveyor/blob/master/src/main/python/conveyor/machine/s3g.py#L699
Here we create the g-code parser and s3g object and then set the parser's environment dict.

@skalnik

skalnik Mar 27, 2013

@tedbrandston A little bit of overlap with conveyor, but we didn't want to pull in the whole complexity of conveyor for just sending gcode to the printer, when something much simpler would fit our needs.

Thanks for the help guys! 😁

@skalnik

skalnik Mar 27, 2013

I went ahead and got make-me working with this, but once I started looking more closely and implemented it, it seems like this should live in s3g. S3g is already replacing some variables like the temperature of the extruder, why not also have it replace this based on the profile you pass to the assembler? Should I file an issue on s3g for this conversation?

@omarc1492

omarc1492 Dec 6, 2016

Trying to make it work by just using the makerware_driver, i know it's been a while but how do I get it to work? Do I have to modify the parser and if so how?

"G130 X20 Y20 A20 B20 (Lower stepper Vrefs while heating)"
- ]
+ ],
+ "start_x" : -112,
+ "start_y" : -73,
+ "start_z" : 150
},
"heat_platform" : {
"no_heat" : []
@@ -68,9 +68,12 @@
"start_position" : {
"replicator_start_position": [
"G92 X163 Y75 Z0 A0 B0",
- "G1 X-112 Y-73 Z150 F3300.0 (move to waiting position)",
+ "G1 X#START_X Y#START_Y #START_Z F3300.0 (move to waiting position)",
"G130 X20 Y20 A20 B20 (Lower stepper Vrefs while heating)"
- ]
+ ],
+ "start_x" : -112,
+ "start_y" : -73,
+ "start_z" : 150
},
"heat_platform" : {
"no_heat" : [],
@@ -67,9 +67,12 @@
"start_position" : {
"replicator_start_position": [
"G92 X152 Y75 Z0 A0 B0",
- "G1 X-112 Y-73 Z150 F3300.0 (move to waiting position)",
+ "G1 X#START_X Y#START_Y Z#START_Z F3300.0 (move to waiting position)",
"G130 X20 Y20 A20 B20 (Lower stepper Vrefs while heating)"
- ]
+ ],
+ "start_x" : -112,
+ "start_y" : -73,
+ "start_z" : 150
},
"heat_platform" : {
"no_heat" : [],
@@ -58,9 +58,12 @@
"start_position" : {
"replicator_start_position": [
"G92 X152 Y75 Z0 A0 B0",
- "G1 X-112 Y-73 Z150 F3300.0 (move to waiting position)",
+ "G1 X#START_X Y#START_Y Z#START_Z F3300.0 (move to waiting position)",
"G130 X20 Y20 A20 B20 (Lower stepper Vrefs while heating)"
- ]
+ ],
+ "start_x" : -112,
+ "start_y" : -73,
+ "start_z" : 150
},
"heat_platform" : {
"no_heat" : [],
@@ -64,8 +64,11 @@
},
"start_position": {
"tom_start_position": [
- "G1 X25 Y-60 Z10 F3300.0 (move to waiting position)"
- ]
+ "G1 X#START_X Y#START_Y Z#START_Z F3300.0 (move to waiting position)"
+ ],
+ "start_x" : 25,
+ "start_y" : -60,
+ "start_z" : 10
},
"heat_platform": {
"no_heat": [],
@@ -55,8 +55,11 @@
},
"start_position": {
"tom_start_position": [
- "G1 X25 Y-60 Z10 F3300.0 (move to waiting position)"
- ]
+ "G1 X#START_X Y#START_Y Z#START_Z F3300.0 (move to waiting position)"
+ ],
+ "start_x" : 25,
+ "start_y" : -60,
+ "start_z" : 10
},
"heat_platform": {
"no_heat": [],
@@ -31,7 +31,7 @@ def test_calc_euclidean_distance(self):
self.ap.calc_euclidean_distance(case[0], case[1]), case[2])
def test_get_start_position(self):
- expected_start_position = 'G1 X-112 Y-73 Z150 F3300.0 (move to waiting position)'
+ expected_start_position = 'G1 X-112.000 Y-73.000 Z150.000 F3300.0 (move to waiting position)'
got_start_position = self.ap.get_start_position()
self.assertEqual(expected_start_position, got_start_position)

0 comments on commit 550f545

Please sign in to comment.