Hello I have created a Python script to move a robot base when the script is called.
The script works fine when I give afixed numbers for the position matrix of the base.
But I want to move the base using variables (real signals) added in robot behavior and receive the values through OPC-UA connection. When I put variables instead of fixed numbers the script does not work.
Here is the script:
from vcScript import *
from vcHelpers.Robot2 import *
from vcMatrix import *
robot = getRobot()
base = robot.Bases[31]
comp = getComponent()
move_base_signal = comp.findBehaviour(“MoveBaseBooleanSignal”)
comp_move_signal = comp.findBehaviour(“CompMoveSignal”)
x_signal = comp.findBehaviour(“XRealSignal”) #signals received from opc-ua server
y_signal = comp.findBehaviour(“YRealSignal”)
z_signal = comp.findBehaviour(“ZRealSignal”)
def OnSignal( signal ):
if signal == move_base_signal:
if signal.Value == True:
movebase()
def movebase():
mtx = base.PositionMatrix
vec = mtx.P
vec.X = x_signal
#when I put a number it works fine (example: vec.X = 300) but as a variable it gives error
vec.Y = y_signal
vec.Z = z_signal
mtx.P = vec
base.PositionMatrix = mtx
getApplication().render()