Home› Programming
Discussion
Back to discussions page
james77
Posts: 10 Apprentice
store variables using urscript and using it? |
161 views
|
Answered | |
/ Most recent by matthewd92
in Programming
|
3 comments |
in Programming
Short question, I've assigned variables using URscript.
ex)
c_1 = get_actual_tcp_pose()
c_3 = pose_add(c_1, p[1, 1, 0, 0, 0, 0])
so it shows me the screenshot above.
I wanted to use those variables as one of waypoints, and below is what it shows.
I could not select any of the variables, c_1 and c_3.
I thought defining variables using functions in script will store the values into the list of variables.
I'd like to know what happened, and how to fix it.
ex)
c_1 = get_actual_tcp_pose()
c_3 = pose_add(c_1, p[1, 1, 0, 0, 0, 0])

I wanted to use those variables as one of waypoints, and below is what it shows.

I thought defining variables using functions in script will store the values into the list of variables.
I'd like to know what happened, and how to fix it.
Best Answers
-
jelms Posts: 34 Handy
This is a issue of variable scoping, but I'm not a heavy user of the variables tab. If you put global in front of the script assignment it will in the variables tab, but still not be an option in the move command.
If you use the "Assignment" (under advanced) it will appear in the variables tab and be a choice for the move. Another option is to run a script file and put all your logic in there.
textmsg puts messages in the Log tab.
-
matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
Variables that are defined as script do not appear as options to choose from any variables list.If you want them to appear in the global variables pane on the right during run time you use the keyword global. Otherwise use keyword local. Anything defined at the top level of a script, outside any definitions even with the local keyword will be globally accessible to all scripts. Otherwise, anything defined as local within a definition will only be available to that function. -
matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
So another thing you can do is have your scripts return the value instead of assigning it to a variable. Then you can use the assignment node to assign that function to the variable that you create. Then you can use that anywhere you want to use a variable.That’s the only way currently to make a script result available to Polyscope nodes.