Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modifying ABB Post for 3D Printing
#1
Hello,

I am working on a 3D printing project using ABB Robot. I have gone through the 3D printing documentation about how the post processor code can be modified to account for extrusion values. The documentation proposes analog output for extruder motor speed control. However, I am using Digital I/O of the IRC5 DeviceNet with some synchronization signals to achieve the material extrusion. I have already hooked up the necessary hardware and I know how to configure the I/O with ABB software. 

I want to modify the post processor code (ABB_RAPID_IRC5.py) to include a specific set of commands around MoveL command ONLY when Extruder() function is called. So far, I have made the following changes: 

Code:
def MoveL(self, pose, joints, conf_RLF=None):
       """Add a linear movement"""        
       target = ''
       if pose is None:
           target = 'CalcRobT([%s,%s],%s,\WObj:=%s)' % (angles_2_str(joints), extaxes_2_str(joints), self.TOOLDATA, self.WOBJDATA)
       else:
           # Filter small movements
           #if self.LAST_POSE is not None and pose is not None:
           #    # Skip adding a new movement if the new position is the same as the last one
           #    if distance(pose.Pos(), self.LAST_POSE.Pos()) < 0.001 and pose_angle_between(pose, self.LAST_POSE) < 0.01:
           #        return                    
           
           # Handle 3D printing Extruder integration
           # self.new_move(pose)   (disabled on purpose)   
       
           if conf_RLF is None:
               conf_RLF = [0,0,0]
           cf1 = 0
           cf4 = 0
           cf6 = 0            
           if joints is not None and len(joints) >= 6:
               cf1 = math.floor(joints[0]/90.0)
               cf4 = math.floor(joints[3]/90.0)
               cf6 = math.floor(joints[5]/90.0)
           [REAR, LOWERARM, FLIP] = conf_RLF
           cfx = 4*REAR + 2*LOWERARM + FLIP
           target = '[%s,[%i,%i,%i,%i],%s]' % (pose_2_str(pose), cf1, cf4, cf6,cfx, extaxes_2_str(joints))

       if self.ARC_ON:
           # ArcL p100, v100, seam1, weld5 \Weave:=weave1, z10, gun1;
           self.addline('ArcL %s,%s,%s,%s,\Weave:=%s,%s,%s,\WObj:=%s;' % (target, self.SPEEDDATA, self.ARC_SEAMDATA, self.ARC_WELDDATA, self.ARC_WEAVEDATA, self.ZONEDATA, self.TOOLDATA, self.WOBJDATA))
       elif self.CLAD_ON:
           self.addline('CladL %s,%s,%s,%s,%s,\WObj:=%s;' % (target, self.SPEEDDATA, self.CLAD_DATA, self.ZONEDATA, self.TOOLDATA, self.WOBJDATA))
       else:
           self.addline('custom code line 1')
           self.addline('custom code line 2')
           self.addline('MoveL %s,%s,%s,%s,\WObj:=%s;' % (target, self.SPEEDDATA, self.ZONEDATA, self.TOOLDATA, self.WOBJDATA))
           self.addline('custom code line 3')

When I make this modification, all MoveL commands are surrounded by the custom code lines like this: 
Code:
custom code line 1
Custom code line 2
MoveL command
custom code line 3

However, I want these custom code lines to be inserted for specific MoveL commands that follow after Extruder() function call. For example, the following is the RAPID code generated by roboDK:

Code:
Extruder(-0.800);
MoveL [[80.484, 81.324, 5.000],[0.000000, 0.000000, -1.000000, 0.000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],v35,z1,rdkTool,\WObj:=rdkWObj;
MoveL [[80.484, 81.324, 0.600],[0.000000, 0.000000, -1.000000, 0.000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],v180,z1,rdkTool,\WObj:=rdkWObj;
MoveL [[80.484, 81.324, 0.600],[0.000000, 0.000000, -1.000000, 0.000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],v180,z1,rdkTool,\WObj:=rdkWObj;
MoveL [[80.484, 81.324, 0.200],[0.000000, 0.000000, -1.000000, 0.000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],v180,z1,rdkTool,\WObj:=rdkWObj;

I want only the fist MoveL to be surrounded by the custom code lines and NOT the successive MoveL commands. Can anyone help me with modifying the post to achieve this?

PS: I am using an older version of ABB_RAPID_IRC5.py post file (not the new one where analog control is implemented; although I have access to that as well) since I need the exact E values from the slic3r ( not converted to ExtruderSpeed() function) 

Any help will be appreciated!
#2
Hi rakshithb174, 

I'm just throwing an idea here.
Couldn't you just create a flag (maybe a global variable) in your post processor that is initialized at FALSE and 
becomes TRUE when you enter the Extrude section of the post processor.

Then in your MoveL section you could adapt your code depending on the flag state.

Something like that :

Code:
if Flag_Extrude == True:

   self.addline('custom code line 1')
  self.addline('custom code line 2')
  self.addline('MoveL %s,%s,%s,%s,\WObj:=%s;' % (target, self.SPEEDDATA, self.ZONEDATA, self.TOOLDATA, self.WOBJDATA))
  self.addline('custom code line 3')

   Flag_Extrude = False

Else:

   self.addline('MoveL %s,%s,%s,%s,\WObj:=%s;' % (target, self.SPEEDDATA, self.ZONEDATA, self.TOOLDATA, self.WOBJDATA))

That should add the three lines you want just for the first MoveL after an Extrude() command. 

Have a good day. 
Jeremy
#3
Hi Jeremy, 

Thank for the suggestion. 

I defined a global flag "EXTRUDE_ON" under the class RobotPost as follows:
Code:
class RobotPost(object):
   """Robot post object"""
   # ------------------------ Customize your post using the following variabl

   # Extrude Flag
   EXTRUDE_ON = False
After this, I edited the "RunCode" function call to set EXTRUDE_ON flag when Exrtruder() is received
Code:
def RunCode(self, code, is_function_call=False):
       """Adds code or a function call"""
       if is_function_call:
           code = code.replace(' ', '_')
           code_lower = code.lower()

           if code_lower.startswith("extruder("):
               # Set Extruder flag true when Extruder call is intercepted
               self.EXTRUDE_ON = True

           self.addline(code + ';')
       else:
           if code.startswith('END') or code.startswith('ELSEIF'):
               # remove tab after ENDWHILE or ENDIF
               self.TAB = self.TAB[:-len(ONETAB)]

           # replace each tab by 2 spaces
           self.addline(code.replace('\t', '  '))

           if code.startswith('IF ') or code.startswith(
                   'ELSEIF ') or code.startswith('WHILE '):
               # add tab (one tab = two spaces)
               self.TAB = self.TAB + ONETAB
Finally, I edited the MoveL function code to include custom lines only when EXTRUDE_ON flag is True
Code:
def MoveL(self, pose, joints, conf_RLF=None):
        """Add a linear movement"""
        target = ''
        if pose is None:
            target = r'CalcRobT([%s,%s],%s,\WObj:=%s)' % (angles_2_str(
                joints), extaxes_2_str(joints), self.TOOLDATA, self.WOBJDATA)
        else:
            # Filter small movements
            # if self.LAST_POSE is not None and pose is not None:
            #    # Skip adding a new movement if the new position is the same as the last one
            #    if distance(pose.Pos(), self.LAST_POSE.Pos()) < 0.001 and pose_angle_between(pose, self.LAST_POSE) < 0.01:
            #        return

            # Handle 3D printing Extruder integration
            # self.new_move(pose)

            if conf_RLF is None:
                conf_RLF = [0, 0, 0]
            cf1 = 0
            cf4 = 0
            cf6 = 0
            if joints is not None and len(joints) >= 6:
                cf1 = math.floor(joints[0] / 90.0)
                cf4 = math.floor(joints[3] / 90.0)
                cf6 = math.floor(joints[5] / 90.0)
            [REAR, LOWERARM, FLIP] = conf_RLF
            cfx = 4 * REAR + 2 * LOWERARM + FLIP
            target = '[%s,[%i,%i,%i,%i],%s]' % (pose_2_str(
                pose), cf1, cf4, cf6, cfx, extaxes_2_str(joints))

        if self.ARC_ON:
            # ArcL p100, v100, seam1, weld5 \Weave:=weave1, z10, gun1;
            self.addline(
                r'ArcL %s,%s,%s,%s,\Weave:=%s,%s,%s,\WObj:=%s;' %
                (target,
                 self.SPEEDDATA,
                 self.ARC_SEAMDATA,
                 self.ARC_WELDDATA,
                 self.ARC_WEAVEDATA,
                 self.ZONEDATA,
                 self.TOOLDATA,
                 self.WOBJDATA))
        elif self.CLAD_ON:
            self.addline(
                r'CladL %s,%s,%s,%s,%s,\WObj:=%s;' %
                (target,
                 self.SPEEDDATA,
                 self.CLAD_DATA,
                 self.ZONEDATA,
                 self.TOOLDATA,
                 self.WOBJDATA))
        elif self.EXTRUDE_ON:
            # Extruder call Flag is ON. Surround MoveL with custom code
            self.addline('custom code 1')
            self.addline('custom code 2')
            self.addline(
                r'MoveL %s,%s,%s,%s,\WObj:=%s;' %
                (target,
                 self.SPEEDDATA,
                 self.ZONEDATA,
                 self.TOOLDATA,
                 self.WOBJDATA))
            self.addline('custom code 3')
            self.EXTRDUDE_ON = False
        else:
            self.addline(
                r'MoveL %s,%s,%s,%s,\WObj:=%s;' %
                (target,
                 self.SPEEDDATA,
                 self.ZONEDATA,
                 self.TOOLDATA,
                 self.WOBJDATA))
However, when I use this post, ALL MoveL commands are being wrapped with custom code lines 
Following is a snippet of code produced by original post 
Code:
%%%
 VERSION:1
 LANGUAGE:ENGLISH
%%%
MODULE MOD_Tmp1

    PROC Prg_Tmp1()

        ConfJ \On;
        ConfL \Off;
        ! Show R3DP_Extruder_Tool
        MoveL [[80.484,81.324,5.000],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[35.00,500,5000,1000],z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        MoveL [[80.484,81.324,0.600],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[180.00,500,5000,1000],z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        MoveL [[80.484,81.324,0.600],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[180.00,500,5000,1000],z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        MoveL [[80.484,81.324,0.200],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[180.00,500,5000,1000],z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        Extruder(0.800);
        MoveL [[80.484,81.324,0.200],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[35.00,500,5000,1000],z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        MoveL [[80.484,81.324,0.200],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],v20,z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        Extruder(0.072);
This is what I get after modification:
Code:
%%%
 VERSION:1
 LANGUAGE:ENGLISH
%%%
MODULE MOD_Tmp1

    PROC Prg_Tmp1()

        ConfJ \On;
        ConfL \Off;
        ! Show R3DP_Extruder_Tool
        custom code 1
        custom code 2
        MoveL [[80.484,81.324,5.000],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[35.00,500,5000,1000],z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        custom code 3
        custom code 1
        custom code 2
        MoveL [[80.484,81.324,0.600],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[180.00,500,5000,1000],z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        custom code 3
        custom code 1
        custom code 2
        MoveL [[80.484,81.324,0.600],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[180.00,500,5000,1000],z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        custom code 3
        custom code 1
        custom code 2
        MoveL [[80.484,81.324,0.200],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[180.00,500,5000,1000],z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        custom code 3
        Extruder(0.800);
        custom code 1
        custom code 2
        MoveL [[80.484,81.324,0.200],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[35.00,500,5000,1000],z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        custom code 3
        custom code 1
        custom code 2
        MoveL [[80.484,81.324,0.200],[0.00000000,0.00000000,-1.00000000,0.00000000],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],v20,z1,R3DP_Extruder_Tool,\WObj:=BedOrigin;
        custom code 3
        Extruder(0.072);
Am I missing anything here? 
There is a section at the end of the ABB_RAPID_IRC5.py to test the post. I added a simple extruder call to see if it gets picked up correctly:
Code:
ef test_post():
   """Test the post with a basic program"""

   robot = RobotPost(
       r'ABB_RAPID_IRC5',
       r'ABB IRB 6700-155/2.85',
       6,
       axes_type=[
           'R',
           'R',
           'R',
           'R',
           'R',
           'R'])

   robot.ProgStart(r'Prog1')
   robot.RunMessage(
       r'Program generated by RoboDK 3.1.5 for ABB IRB 6700-155/2.85 on 18/05/2017 11:02:41',
       True)
   robot.RunMessage(r'Using nominal kinematics.', True)
   robot.setFrame(Pose([0.000000, 0.000000, 0.000000, 0.000000,
                        0.000000, 0.000000]), -1, r'ABB IRB 6700-155/2.85 Base')
   robot.setTool(Pose([380.000000, 0.000000, 200.000000,
                       0.000000, 90.000000, 0.000000]), 1, r'Tool 1')
   robot.setSpeed(2000.000)
   robot.MoveJ(Pose([2103.102861, 0.000000, 1955.294643, -
                     180.000000, -
                     3.591795, -
                     180.000000]), [0.00000, 3.93969, -
                                    14.73451, 0.00000, 14.38662, -
                                    0.00000], [0.0, 0.0, 0.0])
   robot.MoveJ(Pose([2065.661612, 700.455189, 1358.819971, 180.000000, -
                     3.591795, -
                     180.000000]), [22.50953, 5.58534, 8.15717, 67.51143, -
                                    24.42689, -
                                    64.06258], [0.0, 0.0, 1.0])
   robot.Pause(500.0)
   robot.setSpeed(100.000)
   #robot.RunCode(r'ArcLStart', True)
   robot.RunCode(r'Extruder(0.800)')
When I run just the post file to check if the post processor code is working properly, I get following output:
Code:
ConfJ \On;
               ConfL \Off;
               ! Program generated by RoboDK 3.1.5 for ABB IRB 6700-155/2.85 on 18/05/2017 11:02:41
               ! Using nominal kinematics.
               MoveAbsJ [[0.000000,3.939690,-14.734510,0.000000,14.386620,-0.000000],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],v2000,z1,Tool1,\WObj:=ABBIRB6700155285Base;
               MoveAbsJ [[22.509530,5.585340,8.157170,67.511430,-24.426890,-64.062580],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],v2000,z1,Tool1,\WObj:=ABBIRB6700155285Base;
               WaitTime 0.500;
               Extruder(0.800)
               MoveL [[2065.662,1074.198,1358.820],[0.03023582,-0.26288229,-0.96431880,0.00824257],[0,0,-1,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],v100,z1,Tool1,\WObj:=ABBIRB6700155285Base;
It looks like post is NOT picking up Extruder() calls? but the output file has (in)correctly added custom code lines. I am confused. Can you help with this?
#4
Can you attach your modified version of the post processor?
I'll do some test on my side and that would save me some time.

Jeremy
#5
Hi Jeremy,

I have attached the modified Post file for ABB. Please take a look.

Also, what editor do you usually use to edit python files? I use Notepad++ and sometimes this results in inconsistent spacing and indentations error.


Attached Files
.py   ABB_RAPID_IRC5_Modified.py (Size: 44.01 KB / Downloads: 58)
#6
In usually use PyCharm to edit python files.
The community version is free and the pro version is free if you are a student.

I'll take a look at your file.
Can you also send me the 3d printing file that includes the Extrude calls. That could save me some time.

Jeremy
#7
Do you mean the output .MOD files using the modified post? I have included both output files from the original post and the modified post in the attachment.


Attached Files
.zip   ABB_RAPID_IRC5_Modified.zip (Size: 226.29 KB / Downloads: 41)
#8
Hello @Jeremy,

Did you have a chance to check the modified post processor file? Let me know if you have any questions.

Also, do you have any documentation or source code on how robodk 3d printing project parses through gcode file generated by slic3r to create MoveL commands and configuration data (for ABB robot) within MoveL command?
#9
Hi rakshithb174,

I found your problem.
You made a typo... Look at how you wrote :

Code:
self.EXTRUDE_ON = False

There is one too many "D" in the variable name "EXTRDUDE_ON".
Now it's working pretty fine with the modification I suggested you in my first message. 

Have a good day. 
Jeremy
  




Users browsing this thread:
1 Guest(s)