Post Processori per stampanti 3D

Questa sezione mostra come modificare un post processore robot per calcolare il feed dell'estrusore prima di eseguire ogni movimento. In alternativa, questi calcoli possono essere fatti dal controllore robot.

Il primo step è quelli di intercettare le chiamate all'estrusore e leggerne i valori dalla sezione RunCode del post processore:

def RunCode(self, code, is_function_call = False):

        if is_function_call:

            if code.startswith("Extruder("):

                # Intercept the extruder command.

                # if the program call is Extruder(123.56)

                # we extract the number as a string

                # and convert it to a number

                self.NEW_E_LENGTH = float(code[9:-1])

                # Skip the program call generation

                return

            else:

                self.addline(code + "()")

        else:

            # Output program code

            self.addline(code)

Il valore di estrusione è salvato nella variabile NEW_E_LENGTH. Poi, dobbiamo definire una nuova procedura che genera un appropriato comando in accordo alla distanza tra i movimenti, la velocità robot e l'accelerazione robot. Ciò assume che il feed dell'estrusore è gestito da un output analogico dal controllore robot (output analogico numero 5 in questo esempio)

def new_move(self, pose1, pose2):

        if pose1 isNone:

            return

           

        def Calculate_Time(Dist, Vmax, Amax):

            '''Calculate the time to move Dist with Amax acceleration and Vmax speed'''

            tacc = Vmax/Amax;

            Xacc = 0.5*Amax*tacc*tacc;

            if Dist <= 2*Xacc:

                # Vmax is not reached

                tacc = sqrt(Dist/Amax)

                Ttot = tacc*2

            else:

                # Vmax is reached

                Xvmax = Dist - 2*Xacc

                Tvmax = Xvmax/Vmax

                Ttot = 2*tacc + Tvmax

            return Ttot

           

        add_material = self.NEW_E_LENGTH - self.LAST_E_LENGTH

        self.LAST_E_LENGTH = self.NEW_E_LENGTH

       

        if add_material > 0:

            distance_mm = norm(subs3(pose1.Pos(), pose2.Pos()))

            # calculate movement time in seconds

            time_s = Calculate_Time(distance_mm, self.SPEED_MMS, self.ACCEL_MMSS)

            # add material

            self.setDO(5, (add_material/time_s))

        else:

            # DO not add material

            self.setDO(5,0)

Infine, dobbiamo avviare il comando new_move con ogni nuova istruzione di movimento. Possiamo aggiungere questa chiamata all'inzio di ogni comando MoveL:

def MoveL(self, pose, joints, conf_RLF=None):

        """Add a linear movement"""

        self.new_move(self.LAST_POSE, pose) # used for 3D printing