Exemplo n.º 1
0
 def filter_toolpath(self, toolpath):
     last_pos = None
     max_height = None
     new_path = []
     safety_pending = False
     get_safe = lambda pos: tuple(
         (pos[0], pos[1], self.settings["safety_height"]))
     for step in toolpath:
         if step.action == MOVE_SAFETY:
             safety_pending = True
         elif step.action in MOVES_LIST:
             new_pos = tuple(step.position)
             if (max_height is None) or (new_pos[2] > max_height):
                 max_height = new_pos[2]
             if not last_pos:
                 # there was a safety move (or no move at all) before
                 # -> move sideways
                 new_path.append(
                     ToolpathSteps.MoveStraightRapid(get_safe(new_pos)))
             elif safety_pending:
                 safety_pending = False
                 if pnear(last_pos, new_pos, axes=(0, 1)):
                     # same x/y position - skip safety move
                     pass
                 else:
                     # go up, sideways and down
                     new_path.append(
                         ToolpathSteps.MoveStraightRapid(
                             get_safe(last_pos)))
                     new_path.append(
                         ToolpathSteps.MoveStraightRapid(get_safe(new_pos)))
             else:
                 # we are in the middle of usual moves -> keep going
                 pass
             new_path.append(step)
             last_pos = new_pos
         else:
             # unknown move -> keep it
             new_path.append(step)
     # process pending safety moves
     if safety_pending and last_pos:
         new_path.append(ToolpathSteps.MoveStraightRapid(
             get_safe(last_pos)))
     if max_height > self.settings["safety_height"]:
         _log.warn("Toolpath exceeds safety height: %f => %f", max_height,
                   self.settings["safety_height"])
     return new_path
Exemplo n.º 2
0
 def filter_toolpath(self, toolpath):
     last_pos = None
     max_height = None
     new_path = []
     safety_pending = False
     get_safe = lambda pos: tuple((pos[0], pos[1],
             self.settings["safety_height"]))
     for move_type, args in toolpath:
         if move_type == MOVE_SAFETY:
             safety_pending = True
         elif move_type in (MOVE_STRAIGHT, MOVE_STRAIGHT_RAPID):
             new_pos = tuple(args)
             max_height = max(max_height, new_pos[2])
             if not last_pos:
                 # there was a safety move (or no move at all) before
                 # -> move sideways
                 new_path.append((MOVE_STRAIGHT_RAPID, get_safe(new_pos)))
             elif safety_pending:
                 safety_pending = False
                 if pnear(last_pos, new_pos, axes=(0, 1)):
                     # same x/y position - skip safety move
                     pass
                 else:
                     # go up, sideways and down
                     new_path.append((MOVE_STRAIGHT_RAPID,
                             get_safe(last_pos)))
                     new_path.append((MOVE_STRAIGHT_RAPID,
                             get_safe(new_pos)))
             else:
                 # we are in the middle of usual moves -> keep going
                 pass
             new_path.append((move_type, new_pos))
             last_pos = new_pos
         else:
             # unknown move -> keep it
             new_path.append((move_type, args))
     # process pending safety moves
     if safety_pending and last_pos:
         new_path.append((MOVE_STRAIGHT_RAPID, get_safe(last_pos)))
     if max_height > self.settings["safety_height"]:
         _log.warn("Toolpath exceeds safety height: %f => %f" % \
                 (max_height, self.settings["safety_height"]))
     return new_path
Exemplo n.º 3
0
 def filter_toolpath(self, toolpath):
     last_pos = None
     max_height = None
     new_path = []
     safety_pending = False
     get_safe = lambda pos: tuple(
         (pos[0], pos[1], self.settings["safety_height"]))
     for move_type, args in toolpath:
         if move_type == MOVE_SAFETY:
             safety_pending = True
         elif move_type in (MOVE_STRAIGHT, MOVE_STRAIGHT_RAPID):
             new_pos = tuple(args)
             max_height = max(max_height, new_pos[2])
             if not last_pos:
                 # there was a safety move (or no move at all) before
                 # -> move sideways
                 new_path.append((MOVE_STRAIGHT_RAPID, get_safe(new_pos)))
             elif safety_pending:
                 safety_pending = False
                 if pnear(last_pos, new_pos, axes=(0, 1)):
                     # same x/y position - skip safety move
                     pass
                 else:
                     # go up, sideways and down
                     new_path.append(
                         (MOVE_STRAIGHT_RAPID, get_safe(last_pos)))
                     new_path.append(
                         (MOVE_STRAIGHT_RAPID, get_safe(new_pos)))
             else:
                 # we are in the middle of usual moves -> keep going
                 pass
             new_path.append((move_type, new_pos))
             last_pos = new_pos
         else:
             # unknown move -> keep it
             new_path.append((move_type, args))
     # process pending safety moves
     if safety_pending and last_pos:
         new_path.append((MOVE_STRAIGHT_RAPID, get_safe(last_pos)))
     if max_height > self.settings["safety_height"]:
         _log.warn("Toolpath exceeds safety height: %f => %f" % \
                 (max_height, self.settings["safety_height"]))
     return new_path