Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Generating Robot Programs Through API

#1
I'm having difficulties generating Robot Program Files through the RoboDK API in headless mode.
Goal:
  • Run RoboDK headless.
  • Send a request through the API (localhost for now but later remotely) to generate a robot program based on selected parameters.
Current Setup:
  • I have a station with a sequence.py script that contains predefined robot movements.
  • When RoboDK is open and I run my MakeProg (second code bellow), it works fine.
  • However, when I run my program to start RoboDK in headless mode and execute the same file, I receive: Program generated: OK
    But no file was generated
  • Idea is to later send the program written in python through the API and my RoboDK headless generates the Robot program for it.

Code for Starting RoboDK Headless & Generating the Program
Code:
from robodk.robolink import *  # RoboDK API
import time

# Start RoboDK in headless mode and load the station
RDK = Robolink(args=['-NOUI','-SKIPINI'])

station = RDK.AddFile("C:/Users/dantunes/Desktop/Projects/API_Test.rdk")

RDK.setActiveStation(station)
print(RDK.ActiveStation().Name())

# Allow time for RoboDK to fully load
time.sleep(5)
stations = RDK.getOpenStations()

# Print the station names
if stations:
    print("Open Stations in RoboDK:")
    for station in stations:
        print(f"- {station.Name()}")
else:
    print("No open stations found in RoboDK.")

Code:
from robodk.robolink import *  # RoboDK API
import time

# Connect to the running RoboDK instance
RDK = Robolink()

# Wait a bit to ensure connection is established
time.sleep(2)
print(RDK.ActiveStation().Name())

# Set the output path for generated robot programs
RDK.Command("PathPrograms", "C:/Users/dantunes/Desktop/Projects/")

# Set the post-processor for the program
RDK.Command("PostProcessor", "Epson_RC.py")

print("Generating robot program for 'Sequence'...")
file = RDK.Command("MakeProg", "Sequence")
print(f"Program generated: {file}")

RDK.Finish()
print("Disconnected from RoboDK.")


Has anyone encountered this issue before? Could it be a permissions issue, file path problem, or something missing when running in headless mode?
Also, If someone could explain the difference between the MakeProg and MakeProgram commands.

Any insights would be greatly appreciated!
#2
Can you try calling MakeProgram on the program item instead of using the command?

Example:
Code:
pyprog.MakeProgram()
Also you shouldn't need to pause for 2 seconds after connecting to the RoboDK API. Did you experience issues with this?

If you can share a RoboDK project file that shows this behavior we can better take a look.
#3
Albert, I attached my Station file (simple one robot just to test this communication and process)
If I use MakeProgram I get 
Quote:Invalid item provided: Item identifies is not valid or it does not exist.
I’ve tried specifying different item types:
  • ITEM_TYPE_PROGRAM_PYTHON
  • ITEM_TYPE_PROGRAM
  • No item type at all

MakeProg Issue
  • The first time I run MakeProg, it works fine.
  • The second time, it tries to open another instance of RoboDK, which causes it to break.
  • After this happens, if I try to restart in headless mode, RoboDK tells me my license is free (even though I have a professional license) and doesnt start.
  • To fix this, I have to manually open RoboDK, disable the license, then re-enable it before running again.
The headless startup code is the same as before (I only removed the timers).
Updated generate program:
Code:
from robodk.robolink import *  # RoboDK API

# Connect to the running RoboDK instance
RDK = Robolink()

print(RDK.ActiveStation().Name())

# Set the output path for generated robot programs
RDK.Command("PathPrograms", "C:/Users/dantunes/Desktop/Projects/240152/RoboDk/")

# Set the post-processor for the program
RDK.Command("PostProcessor", "Epson_RC.py")

print("Generating robot program for 'Sequence'...")
program = RDK.Item("Sequence", ITEM_TYPE_PROGRAM_PYTHON)
print(f"Program generated: {program}")
program.MakeProgram("C:/Users/dantunes/Desktop/Projects/240152/RoboDk/",3)
#RDK.Command("MakeProg", "Sequence")

#RDK.Disconnect()
print("Disconnected from RoboDK.")


Attached Files
.rdk   API_Test.rdk (Size: 1.74 MB / Downloads: 46)
#4
OK I understand the issue better now. We'll improve RoboDK so you can use the 2 functions you are trying.

For the time being you can generate your program purely using Python by changing your RunMode and calling RDK.Finish() to trigger the program generation. Example:
Code:
RDK.setRunMode(RUNMODE_MAKE_ROBOTPROG)

robot.setPoseFrame(reference)
robot.MoveJ(Offset(box, 0, 0 ,200,0,0,0))
robot.MoveL(box)
robot.MoveL(Offset(box, 0, 0 ,200,0,0,0))
robot.MoveJ(home)

RDK.Finish()
#5
That worked great, thank you Albert!

I recently installed RoboDK on my Linux Debian machine. The first time I ran it, everything worked perfectly. However, after that, I started encountering the following error whenever I try to open RoboDK or use the python script to open headless:

Code:
symbol lookup error: ./RoboDK: undefined symbol: _ZdlPvm, version Qt_5

After some research, I found that this error is likely due to a mismatch between the Qt version used to build RoboDK (Qt 5.12) and the version installed on my system (Qt 5.15).

I’d like to know if there’s a workaround for this issue without having to install Qt 5.12 or use a Docker container. For example:
  • Is there a version of RoboDK compatible with Qt 5.15?
  • Can I modify something in the current installation to make it work with Qt 5.15?

If there’s no workaround, could you provide guidance on the best way to proceed? For instance, should I:
  • Install Qt 5.12 alongside Qt 5.15?
  • Use a Docker container with Qt 5.12 preinstalled?
#6
I'm not so familiar with Docker but I assume it will work if it is precofigured with Qt 5.12.

You can try running the debug script to see if you have any hints on what could be causing this error.

You can also try adding the command line option -platform offscreen which can help you run RoboDK without a screen (it is like running a virtual non-existing screen):
Code:
./RoboDK -NOUI -platform offscreen
#7
With the Debug flag it still gives me the same error as well with the platform offscreen option.
Is there a way to change the dependency on RoboDK to 5.15?
I found this other forum entry that says to change pyside2 version requirement in the addin but I don't know if that applies in this situation.
https://robodk.com/forum/Thread-shape-ad...untu-20-04

In any case, installing 5.12 manually was not possible due to my machine available space.
#8
I don't think that Pyside2 would be causing an issue in your case. Your Qt binaries issue is more related to the version of Qt.

You mentioned RoboDK started properly at some point. Do you remember what you installed afterwards? I assume you didn't alter the binaries in the install folder of RoboDK?
#9
RoboDK only works when I launch it immediately after installation. I didn’t install anything else after that.

If I uninstall and reinstall RoboDK, and then check the box to run it at the end of the installation process, it opens fine. However, if I close it and try to open it again normally, I get the Qt error.
#10
Did you use the Raspberry Pi (Debian) installer or the Ubuntu installer?

You may need to start RoboDK using one of the SH files after installation instead of running the binary directly.
  




Users browsing this thread:
1 Guest(s)