Using Python Script as Task Manager 1.3.0

 

This guide provides a basic walk-through regarding the files inside the python folder in the RealtimeExamples repository and guides the user on how to use the python script as a task manager to control the robots in the Getting Started Example Project

 

1 Repository

Code examples and documentation can be found on our public GitHub repository RealtimeExamples.

1.1 Python Task Manager Directory

The python scripts and libraries are stored in the python folder under the root directory of RealtimeExamples.

RealtimeExamples ├── python │ ├── lib │ │ ├── PythonCommander.py │ │ ├── PythonCommanderHelper.py │ │ └── CommonOperations.py │ ├── Example.py │ ├── Example_CommonOperations.py │ └── Example_GettingStarted.py │ └── Example_GettingStarted_1.3.0.py ├── C# └── PLC

2 Example Scripts

This section describes how to use the example python scripts located in the root directory of the RealtimeExamples python folder. The examples serve as a Task Manager so the following instructions are written in the assumption that the project is loaded in the Control Panel before the python scripts are called. The example python scripts can be run by moving to the python folder and running the python scripts in a terminal.

python3 <python script file>

For example, to run the example ‘Example.py’:

python3 Example.py

2.1 Example.py

Example.py attempts to connect to the Realtime Controller assuming that the controller is connected via localhost thus using the IP address 127.0.0.1 and port number 9999 as arguments. This example with work with any deconfliction group and projects.

The script then calls GetMode five times and returns the response of the Realtime Controller if the connection was successful.

The expected response would be something like this:

2.2 Example_CommonOperations.py

Example_CommonOperations.py makes use of the three library files and provides an example of how to initialize robots in the project using a python script. The project file needed for this example is located in the root directory of the python folder. The user has to manually add the deconfliction group in the control panel.

2.2.1 How to Use the Example

  1. Load the CommonOperationsExample.zip project into the Control Panel by clicking on Upload Project and choosing CommonmOperationsExample.zip under the python folder.

A message that the project has been successfully uploaded will be displayed when the upload is successful

 

2. Create a deconfliction group and name it CommonOperationsExample.

Click on the Deconfliction Group drop-down list and click on the 'Add A Group' button.

Type the name of the Deconfliction Group you want to add and press ‘Add’

 

3. Add the project to the deconfliction group.

Select the newly created ‘CommonOperationsExample’ deconfliction group.

Check on the ‘CommonOperationsExample’ project under Available Robots to add the project to the group.

4. Load the group and verify voxel region.

Load the group by clicking on the ‘Load Group’ button

Click on the ‘Command’ tab

Click on Enter Operation and verify the voxel region.

The robot will be initialized and the controller will be in ‘Operation Mode’.

Set the controller back to ‘Configuration Mode’ by clicking on the ‘Enter Configuration button’.

The controller will then be back to ‘Configuration Mode’.

 

5. Open a terminal and run the Example_CommonOperations.py.

2.2.2 Example Content and Expected Behavior

This example accepts an IP address as an argument and uses 127.0.0.1 as default IP address.

The example checks if the Robot Controller is in fault mode then proceeds with checking if the group has been named correctly using functions from Python Commander Helper.

It gets the necessary project information and project names and proceeds with the startup sequence and putting the robots into the roadmap.

Finally, it executes an attempt at fault recovery after checking with the user if the user wants to test fault recovery or not.

2.3 Example_GettingStarted.py

Example_GettingStarted.py makes use of the GettingStartedExampleProject and simulates a pick and place task using two robots. The project files needed for this example is located in the root directory of the python folder. The user has to manually add the deconfliction group in the control panel.

2.3.1 How to Use the Example

  1. Follow the procedures on how to setup the GettingStartedExampleProject in the Control Panel here until step three.

 

2. We will then be using the python script as a Task Manager instead of using the rtr_quick_commander.

python3 Example_GettingStarted.py

 

2.3.2 Example Content and Expected Behavior

The example features a pick and place operation using two robots with the work area limited to the area where the pick positions for both robots are really close to each other. The task flow is as follows:

  1. The startup sequence is executed. The deconfliction group is initialized, the controller is set to operation mode and the robots are moved to the ‘staging’ position.

  2. Threads and task parameters are initialized.

  3. The following sequence is executed in a loop until the robots have finished performing pick and place in eight positions listed in the hub_list.

  4. The function AcquireTargets is called to acquire pick positions. It is implemented in such a way that randomized x and y positions with fixed z position will be returned as pick positions.

  5. pick_and_place_part is called for each of the robots. Pick and place part involves the following sequence:

    1. the robot moves to the closest roadmap position to the pick position using MoveToPose

    2. the robot moves to the pick position via a BlindMove

    3. the robot moves to the unfinished place position

  6. When pick_and_place_part is executed successfully, the hub_idxs is advanced so that the next part will be placed to the next place position until pick and place to all eight place positions are completed for each robot.

Note: By setting the retreat_idx variable to the robot with less priority to complete the pick and place sequence, the other robot will retract to the ‘staging’ position if motion is not possible because its path is blocked by the other robot.

 

2.3 Example_GettingStarted_1.3.0.py

Example_GettingStarted_1.3.0.py is a script that can be used to run an assembly task with two robots equipped with screw drivers as end-effectors performing assembly and one robot equipped with a camera as end-effector performing inspection. The project files needed for this example is located in the root directory of the python folder. The user has to manually add the deconfliction group in the control panel.

2.3.1 How to Use the Example

  1. Load the projects and add them to a deconfliction group named ‘GettingStartedGuide’. There is also an option of setting a name you prefer and editing the group name in the python script instead.

 

  1. We will then be using the python script as a Task Manager instead of using the rtr_quick_commander.

python3 Example_GettingStarted_1.3.0.py

 

2.3.2 Example Content and Expected Behavior

The task flow is as follows:

  1. The startup sequence is executed. The deconfliction group is initialized, the controller is set to operation mode and each of the robots are moved to their respective staging position via ‘OffroadToHub'.

  2. Threads and task parameters are initialized.

  3. Each of the robots will cycle through their hub lists to perform their tasks (assembly for the Fanuc RS007L and Kawasaki 200iDL and inspection for RV-5AS).

The behavior of the robots performing assembly will be as follows:

  1. Move to staging position

  2. Pick screw

  3. Move to assembly location (screw hole)

  4. Repeat cycle and advance the screw hole index

  5. Go back to staging position after cycling through all screw holes

The behavior of the robot performing inspection will be as follows:

  1. Move to staging position

  2. Move to an inspection point

  3. Repeat cycle while cycling through all inspection points

  4. Go back to staging position.