Hey Bad, thanks for the info. This is a easy way to mount the tool. I have incorporated it into a python script which moves the mountplate to the gripper, and then activates the output (OUT34). This worked, but after a few tries and debugging VC crashed. Now my code doesn’t work anymore. The robot moves to the gripper, sets the output on True but it doesn’t mount the gripper to the mountplate.
Any idea what the problem is?
My debug code:
from vcScript import *
from vcHelpers.Robot2 import *
import vcMatrix
comp = getComponent()
controller = comp.getBehaviour('RobotController')
executor = comp.getBehaviour('Executor')
app = getApplication()
sim = getSimulation()
def goToTarget(x, y, z, base="main_base", tool=None):
#print("🔄 Bewegen naar: X=%.1f Y=%.1f Z=%.1f | Base: %s | Tool: %s" % (x, y, z, base, tool))
# Check geldige base
base_names = [b.Name for b in controller.Bases]
if base not in base_names:
print("❌ Ongeldige base:", base)
return
# Check geldige tool
tool_names = [t.Name for t in controller.Tools]
if tool and tool not in tool_names:
print("❌ Ongeldige tool:", tool)
return
m = vcMatrix.new()
m.translateRel(x, y, z)
m.setWPR(180, 0, 0)
motionTarget = controller.createTarget()
motionTarget.TargetMode = VC_MOTIONTARGET_TM_NORMAL
motionTarget.BaseName = base
motionTarget.MotionType = VC_MOTIONTARGET_MT_LINEAR
motionTarget.RobotConfig = 0
motionTarget.Target = m
if tool:
motionTarget.ToolName = tool
try:
controller.moveTo(motionTarget)
except Exception as e:
print("❌ Beweging mislukt:", e)
def OnRun():
#sim.reset()
robot = getRobot(comp)
print("Tools:", [t.Name for t in controller.Tools])
print("Bases:", [b.Name for b in controller.Bases])
for i, tool in enumerate(robot.Tools):
if tool.Name == "Tool1":
robot.ActiveTool = i
break
tool = robot.ActiveTool
tools = robot.Tools
print tools[tool].Name
for i in range(33, 49):
executor.setOutput(i, False)
goToTarget(977.461,-411.685, 828.483, base="main_base", tool="Tool1")
executor.setOutput(35, True)
for i, tool in enumerate(robot.Tools):
if tool.Name == "Tool3":
robot.ActiveTool = i
break
tool = robot.ActiveTool
delay(1.0)
goToTarget(1278.557, 365.182, 0, base="grasp_base", tool="Tool3")
goToTarget(2484.207, -417.062, 979.1, base="main_base", tool="Tool3")
executor.setOutput(1, True)
goToTarget(2484.207, -417.062, 1050, base="main_base", tool="Tool3")
def OnReset():
return
type or paste code here