Based on contributions by icorn.
This shows how to implement a software āholdā button for a Kawasaki robot: a command sent from your PC that pauses the robotās motion and lets you resume it later, without killing the controllerās motors or aborting the program.
What you need
- A Kawasaki robot controller with AS language / KIDE access, able to run background āProcess Controlā (
.pc) programs - A network connection between the PC and the robot (this example uses UDP; see How to connect a Kawasaki robot to a Python program over TCP or UDP for TCP/UDP basics)
- Python 3 (
socketmodule)
Steps
1. Understand PC programs vs. AS programs
A .pc (Process Control) program runs in the background, simultaneously with the main .as program you run on the robot. Unlike regular AS programs, PC programs are allowed to control the flow of execution of other programs ā including issuing āmonitor commandsā that a normal program canāt.
The two monitor commands you need are HOLD and CONTINUE. Unlike ABORT or HALT, HOLD pauses the program the same way turning the physical āHoldā dial would: the robotās motors stay energized, and you keep control over the robot via software. To call a monitor command from a PC program, prefix it with MC, e.g. MC EXECUTE program_name.
2. Write the background PC program
This program starts your main robot program, then waits for "hold" or "continue" messages over UDP and issues the matching monitor command.
.PROGRAM bg_control.pc () ;
.retrecv = -1
WAIT SWITCH (POWER)
MC EXECUTE main_robot1
receive:
.$receive = ""
; Receive control commands via UDP, executes the UDP support program
CALL udp_emergency(.retrecv, .$receive)
; Check for errors in UDP reception
IF .retrecv < 0 THEN
GOTO receive
END
; Handle received commands
IF .$receive == "hold" THEN
MC HOLD ; THIS IS THE COMMAND THAT PAUSES THE ROBOT!!
PRINT " -> PROGRAM HELD"
; Add a short delay to ensure state update
TWAIT 0.5
GOTO receive
END
IF .$receive == "continue" THEN
MC CONTINUE ; THIS IS THE COMMAND TO RESUME ROBOT MOVEMENT
PRINT " -> PROGRAM RESUMED"
; Add a short delay to ensure state update
TWAIT 0.5
GOTO receive
END
; If neither hold nor continue, loop again
GOTO receive
.END
Replace main_robot1 with the name of your own main program.
3. Write the UDP receive helper program
bg_control.pc calls this program to receive a message over UDP and decode it into a string.
.PROGRAM udp_emergency (.ret,.$receive) ;
ip[1] = 192
ip[2] = 168
ip[3] = 0
ip[4] = 10
.$recv_buf[1] = .$receive
.ret = 0
timeout = 60
max_length = 255
.port = 10020
.$receive = ""
.num = 0
; Receive a message from the server. Check the Kawasaki AS Manual
; for details on UDP_RECVFROM.
UDP_RECVFROM .eret, .port, .$recv_buf[1], .num, timeout, ip[1], max_length
IF .eret < 0 THEN
PRINT "UDP_RECV error in Control Program ", .eret
PRINT ".num = ", .num
.ret = -1
ELSE
IF .num > 0 THEN
IF .num * max_length <= 255 THEN
FOR .j = 1 TO .num
.$receive = .$receive + .$recv_buf[.j]
END
ELSE
.ret = -1
PRINT "String too long"
PRINT .$recv_buf[1]
END
ELSE
PRINT "Invalid response"
.ret = -1
END
END
.END
4. Send hold/continue commands from Python
import socket
ROBOT_IP = '192.168.0.1' # replace with your robot's IP address
ROBOT_PORT_EMERGENCY = 10020 # any non-privileged port the robot isn't already using
def send_message(message, robot_port=10010):
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as server_socket:
try:
server_socket.sendto(message.encode(), (ROBOT_IP, robot_port))
print(f"Message '{message}' sent to robot at {ROBOT_IP}")
except Exception as e:
print(f"Error sending message to robot: {e}")
send_message('hold', ROBOT_PORT_EMERGENCY)
send_message('continue', ROBOT_PORT_EMERGENCY)
Troubleshooting
- Robot never pauses: check that
bg_control.pcis actually running as a background program (it needs to be started as a.pcprogram, not a regular.asprogram) and that the port inudp_emergencymatchesROBOT_PORT_EMERGENCYin Python. .retrecv < 0loops forever without pausing: this means the UDP receive itself failed (timeout or malformed packet); the program just loops back to wait for the next message. Check the network connection and that the PC is actually sending to the robotās IP and port.
Further reading
Check the Kawasaki manuals for more detail on PC programs and monitor commands.
Related
- How to connect a Kawasaki robot to a Python program over TCP or UDP
- How to control a Kawasaki robot with the PromoBot Python class
Rewritten and consolidated (Sept 2026) from the original student how-toās: How to āpauseā a Kawasaki robot on command using a Kawasaki background program.