Introduction to ABB RAPID
RAPID (Robot Application Programming Interactive Design) is the programming language of the ABB IRC5 controller. Compared to KUKA KRL, RAPID is significantly more structured and offers genuine high-level language constructs like recursive functions, structured data types, and exception handling. Once you master RAPID, you can develop complex robot programs that are maintainable, reusable, and scalable.
Basic Structure: Modules, Procedures, and Functions
A RAPID program consists of one or more modules. Each module contains data declarations and routines.
MODULE MainModule
! Global variables
PERS tooldata MyTool := [TRUE, [[0,0,100],[1,0,0,0]], [2,[0,0,50],[1,0,0,0],0,0,0]];
PERS wobjdata MyWobj := [FALSE, TRUE, "", [[0,0,0],[1,0,0,0]],[[0,0,0],[1,0,0,0]]];
PROC main()
! Main program
InitRobot;
RunPickPlace;
ENDPROC
PROC InitRobot()
AccSet 80, 80;
VelSet 80, 1000;
ENDPROC
ENDMODULE
Three types of routines exist in RAPID:
- PROC: Procedure, no return value (like a subroutine)
- FUNC: Function with return value
- TRAP: Interrupt routine, triggered by external events
Key Data Types
robtarget – Target Position
The most important data type in RAPID. A robtarget defines the TCP position and orientation as well as axis configuration and external axes:
CONST robtarget pHome := [[500,0,600],[0.707,0,0.707,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
The four fields: [translation vector], [quaternion orientation], [axis configuration], [external axes]. 9E9 means "not defined" for non-existent external axes.
jointtarget – Axis Position
For movements to defined axis positions (e.g., home position):
CONST jointtarget jHome := [[0,-30,30,0,90,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
tooldata – Tool Data
Defines the Tool Center Point (TCP) and tool mass for dynamics calculation:
PERS tooldata tGripper := [TRUE,[[0,0,150],[1,0,0,0]],[3,[0,0,75],[1,0,0,0],0,0,0]];
wobjdata – Work Object
Defines the coordinate system of the workpiece. When programming relative to a workpiece, programs can be easily adjusted when table position changes by simply updating the wobjdata.
Motion Instructions
MoveL – Linear Motion
MoveL pTarget, v500, z10, tGripper WObj:=MyWobj;
Parameters: target point, speed (v500 = 500 mm/s), zone (z10 = 10 mm corner rounding radius), tool, optional: work object.
MoveJ – Joint-Interpolated Motion
MoveJ pHome, v1000, z50, tGripper;
The fastest motion type. All axes move simultaneously and reach the target simultaneously. Not suitable for precise path control.
MoveC – Circular Motion
MoveC pVia, pEnd, v300, z5, tGripper;
Three points define the arc: start point (current position), via point, end point. Note: the TCP must approach all three points in the same tool coordinate system.
MoveAbsJ – Absolute Joint Motion
MoveAbsJ jHome, v500, fine, tGripper;
Moves the robot to a defined axis position. Independent of TCP and tool data — ideal for home positions and calibration moves.
Speed and Zone Data
Predefined speed data in RAPID:
v5tov7000: speed in mm/svmax: maximum robot speedv500: commonly used medium speed (500 mm/s)
Zone data determines the corner rounding radius for chained motions:
fine: exact stop at target point (no corner rounding)z0toz200: corner rounding radius in mmz10: typical zone for chained pick-and-place motions
Error Handling with ERROR Handler
RAPID provides elegant exception handling with ERROR handlers:
PROC SafeMove(robtarget pTarget)
MoveL pTarget, v500, fine, tGripper;
ERROR
IF ERRNO = ERR_PATH_STOP THEN
! Motion was interrupted, park safely
MoveAbsJ jHome, v200, fine, tGripper;
TPWrite "Motion error occurred, moved to home";
RAISE; ! Forward the error
ENDIF
ENDPROC
Common error constants: ERR_PATH_STOP, ERR_MAXSPEED, ERR_OUTOFREACH, ERR_ROBLIMIT.
Interrupts and TRAP Routines
For time-critical responses to external signals:
VAR intnum iStopSignal;
PROC main()
CONNECT iStopSignal WITH TrapStop;
ISignalDI di_EmergencyInput, 1, iStopSignal;
! ... main program
ENDPROC
TRAP TrapStop
StopMove;
TPWrite "Emergency stop activated!";
ENDTRAP
FlexPendant and RobotStudio
The FlexPendant (teach pendant) enables teaching positions in jog mode. Best practice: use the FlexPendant only for measuring in positions. The actual program logic should be developed in RobotStudio. RobotStudio provides syntax checking, debugging, simulation, and a comfortable development environment. Modified modules can be transferred to the controller via the RAPID file share.
Best Practices
- Position naming: Consistent naming:
pPickReady,pPickApproach,pPickGrab - Module structure: One module per function (gripper, camera, transport)
- PERS vs. CONST: Taught positions as PERS (modifiable via FlexPendant), fixed parameters as CONST
- AccSet and VelSet: Always define at program start, not inside loops
- fine vs. zone: Use fine only where truly necessary — it costs time due to the complete stop
Conclusion
RAPID is a mature, well-designed language for industrial robot programming. Those who master the fundamental concepts — modules, data types, motion instructions, error handling — can develop even complex applications in a structured manner. RobotStudio as a development and simulation tool should be integrated into the workflow from the very beginning.