Manipulating Planes in script

I have a Plane setup, Tray_1
I can adjust values eg Tray_1 = Tray_1[2] + value,
this works as expected.

so when I want to set it back to its original values
I would have thought
Tray_1 = Tray_1_const
would work

But No!

Can anyone explain why?

If I use it as an assignment in the program it works so why not in a script file?

Your plane, Tray_1, is a pose variable. I am not sure how you got the first part, Tray_1 = Tray_1[2] + value. Maybe the Assignment node creates a new variable of the same as your plane, but it is a float type. If Tray_1 and Tray_1_const are both pose the code will work.

FYI I’m using a UR5e with 5.11 version software

Tray_1 is a Plane created using the features menu in installation.
Which is a and thus so can be modified, Hence Tray_1 = Tray_1[2] + value (value is an arbitrary No) which works as expected and adjusts the Z value of the plane.

as I understand it, when Tray_1 is created the Robot also creates a Tray_1_const which has the exactly the same values as Tray_1. However as its a constant it cannot be modified!

as indicated in my original post

Tray_1 = Tray_1_const works fine when its used in the main body of the program in an assignment,

So my question is why doesn’t it work from a Script file?
are values not accessible in a script file? (I find that hard to believe)

From my experience, the Const version of the feature is not global. You can actually test this by manually typing Tray_1_const into your assignment node and watch it fail. For whatever reason, that const variable HAS to be selected from the dropdown menu. You therefore must pass the const version into your script via a function call and reassign your plane that way, if you want to do it all with script. I haven’t done it myself, but it might be interesting to see the script polyscope generates when you do the assignment node, since it works there for some reason.

He means if you are changing Tray_1 which is a Pose variable into a float variable with that Tray_1 (Pose) = Tray_1[2] (float) + value (assuming float). If you are trying to change just the z value it would be Tray_1[2] = Tray_1[2] + value. Also eric is right where you should choose the constant variable from the drop down box if you are using the Script node. If you are manually typing the script from your own URCap then you would need to pull the Pose data from the installation node. I believe the UR side doesn’t actually have a variable in the script made for the const but places the original pose there instead.

For Instance your variable Tray_1 would show up in the Script as “Tray_1” so if you did Tray_1 = Tray_1 that is exactly what you would see in the Script. If you do Tray_1 = Tray_1_const though by selecting the const from the dropdown box, you would actually get Tray_1 = p[some_data] and not Tray_1 = Tray_1_const. So when you type in Tray_1_const it does not know what variable you are referencing.

I have attached an image with an example showing this. On the left is the program when the first Plane_1_const I selected with the Drop down and the second one I physically typed in.

1 Like

The reason this does not work from a script file (or typing in the logical script commands) :
Tray_1 = Tray_1_const
is because Tray_1_const does not really exist as a truly global variable. It ONLY exists in the mind of the Polyscope editor. When you select it from a dropdown in the expression editor of polyscope the polyscope editor will pull in the actual pose value for Tray_1 (as taught in the Installation) and substitute this for the underlying script it generates.

The workaround would be to assign Tray_1_const to global variable in polyscope “before start” section.

I did something similar
I created a Variable Tray_1_Mstr and in the Before start
Tray_1_Mstr := Tray_1_const

then in my Script file when I need to set it back to its original value

Tray_1 = Tray_1_Mstr

Its a work around but it’ll have to do!

I just wanted to try and keep the amount of variables to a minimum to try and conserve memory.