Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function for automatic "Get Position" when running a program on robot
#1
Hi Guys

We are running all our programs on the robot from RoboDK. Before we right-click the program to click RUN, we have to remember to first select "Get Position" on Robot Connections screen.

The problem is human error, it is possible to forget to select "Get position" and crash the robot, which has already happened once with us.

Please advise if there is a function which automatically activates "Get Position" first every time "Run" is selected before running a program on the robot? Because this is required anyway before running a program on the robot it makes sense to me that it should happen automatically? 

If not, would it be possible to add such a function to RoboDK software? anything possible to prevent human error is always advisable.

kind regards
Curt
#2
Hi Curt,

You could have a simple script like the following example to retrieve the robot position from the real robot and update it in the simulation.

Example:

Code:
from robolink import *
RDK = Robolink()
robot = RDK.Item('',ITEM_TYPE_ROBOT)
if robot.Connect() > 0:
   robot.Joints()
else:
   raise Exception("Unable to connect to robot")
#3
(12-14-2020, 04:45 PM)Albert Wrote: Hi Curt,

You could have a simple script like the following example to retrieve the robot position from the real robot and update it in the simulation.

Example:

Code:
from robolink import *
RDK = Robolink()
robot = RDK.Item('',ITEM_TYPE_ROBOT)
if robot.Connect() > 0:
   robot.Joints()
else:
   raise Exception("Unable to connect to robot")

Hi Albert,

Thanks, but where do I copy this script to?

Kind regards
Curt
#4
Hi Curt,

Just create a new python macro and copy the content there.
Follow this link for more details:
https://robodk.com/doc/en/RoboDK-API.html#RoboDKAPI

Jeremy
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel


#5
Thanks Jeremy

Just a quick question before I start studying Python macros and API on the link you have sent me:

I need the "Get position" macro to affect every program that I run automatically without having to include it manually in each main program created. 

Is this possible by adding the "Get Position" script, as supplied above in the previous reply, to the post processor script?

Curt
#6
Hi Curt,

If, as you said in the first post, you are using the "Run on robot" and the "Connections screen", it doesn't go through the post-processor.
Post-processor only affects generated .src files.

In your case, you could simply create the python macro.
1 - "Main menu"->"Program"->"Add Python Program"
2 - Station tree -> You should see a python macro -> Rename it to "Get_Position"
3 - "Main menu" -> "Tools" -> "Options" -> "Python" -> Make sure Python 37 is selected in the first text box and VScodium in the second one
4 - Right-Click it -> "Edit python script" -> VSCodium window should appear
5 - Delete everything and paste Albert's code
6 - Save and close
7 - Add the program "Get_Position" to your machining project in "Program Event" -> "Program start" (you can set it as a default value for all future program in "Tools"->"Options"->"CAM"->"Program Events")

Hope it helps.
Jeremy
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel


#7
Hi Jeremy

In the meantime, I have created a "Get_Position" macro which I opened in RoboDK for offline programming.

My intention was to create a main program which would call the "Get_Position" macro first before any other programs. 

However, when trying to "generate a program" from the Python macro, an Attribute Error appears.

Herewith a screenshot of the error and the Python code:
   

Please advise

Kind regards
Curt
#8
Hi Curt,

Python is a Cap sensitive language, meaning you need to respect the letter capitalization.
You should use a capital C for "Connect" at line 17 and a capital J for "Joints" at line 18.

You could have just copy-pasted the code Albert sent you an avoid the typo ;).

Jeremy
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel


  




Users browsing this thread:
1 Guest(s)