[IMPLEMENTED] Adding variables

Is it possible to add variable in here like this? If yes then how?
In your example com.ur.urcap.examples.scriptfunction you have done it with functions.

I want to dynamically change a certain variable while the robot is running, that should be possible right?
cheers.

2 Likes

Currently, it is only possible to show PolyScope generated variables (Installation variables and by Assignment) in the “Variables” list.

I believe using functions to read and write certain variables would be a more robust way to access your variables, instead of just overwriting another variable. Especially from a “variable ownership” point of view. So it would be my recommendation to create a “get” and “set” function in the dropdown list, to be able to access your variables.

1 Like

Hi @jbm,
I was looking into this also. Where do I have to look to add installation variables to that list? Is there an example around?
Thanks!

Simply go to the Installation tab, and then Variables.

Oh I see, thanks!
Can that be done within a URCap, like it is with functions in the “scriptfunction” sample? I mean, can a URCap generate assignments that add the assigned variables to the list from the installation node? (something like a VariableModel)

1 Like

Check out the new 3.5 release, this feature have now been implemented.
Release of 3.5

1 Like

Hi @jbm
I have a question regarding this: As I read your response here, it is possible to create new variables through the installation contribution of a URCap. I have been trying to do exactly that, but ended up stopping since it is stated in the “working_with_variables.pdf” that: “Note that variables should not be used in an
URCap installation node contribution, since it is a programming construct only
used at runtime of a robot program.” (pg. 3, sec. 2)
How is it possible to create and assign variables from the installation contribution, like @jubeira ask?

In the installation contribution part of your URCap you add and remove functions that can be used to assign variables during run time. Here is an example of how to add/remove functions to the function model. image

The functions will need to be within the generateScript(ScriptWriter writer) portion of the URCap installation contribution example: image

Adding the function to the function model would then be: image

Now within the program tree of the UR you can assign a variable from the function drop down menu example:


Sorry for long post but hope this helps you out!

2 Likes

What if I want to add a function that returns something depending on the model?
i.e. I have a series of positions set in the installation node and I want to get position N.
I can addFunction("get_position","index") but then I cannot simply define a static script like the example, I need to examine the value of "index" at runtime and return the corresponding position stored in the model.
Edit oh, and throw an error if the index is out of range.

I started writing a program node for that, but it has the same problem: the generateScript method is called only once so I need a way to inspect the current value of the variables and get the position from the installation node depending on that and I could find no examples on how to do that.

I think that what I want to do is impossible. Oh, well, I’ll go on with the band-aid solution I’m using now.

In case somebody is interested, I programmed an xmlrpc server in my urcap and the urscript function simply uses an xmlrpc client to obtain the indexed pose from the installation node.
I would have preferred to be able to extend the urscript interpreter with a real function but this is working now.
BTW: I didn’t like java too much before, now that I’ve been forced to program in it I hate it with a passion.

2 Likes