Headless Pally

This article contains useful information about running Pally without the Teach Pendant.

Understanding headless mode

In most setups the palletizer robot is a standalone application. The operator uses the teach pendant to select product, continue or terminate existing pallet, confirm empty pallet positions, etc.

In headless mode however, the robot should be able to palletize without using the teach pendant. This means an external interface will be used to select product, continue or terminate existing pallet, display current progress, etc.

To run Pally without the teach pendant we recommend using the Order Processing functions, deactivate the Operator Interface, and Redirect all Popups using registers. During program run it is also possible to send a detailed progress report via Callbacks.

At the bottom of this page you’ll also find a sample program where Pally is controlled via OPC UA.

Useful settings related to headless mode

GUI settings

It is recommended to select Operator Interface: “None”. This will instruct the code generator to exclude all script functions related to the Pally operator interface. As a result, the robot program will be shorter, and start faster.

Operator interface can be completely deactivated in Headless Mode

 

Automatic order processing

Add the following script line under the initial MoveJ node under the Pally program node:

rf_order_mode=2

This will instruct the Pally program to get the pattern name and requested number of boxes from the Order Management API. The program will keep running until terminated by external control signals or a fatal error occurs.

Automatic order processing mode can be activated by setting rf_order_mode=2

Using the Order Management API functions

The Order Management API functions provide an easy interface to instruct Pally what to do. The pattern name and the number of boxes can be specified programmatically.

It is possible to access the Order Management API functions via the Pallet Manager daemon XML RPC interface, e.g. using Python, but we recommend using script functions in a separate thread inside the robot program.

 

Product selection variables

Using the product selection variables rf_product_selection_strategy and rf_product_selection_predefined is still possible, but not recommended when using Pally in headless mode. These variables are useful when creating a simple palletizer application with a fixed pallet pattern, but won’t provide a flexible workflow that can be easily controlled by an external controller.

Easy pattern selection

In headless mode it is a common practice to use a special naming convention in pattern names to make pattern selection via external control systems easy. In the following example we use 4-digit integer number in the pattern file name to identify patterns, assuming every pattern file name is in the format

P_nnnn_patternname.json

where nnnn is a 4-digit integer in the middle of a file name.

The function goes through the list of available patterns in the patterns folder, and return the file name that matches the search criteria.

def find_pattern_by_nr(pattern_number): # convert number to string with zero padding local p_str = str_cat("0000", pattern_number) # make sure the string is not longer than 4 digits p_str = str_sub(p_str, str_len(p_str)-4, 4) local nr_patterns = palletmanager_daemon.init_pattern_cache() local pattern_nr = 0 while (pattern_nr < nr_patterns): local file_name = palletmanager_daemon.get_file_name(pattern_nr) textmsg("Testing pattern name: ", file_name) if (str_len(file_name) >= 6): if (str_sub(file_name, 2, 4) == p_str): textmsg("Found pattern name: ", file_name) return file_name end end pattern_nr = pattern_nr + 1 end return "" end

Pallet confirmation signals

Pallet confirmation is done via the Pallet Confirmation signals as specified in the Installation Node. This can be used in Headless Mode as well.

The pallet confirmation signal must go from LOW to HIGH and remain HIGH for at least 300 msec to confirm a new empty pallet.

 

Pallet termination signals

Terminating the current pallet can be done via the variables rf_P1_terminate and rf_P2_terminate.

Setting rf_P1_terminate = True will stop the right pallet instantly.

Setting rf_P2_terminate = True will stop the left pallet instantly.

Pallet termination at program (re)start

After stopping and starting the program again in Headless mode, the program will continue the existing pallet unless specified otherwise. To terminate the existing pallet on program start, make sure the corresponding variable (rf_P1_terminate and/or rf_P2_terminate) is set to True in the initial MoveJ node under the Pally program node.

Pallet termination during program run

Setting rf_P1_terminate or rf_P2_terminate to True will finish the current motion (put down the last box that is currently held by the robot) and finish the current pallet.

If the order has more pallets to be palletized, the robot will wait for a new empty pallet confirmation signal and then proceed to the next pallet in the current order.

If the order has no more pallets, but there are additional orders in the queue, the robot will wait for a new empty pallet confirmation signal and then proceed to the first pallet of the next order.

Otherwise the robot will go to the default waiting position and wait for a new order.

Progress indicator

Use Callbacks to report the current progress back to the external control system. Use the global Pally variables such as ProductName, PalletNr and ProductCount. You can also get more detailed information from the Pallet Manager Daemon.

Suppress popups

It is possible to suppress Pally popups and use IO registers to indicate an error/warning. An integer code and an optional integer parameter is provided.

Unique error codes

  • This position cannot be palletized (2002)

  • Unable to find a collision-free path (2011)

  • this pattern hasn’t been fully verified (2023)

  • controlling the external hardware failed (2005)

  • vacuum not detected (1016)

  • … (more to come)

 

Example

Control loop via OPC UA

A script code is provided to receive commands from OPC UA. The command sequence is the following:

  • set the requested command in the OPC UA variable “COMMAND”

  • set the command parameters (specific to each command)

  • increment the variable value “COMMAND_SEQNO” by one

  • wait until “COMMAND_RESULT_SEQNO” is updated to the same value as “COMMAND_SEQNO”

  • read command result from the variable “COMMAND_RESULT” (possible values: 1=OK, 0=not OK)

Currently the following commands are supported:

  • “NEW_ORDER”: create a new palletizing task (pattern name and number of boxes)

  • “TERMINATE_PALLET”: immediately terminate the current pallet

  • “DELETE_ORDERS”: remove all orders from the queue

  • “EXIT”: terminate the robot program

To create a new palletizing task (NEW_ORDER):

  • set the requested command “NEW_ORDER” in the OPC UA variable “COMMAND”

  • set the pallet manager instance (optionally) in the variable “INSTANCE” or leave it to 0

  • set the requested pattern in the variable “PATTERN” (4-digits integer format)

  • set the requested number of boxes in the variable “BOXES” or leave it to 0 for a full pallet

  • increment the variable value “COMMAND_SEQNO”

  • wait until “COMMAND_RESULT_SEQNO” is updated to the same value as “COMMAND_SEQNO”

  • read command result from the variable “COMMAND_RESULT” (1: OK, 0: not OK)

 

Sample code to control Pally via OPC UA.

def find_pattern_by_nr(pattern_number): # convert number to string with zero padding local p_str = str_cat("0000", pattern_number) # make sure the string is not longer than 4 digits p_str = str_sub(p_str, str_len(p_str)-4, 4) local nr_patterns = palletmanager_daemon.init_pattern_cache() local pattern_nr = 0 while (pattern_nr < nr_patterns): local file_name = palletmanager_daemon.get_file_name(pattern_nr) textmsg("Testing pattern name: ", file_name) if (str_len(file_name) >= 6): if (str_sub(file_name, 2, 4) == p_str): textmsg("Found pattern name: ", file_name) return file_name end end pattern_nr = pattern_nr + 1 end return "" end def do_insert_order(): local instance = opcua_server_read_byname("INSTANCE") local pattern = opcua_server_read_byname("PATTERN") local boxes = opcua_server_read_byname("BOXES") local pattern_name = find_pattern_by_nr(pattern) local result = 0 if (pattern_name != ""): local nr_orders = palletmanager_daemon.get_nr_orders(instance) if (palletmanager_daemon.insert_order(instance, nr_orders, "SOME_ID", "My Order", pattern_name, [1, boxes])): textmsg(str_cat("Inserted order ", pattern_name), str_cat(" with boxes ", boxes)) result = 1 end end return result end def do_terminate_pallet(): local result = 0 local instance = opcua_server_read_byname( "INSTANCE") if (instance==0): rf_P1_terminate = True rf_P2_terminate = True result = 1 end return result end def do_delete_orders(): local instance = opcua_server_read_byname("INSTANCE") local result = 0 if (palletmanager_daemon.clear_orders(instance)): result = 1 end return result end thread OpcPallyThread(): local command = "" local can_go = True while (can_go): local last_command_seqno = opcua_server_read_byname("COMMAND_SEQNO") local command_seqno = last_command_seqno while (command_seqno == last_command_seqno): sleep(1) command_seqno = opcua_server_read_byname("COMMAND_SEQNO") end last_command_seqno = command_seqno command = opcua_server_read_byname("COMMAND") local result = -999 # command not supported if (command == "NEW_ORDER"): result = do_insert_order() elif (command == "TERMINATE_PALLET"): result = do_terminate_pallet() elif (command == "DELETE_ORDERS"): result = do_delete_orders() elif (command == "EXIT"): can_go = False result = 1 end opcua_server_write_byname("COMMAND_RESULT", result) opcua_server_write_byname("COMMAND_RESULT_SEQNO", command_seqno) end # received EXIT command, terminate program halt end opc_pally_thid = run OpcPallyThread()

 

The example is not suitable for Dual Product mode.

Palletizing progress via OPC UA

A script code is provided that updates some OPC UA variables during palletizing.

  • The actual pattern name will be visible in the string variable “CURRENT_PATTERN”.

  • The number of boxes being picked (1 for single pick, 2 for double pick, etc) in the “CURRENT_PICK” variable.

  • The variable “CURRENT_BOXES” contains the number of boxes already on the pallet.

  • The remaining boxes are indicated in “REMAINING_BOXES”.

  • The variable “PALLET_NUMBER” contains 1 when palletizing on the right pallet, 2 for the left pallet.

 

The script functions are called from Pally callbacks:

  • beforePallet: call the function BeforePalletAction()

  • afterGrab: call the function AfterGrabAction()

  • afterRelease: call the function AfterReleaseAction()

  • afterPallet : call the function AfterPalletAction()

Add more function calls if needed.

Error codes via OPC UA

A script code is provided to suppress app popups and redirect error codes into registers.

The error/warning code will be set in the OPC UA integer variable “STATE_CODE”. Optional parameter of the error/warning can be accessed in the “STATE_PARAM” integer variable. If an error/warning occurs, the boolean variable “STATE_FLAG” will be set to true.

Please note: the sample program will not simulate user acknowledgement of errors.

 

Running the example

See headless Pally in action here:

Download the example

Download the complete example here:

Current limitations

Some popups cannot be suppressed.