4. Post Processors

A Post Processor defines how robot programs must be generated for a specific robot controller. A Post Processor is a key component of simulation and offline programming of industrial robots.

More information regarding post processors is available in the following two links:

RoboDK comes with many Post Processors available, providing support for many robot brands (such as ABB, Fanuc, KUKA, Motoman, UR, …). Post Processors are located in the folder: C:/RoboDK/Posts/. Each Post Processor is a .py file. You must place the py Post Processor file in C:/RoboDK/Posts/ to use a Post Processor that has been provided to you. To remove an existing Post Processor you can simply delete the corresponding py file located in C:/RoboDK/Posts/.

For example, for KUKA robots the following Post Processors are available:
  • KUKA_KRC2: Generates SRC program files compatible with KUKA KRC2 controllers.

  • KUKA_KRC4: Generates SRC program files compatible with KUKA KRC4 controllers.

  • KUKA_IIWA: Generates JAVA programs using the KUKA.Sunrise platform, required by KUKA IIWA robots.

Python should be installed and working with RoboDK to properly use Post Processors (How to install).

Follow these steps in RoboDK to link a robot to a specific Post Processor:
  1. Open the robot panel by double clicking a robot.

  2. Select Parameters at the top right.

  3. Select Select Post Processor.

Alternatively, you can right click a program, then select Select Post Processor.

_images/PostProcessorSelect.png
To modify or create a Post Processor:
  1. Select Program-Add/Edit Post Processor.

  2. Select an existing Post Processor or create a new one. A template like the example provided in this section will be provided if you decide to create a new Post Processor.

  3. You can edit a Post Processor using a text editor or a Python editor.

A Python editor allows you to quickly test the Post Processor given a sample program at the end of the module. You can also execute a Post Processor file to see a sample of the output that it will generate (double click the py file, or right click the py file, then select Open).

It is also possible to manually edit a Post Processor without using RoboDK:
  1. Go to the folder C:/RoboDK/Posts/ and open the corresponding py file with a text editor such as Notepad or Python IDLE (right click the py file, then, select Edit with IDLE)

  2. Make any required modifications.

  3. To get a preview of the result: Run the Post Processor by double clicking the py file (or right click, then, select Open, as shown in the following image).

Alternatively, you can run and preview the result sing a Python editor such as Python IDLE.

_images/PostProcessorPreview.png

4.1. Post Processor Methods

This section shows the procedures that every Post Processor should define to properly generate programs from RoboDK simulations. This step is transparent to the end user of RoboDK because the program is automatically generated once a Post Processor has been defined. You do not need to understand what is going on behind the scenes unless you are willing to create or modify a Post Processor.

Once a robot program is ready to be generated RoboDK creates a generic Python file (pre processed) that is linked to a Post Processor. The pre-processed file is executed using the selected Post Processor and the desired program is obtained.

class samplepost.RobotPost(robotpost=None, robotname=None, robot_axes=6, **kwargs)

Robot Post Processor object

MoveC(pose1, joints1, pose2, joints2, conf_RLF_1=None, conf_RLF_2=None)

Defines a circular movement.

Tip: MoveC is triggered by the RoboDK instruction Program->Move Circular Instruction.

Parameters
  • pose1 (robodk.Mat()) – pose target of a point defining an arc (waypoint)

  • pose2 (robodk.Mat()) – pose target of the end of the arc (final point)

  • joints1 (float list) – robot joints of the waypoint

  • joints2 – robot joints of the final point

  • conf_RLF_1 – robot configuration of the waypoint

  • conf_RLF_2 – robot configuration of the final point

MoveJ(pose, joints, conf_RLF=None)

Defines a joint movement.

Tip: MoveJ is triggered by the RoboDK instruction Program->Move Joint Instruction.

Parameters
  • pose (robodk.Mat()) – pose target of the tool with respect to the reference frame. Pose can be None if the target is defined as a joint target.

  • joints (float list) – robot joints as a list

  • conf_RLF (int list) – robot configuration as a list of 3 ints: [REAR, LOWER-ARM, FLIP]. [0,0,0] means [front, upper arm and non-flip] configuration.

MoveL(pose, joints, conf_RLF=None)

Defines a linear movement.

Tip: MoveL is triggered by the RoboDK instruction Program->Move Linear Instruction.

Parameters
  • pose (robodk.Mat()) – pose target of the tool with respect to the reference frame. Pose can be None if the target is defined as a joint target.

  • joints (float list) – robot joints as a list

  • conf_RLF (int list) – robot configuration as a list of 3 ints: [REAR, LOWER-ARM, FLIP]. [0,0,0] means [front, upper arm and non-flip] configuration.

Pause(time_ms)

Defines a pause in a program (including movements). time_ms is negative if the pause must provoke the robot to stop until the user desires to continue the program.

Tip: Pause is triggered by the RoboDK instruction Program->Pause Instruction.

Parameters

time_ms (float) – time of the pause, in milliseconds

ProgFinish(progname)

This method is executed to define the end of a program or procedure. One module may have more than one program. No other instructions will be executed before another samplepost.RobotPost.ProgStart() is executed. Tip: ProgFinish is triggered after all the instructions of the program.

Parameters

progname (str) – name of the program

ProgSave(folder, progname, ask_user=False, show_result=False)

Saves the program. This method is executed after all programs have been processed.

Tip: ProgSave is triggered after all the programs and instructions have been executed.

Parameters
  • folder (str) – Folder hint to save the program

  • progname (str) – Program name as a hint to save the program

  • ask_user (bool, str) – True if the default settings in RoboDK are set to promt the user to select the folder

  • show_result (bool, str) – False if the default settings in RoboDK are set to not show the program once it has been saved. Otherwise, a string is provided with the path of the preferred text editor.

ProgStart(progname)

Start a new program given a name. Multiple programs can be generated at the same times.

Tip: ProgStart is triggered every time a new program must be generated.

Parameters

progname (str) – name of the program

RunCode(code, is_function_call=False)

Adds code or a function call.

Tip: RunCode is triggered by the RoboDK instruction Program->Function call Instruction.

Parameters
  • code (str) – code or procedure to call

  • is_function_call (bool) – True if the provided code is a specific function to call

RunMessage(message, iscomment=False)

Display a message in the robot controller screen (teach pendant)

Tip: RunMessage is triggered by the RoboDK instruction Program->Show Message Instruction.

Parameters
  • message (str) – Message to display on the teach pendant or as a comment on the code

  • iscomment (bool) – True if the message does not have to be displayed on the teach pendant but as a comment on the code

addline(newline)

Add a new program line. This is a private method used only by the other methods.

Parameters

newline (str) – new line to add.

addlog(newline)

Add a message to the log. This is a private method used only by the other methods. The log is displayed when the program is generated to show any issues when the robot program has been generated.

Parameters

newline (str) – new line

setAcceleration(accel_mmss)

Changes the robot acceleration (in mm/s2)

Tip: setAcceleration is triggered by the RoboDK instruction Program->Set Speed Instruction. An acceleration value must be provided.

Parameters

accel_mmss (float) – speed in mm/s^2

setAccelerationJoints(accel_degss)

Changes the robot joint acceleration (in deg/s2)

Tip: setAccelerationJoints is triggered by the RoboDK instruction Program->Set Speed Instruction. A joint acceleration value must be provided.

Parameters

accel_degss (float) – speed in deg/s^2

setDO(io_var, io_value)

Sets a variable io_var (usually a digital output) to a given value. This method can also be used to set other variables.

Tip: setDO is triggered by the RoboDK instruction Program->Set or Wait I/O Instruction.

Parameters
  • io_var (int, str) – variable to set, provided as a str or int

  • io_value (int, float, str) – value of the variable, provided as a str, float or int

setFrame(pose, frame_id=None, frame_name=None)

Defines a new reference frame with respect to the robot base frame. This reference frame is used for following pose targets used by movement instructions.

Tip: setFrame is triggered by the RoboDK instruction Program->Set Reference Frame Instruction.

Parameters
  • pose (robodk.Mat()) – pose of the reference frame with respect to the robot base frame

  • frame_id (int, None) – number of the reference frame (if available)

  • frame_name (str) – Name of the reference frame as defined in RoboDK

setSpeed(speed_mms)

Changes the robot speed (in mm/s)

Tip: setSpeed is triggered by the RoboDK instruction Program->Set Speed Instruction.

Parameters

speed_mms (float) – speed in mm/s

setSpeedJoints(speed_degs)

Changes the robot joint speed (in deg/s)

Tip: setSpeedJoints is triggered by the RoboDK instruction Program->Set Speed Instruction. A joint speed value must be provided.

Parameters

speed_degs (float) – speed in deg/s

setTool(pose, tool_id=None, tool_name=None)

Change the robot TCP (Tool Center Point) with respect to the robot flange. Any movement defined in Cartesian coordinates assumes that it is using the last reference frame and tool frame provided.

Tip: setTool is triggered by the RoboDK instruction Program->Set Tool Frame Instruction.

Parameters
  • pose (robodk.Mat()) – pose of the TCP frame with respect to the robot base frame

  • tool_id (int, None) – number of the reference frame (if available)

  • tool_name (str) – Name of the reference frame as defined in RoboDK

setZoneData(zone_mm)

Changes the smoothing radius (also known as rounding, blending radius, CNT, APO or zone data). If this parameter is higher it helps making the movement smoother

Tip: setZoneData is triggered by the RoboDK instruction Program->Set Rounding Instruction.

Parameters

zone_mm (float) – rounding radius in mm

waitDI(io_var, io_value, timeout_ms=-1)

Waits for a variable io_var (usually a digital input) to attain a given value io_value. This method can also be used to set other variables. Optionally, a timeout can be provided.

Tip: waitDI is triggered by the RoboDK instruction Program->Set or Wait I/O Instruction.

Parameters
  • io_var (int, str) – variable to wait for, provided as a str or int

  • io_value (int, float, str) – value of the variable, provided as a str, float or int

  • timeout_ms (float, int) – maximum wait time

samplepost.joints_2_str(joints)

Converts a robot joint target to a string according to the syntax/format of the controller.

Parameters

pose – 4x4 pose matrix

Returns

joint format as a J1-Jn string

Return type

str

samplepost.pose_2_str(pose)

Converts a robot pose target to a string according to the syntax/format of the controller.

Parameters

pose – 4x4 pose matrix

Returns

postion as a XYZWPR string

Return type

str

samplepost.test_post()

Test the post processor with a simple program

4.2. Post Processor Example

This section shows a sample post processor. This sample Post Processor is used as a template when a new Post Processor is created using RoboDK.

4.3. Post Processor Example Output

Once a program has been generated using a Post Processor, an output such as the following will be obtained. In this example, the result is meant to be used with an ABB robot using an IRC5 controller.

Weld_Hexagon.mod for ABB IRC5 robot
 MODULE MOD_Weld_Hexagon

 PERS wobjdata rdkWObj := [FALSE, TRUE, "", [[0,0,0],[1,0,0,0]],[[0,0,0],[1,0,0,0]];
 PERS tooldata rdkTool := [TRUE,[[0,0,0],[1,0,0,0]],[3,[0,0,200],[1,0,0,0],0,0,0.005]];
 VAR speeddata rdkSpeed := [500,500,500,500];
 VAR extjoint rdkExtax := [9E9,9E9,9E9,9E9,9E9,9E9];

 PROC Weld_Hexagon()
     !Program generated by RoboDK for ABB IRB 1600ID-4/1.5 on 29/11/2014 17:42:31
     ConfJ \On;
     ConfL \On;
     rdkWObj.oframe:=[0,0,0],[1,0,0,0];
     rdkWObj.uframe:=[0,0,0],[1,0,0,0];
     rdkTool.tframe:=[-4,0,371.3],[0.92387953,0,0.38268343,0];
     MoveAbsJ [[-0,-19.143793,-7.978668,0,49.189506,-0]],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     MoveJ [[1010.634,-114.491,662.29],[0,0,1,0],[-1,0,-1,0],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     WeldStart;
     MoveL [[810.634,-114.491,662.29],[0,0,1,0],[-1,0,-1,0],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     MoveL [[910.634,58.715,662.29],[0,0,1,0],[0,-1,0,0],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     MoveL [[1110.634,58.715,662.29],[0,0,1,0],[0,-1,0,0],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     MoveL [[1210.634,-114.491,662.29],[0,0,1,0],[-1,0,-1,0],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     MoveL [[1110.634,-287.696,662.29],[0,0,1,0],[-1,0,-1,0],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     MoveL [[910.634,-287.696,662.29],[0,0,1,0],[-1,0,-1,0],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     MoveL [[810.634,-114.491,662.29],[0,0,1,0],[-1,0,-1,0],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     WeldStop;
     MoveL [[1010.634,-114.491,662.29],[0,0,1,0],[-1,0,-1,0],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     MoveAbsJ [[-0,-19.143793,-7.978668,0,49.189506,-0]],rdkExtax], rdkSpeed, rdkZone, rdkTool, \WObj:=rdkWObj;
     ConfJ \On;
     ConfL \On;
 ENDPROC
 ENDMODULE