How to Execute Saved positions as Waypoints and movement in URCap

I’m currently programming a UR10e robot to communicate with a HoloLens in order to simulate a welding process. I position the robot and visualize each position and movement in the HoloLens by placing spheres at the positions and drawing arcs or lines to represent the two types of motion.

For communication between the robot and the HoloLens, I’m using the MQTT protocol, with MQTT libraries integrated into both the URCap and Unity.

The goal is to simulate the entire welding process. I’ve completed the simulation part, and now I want the robot to execute the sequence when a “Run” button is pressed. At that point, the robot should use all previously saved positions as waypoints, and the corresponding movement types (arc or linear) to move through them in order.

I attempted to store the positions and movement types in a list and then call a script when the “Run” button is pressed to iterate through and execute the moves. However, I’m encountering an unclear error when i press run in urcap, and the code fails to execute.

Has anyone dealt with a similar scenario or knows the correct way to implement this type of behavior?

What error are you getting?

The error always originates from my script code. I have a loop that checks the saved positions and movements, and depending on the movement type, it applies either linear or circular motion. However, it keeps showing a syntax error in code that worked fine before I added the script, or it throws errors related to counters in my Python code.

Overall, I suspect there’s an issue with how the script is being executed. I tried using Python to write the run script, and I also tried the script programming method, but both resulted in errors.

My main problem is that I don’t know how to properly run Python code in URCap. And if Python isn’t the right approach, how can I access the waypoints I saved?

I’ve tried to use subprogram for collecting positions and shift them in before start section and added the run code within a conditional block in the robot program section. The script runs, but when I receive the first position and try to append it to my list, I encounter a runtime error:
“Unknown/unexpected error in the program ‘popXMLRPCInstance’”.

Any idea what might be causing this?

Trying to understand your complete flow here… When does your python code run? Are you just looking for how to retrieve a collection of Waypoints from Python to Java BEFORE pressing Play on your program?

You say the loop checks the “saved positions.” How and when did they get saved?

Let me explain the flow in detail. I have several sub-programs that I call in the “Before Start” section:

  • weld_mqtt_initialization*: This initializes the MQTT connection.
  • weld_safety_dialog*: This checks safety conditions before executing the main program.
  • weld_get_tcp*: This retrieves the robot’s initial TCP (Tool Center Point) position, sends it via MQTT, and stores it in a list to be used later as a waypoint.
  • weld_button_pressed*: This checks whether the button has been pressed to toggle the robot between free-drive mode and normal mode, and also to trigger either linear or circular movement displays.

After these sub-programs run, instead of using a separate script, I implemented a loop directly in the main program. when i receive the run message from the user “which will be publish in the mqtt broker by clicking a button in Hololens” then, this loop iterates over waypoints and movement types stored in two separate lists. Based on the movement type, it uses either movel for linear movement or movec for circular movement.

The program now runs without any errors until it attempts to save the first position to the list. At that point, I get an error: “index out of range, the list size is smaller than 0 in UR robot”.

The issue seems to be with how I’m using the list in the script. The problematic line appears in the Before Start section:
waypoint_count ≔ 0
waypoint_poses≔
And in the sub-program:
waypoint_poses[waypoint_count] = get_actual_tcp_pose()
waypoint_count = waypoint_count + 1

I also tried to check by replacing this code waypoint_poses[waypoint_count] = get_actual_tcp_pose() with waypoint_poses.append(get_actual_tcp_pose()) but i receive another error: runtime Error: Unknown / unexpected error in the program. “popXMLRPCInstance”

stored in two separate lists

Still don’t know WHERE these lists are stored. Externally? In Python? In Java? In URScript?

“index out of range, the list size is smaller than 0 in UR robot”

This is what you need to include in your original post. Arrays are not dynamic on the UR. You need to initialize them with a size when they are declared.

Other list functions are somewhat recent, so make sure you’re up to at least Polyscope 5.15, otherwise the “append()” method doesn’t even exist.

See the script manual here for more explanation on lists.

1 Like

Exactly, that was my problem. I finally managed to create the list manually with a fixed length, and it worked.
I’m using this approach in URScript, and I exactly need the command you provided. I’ll be updating my program accordingly using this command. Thanks again for the sources and information.