Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import/Export Programs via API
#1
Question
Hello,

I'm using the C++ API to controll the RoboDK from an external application.
As an example, I used the c++ example from the gitlab projecthttps://github.com/RoboDK/RoboDK-API/.

I would have some question about the API because I was not able to solve this using the documentation.

- Is there a posibility to import/export programs (not as robot specific program) via the API?

- Who is it possible to get the values of non-movement instructions within a program ? (Item::Instruction(...) only returns types and positions but no values for speed- or wait-instructions)

在后来——应该是什么x of the Item::InstructionList(tMatrix2d m) method? (because it's everytime empty)

Attached you find a very small robodk project with one program inside which I want to export and later import via the API.

Thank you very much in advance for your help.


Attached Files
.rdk Demo.rdk(Size: 411.96 KB / Downloads: 367)
#2
Hi Leo,

If you want to generate a generic program you can use a neutral post processor such as the CSV post or a Gcode post. This will generate a generic program with all the information needed. We'll soon add a post that automatically creates a Python script that can be run in simulation.

你can change instruction parameters as shown in this example:
//www.sinclairbody.com/doc/en/PythonAPI/exam...structions

We just added support for this so make sure to upload RoboDK. Also, the Python API uses a dictionary to get/set values, with the C++ API you'll need to use a JSON string instead.

InstructionList is a bit outdated but should work. It will provide a large array describing the program as a 2D matrix.

Albert
#3
HiAlbert,

thank you for your response.

Exporting a program using the CSV Post Processor worked very well using the UI.
But is it possible to change the Post Processor using the C++ API?

I saw the python example:

Code:
robot = RDK.ItemUserPick("Select a robot", ITEM_TYPE_ROBOT)

# Set the robot post processor (name of the py file in the posts folder)
机器人。setParam(“后处理程序”、“Fanuc_RJ3”)
But in C++, the RoboDK_API::Item has no setParam method.

Is it possible to later import the same file again?

Regarding get/set values using json string: do you have an example or documentation for that?

BR, Leo
#4
Hi Leo,

Yes, it is possible to change the post processor via the API. You'll find the setParam function for items available in the latest version of the C++ API on GitHub:
https://github.com/RoboDK/RoboDK-API/blo...dk_api.cpp

Importing program files such as LS files may work but you may loose information depending on the syntax you are using.

The example I provided includes an example using a dictionary in Python (it is automatically converted to a JSON string behind the scenes). You can do so in C++/Qt using a QJsonDocument.

Albert
#5
Hi Albert,

with the new update I'm now able to set the post processor for an item (program) using "item.setParam(...)".
Thank you.

But I can't find the regarding getting method to read the current selected post processor
-> there is no "item.getParam(...)" method defined.
Could you add this method to the C++ API?


Regarding importing a program:
I would use the same syntax as it exports using the CSV Post Processor.
Is there a method/way to import this file? Or is it only possilbe manually?

Could you provide a link to the example you mentioned (importing a program via python dictionary)?

BR,
Leo
#6
Hi Leo,

It is already possible to retrieve the current post processor.
Simply pass an empty string to the Post Processor parameter

Code:
post_selected = robot.setParam("PostProcessor")

@Phillipcreated a post processor that may help you (attached). This post will generate a Python program as if you created it using the RoboDK API. You can reload your original program in RoboDK or move your robot using drivers.

Albert
#7
Hi Albert,

thank you for your help so far.

Could you reattach the mentioned post processor from Phillip?
You last post has no attachments.

BR, Leo
#8
Hi Leo,

Sorry, I missed the attachment.

Albert


Attached Files
.py Quine.py(Size: 24.59 KB / Downloads: 421)




Users browsing this thread:
1 Guest(s)