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

Running RoboDKapi in production

#1
Hi RoboDK team,

I have a more general question in regards to using the python API in production. There's not much info on how it should be done, so I'll provide a simplified version on how I am using it at the moment, but I would like to know if there is a more appropriate way

General workflow of my robotcell:
I am using the API to generate sanding programs for custom made solid surface bathroom sinks (up to 8 at the same time). I have a Siemens PLC with a start and stop button, that starts and stops a linux service respectively. This service starts a python program, where (based on data from a database) robot sanding programs will be generated using the RoboDK API. The sanding paths for the inside of the sinks were made with Autodesk Fusion CAM and these paths are stored as APT files. The RoboDK API loads in the correct apt file corresponding to the database data, calculates the robot moves ( all slightly different for these 8 positions). The PC sequentially uploads these robot programs to the robot and the robot starts sanding.

How I use the API:
When the script starts, it opens robodk and opens the robotcell.rdk file which contains the robot,  tools and origin points for the 8 different positions (Identical calibrated representation of the physical cell). After all the paths are generated, I shutdown roboDK and run through all the individual sanding programs.

Is there a more correct way to start and stop the roboDK API in the background?

Thanks in advance!
#2
Your workflow looks good. I assume you use functions like Update (for robot machining projects) or setMachiningParameters or AddMachiningProject to update your paths based on the APT file.

You can call Update on your robot machining project to get a status of your program. For example, valid ratio should be 1.00 (the robot is able to complete the path without issues). If there are any issues you should see a readable message. You can find more information here:
https://robodk.com/doc/en/PythonAPI/robo...tem.Update
You can then retrieve the link to your program by calling getLink. Example:
Code:
prog, status = machining.setMachiningParameters("path-to-your-apt-file.apt")
# if needed, you can also change settings and update your path again:
status =  machining.Update()
...
# Retrieve the link to your program:
program = machining.getLink(ITEM_TYPE_PROGRAM)
# Generate and upload the program:
m.MakeProgram("Path-to-folder", RUNMODE_MAKE_ROBOTPROG_AND_UPLOAD)
You can rely on your post processor to transfer the program automatically. This uses FTP protocol by default for most robot controllers and post processors.

Also, for production, I recommend you to consider the following command line flags for RoboDK:
  • -NEWINSTANCE Forces using a new instance of RoboDK (the default port of the API will change and it should not interfere with other instances of RoboDK you could have).
  • -EXIT_LAST_COM Forces RoboDK to close if your API Robolink instance closes or your application crashes.
  • -NOUI Do not show the UI. If you rely 100% on your code and you don't want to show the UI. The 3D view won't be visible. Another option is to use -HIDDEN
  • -SKIPINI Skip user settings (I don't recommend you to use it if you rely on your settings).
Example:
Code:
RDK = Robolink(args=["-NEWINSTANCE", "-SKIPINI", "-EXIT_LAST_COM"])
You can find more information here:
https://robodk.com/doc/en/RoboDK-API.html#CommandLine
#3
Hey Albert,

Thanks for the reply, this gives me confidence to put the cell in production. You are correct, that is basically how I use it right now. 

Thanks for the tip on the -NEWINSTANCE and -EXIT_LAST_COM, I will add those!

maybe usefull for other people: I struggled a lot getting roboDK to start as a service:  I had to add the 'Environment="DISPLAY=:0.0" line to the service file. 
And if you use a virtual environment like anaconda, make sure to add the path to the environment before your mainscript
Code:
[Unit]
Description= main python script
PartOf=graphical-session.target
After=graphical-session.target

[Service]
WorkingDirectory=/home/...
Environment="DISPLAY=:0.0"
ExecStart=PathToAnacondaEnvironment /PathToMainScript
Type=exec
RemainAfterExit=no
KillMode=control-group

[Install]
WantedBy=graphical-session.target
#4
Excellent, thank you very much for this feedback!

Also, if you want to start RoboDK in the background as a service and you don't need to show the UI you could use the -NOUI parameter this will use less resources (RAM memory) as it does not create 3D context.
  




Users browsing this thread:
1 Guest(s)