机器人码垛操作
对机器人码垛操作步骤
1、获得机器人对象getRobot()
2、将机器人输出信号设置为零SignalMapOut,
3、获取传感器输送带findComponent("Sensor Conveyor")对象
4、获得输送带输入的托盘ComponentChildren[0]
5、获得托盘上的物件pallet.ChildComponents
6、从托盘上取件pickFromPallet(pallet)注意pickFromPallet(pallet)是不按顺序取件,按顺序取件需要修改为robot.pickFromPallet(pallet,InversedOrder=True)
7、获得放置的传输带对象findComponent("Sensor Conveyor #2")
8、放置货物place(conveyorOut)
from vcScript import *
from vcHelpers.Robot2 import *
def OnRun():
app=getApplication()
robot=getRobot(app.findComponent("GenericRobot"))
while app.Simulation.IsRunning==True:#重复搬运动作
#stop pallet at sensor
while robot.SignalMapIn.input(100)!= True:
delay(0.1)
robot.SignalMapOut.output(100,False)#这一句话让托盘停止
#get parts
conveyorIn=app.findComponent("Sensor Conveyor")
pallet=conveyorIn.ComponentChildren[0]
parts=pallet.ChildComponents
conveyorOut=app.findComponent("Sensor Conveyor #2")
for part in parts:#while part in parts 时出错,part没有定义,那么for 语句是在条件中定义的
#pick part
robot.pickFromPallet(pallet,Approach=300,InversedOrder=True)#Approach=300提高物件高度
#place part
robot.place(conveyorOut)
#start path of pallet
robot.SignalMapOut.output(100,True)
#wait for pallet to leave path 没有这句话软件就崩溃了
while pallet in conveyorIn.ComponentChildren:
delay(0.1)
翻译由网淘巴完成,转载必须标明出处:https://www.wtao8.com/post/5.html