案例/模板说明 ============================ **请注意模板函数并不能直接运行,请一定根据项目现场环境和流程需求进行修改** CartMove模板 ++++++++++++++++++++++++++++++++ 以下为机械臂主控CartMove模板程序,注意对工控机返回的 error_code 进行判断。 CartMove基本模板: XYZCARTBASIC.prg .. code-block:: ' ' Title "XYZ CartMove Basic Template" ' ' '------------------------------ ' init:初始化变量+连接 '------------------------------ #Include "XYZUTILS" Def Act 3, M_Err > 0 GoSub *LSYSERR Act 3 = 1 ' xyzInitParams() xyzConnect("192.168.0.10",11111) ' 服务器IP地址和端口号 ' '------------------------------ ' work flow:以下为主要工作区间 '------------------------------ ' ' 切换 flow ' M1 = xyzSwitchFlow("cart_basic.t") If M1 <> 0 Then Hlt ' ' 切换 item ' M1 = xyzSwitchItem(0, "item1") If M1 <> 0 Then Hlt ' ' DO初始化,并运行到Home点 M_Out(10) = 0 Mov JHome ' ' ' ' 如果项目是眼在手上,则设置为1,否则设置为0 MIsEyeInHand = 1 ' ' *LOOP ' ' send scan pose if in case of eye-in-hand ' If MIsEyeInHand = 1 Then ' 如果是眼在手上,则 ' 运动到拍照点并发送拍照位姿 Mvs PScanPose M1 = xyzSendCurrentCartPose() If M1 <> 0 Then Hlt EndIf ' ' 拍照并获取抓取点 ' M1 = xyzCalculateGraspPose(0) If M1 <> 0 Then Hlt ' check grasp pose num If M_01# < 1 Then ' no grasp pose, continue requesting Dly 5 GoTo *LOOP EndIf ' ' 运动到抓取点 ' Mvs P_00 M_Out(10) = 1 ' ' 运动到示教好的放置点 ' Mvs PPlacePose M_Out(10) = 0 ' GoTo *LOOP ' ' '------------------------------ ' 系统报错处理 '------------------------------ *LSYSERR: ' ' system error ' Hlt End CartMove二次定位模板: XYZCARTREPO.prg .. code-block:: ' ' Title "XYZ CartMove Repositioning Template" ' ' '------------------------------ ' init:初始化变量+连接 '------------------------------ #Include "XYZUTILS" Def Act 3, M_Err > 0 GoSub *LSYSERR Act 3 = 1 ' xyzInitParams() xyzConnect("192.168.0.10",11111) ' 服务器IP地址和端口号 ' '------------------------------ ' work flow:以下为主要工作区间 '------------------------------ ' ' 切换 flow ' M1 = xyzSwitchFlow("cart_repo.t") If M1 <> 0 Then Hlt ' ' M_Out(10) = 0 ' pick board M_Out(11) = 0 ' pick item Mov JHome ' ' 切换 item ' M1 = xyzSwitchItem(0, "item1") If M1 <> 0 Then Hlt ' ' 对工件粗定位拍照 ' M1 = xyzReqGraspPose(0) If M1 <> 0 Then Hlt MToken = M_00# ' ' *LOOP ' ' 获取工件粗定位坐标值 ' M1 = xyzGetGraspPose(MToken) If M1 <> 0 Then Hlt ' ' 如果识别不到工件,表示工作抓完,则抓取隔板 ' If M_01# < 1 Then ' check grasp_pose_num ' ' 切换 item 到隔板 ' M1 = xyzSwitchItem(0, "board") If M1 <> 0 Then Hlt ' ' 拍隔板 ' M1 = xyzCalculateGraspPose(0) If M1 <> 0 Then Hlt If M_01# < 1 Then Hlt ' check grasp_pose_num ' ' 抓隔板 ' Mvs P_00 M_Out(10) = 1 ' ' 放置隔板 ' Mvs PBoardPlacePose M_Out(10) = 0 ' ' 切换item到工件 ' M1 = xyzSwitchItem(0, "item1") If M1 <> 0 Then Hlt ' ' 对工件粗定位拍照 ' M1 = xyzReqGraspPose(0) If M1 <> 0 Then Hlt MToken = M_00# ' GoTo *LOOP ' EndIf ' ' ' 二次定位 ' ' ' 运动到粗定位点 ' Mvs P_00 ' ' 发送拍照位姿 ' M1 = xyzSendCurrentCartPose() If M1 <> 0 Then Hlt ' ' 切换 item ' M1 = xyzSwitchItem(1, "item1") If M1 <> 0 Then Hlt ' ' 对工件进行精定位拍照 ' M1 = xyzCalculateGraspPose(1) If M1 <> 0 Then Hlt If M_01# < 1 Then Hlt ' check grasp_pose_num ' ' ' 抓取工件 ' Mvs P_00 M_Out(11) = 1 ' ' 放置工件 Mvs PItemPlacePose M_Out(11) = 0 ' ' 切换 item ' M1 = xyzSwitchItem(0, "item1") If M1 <> 0 Then Hlt ' ' 对工件进行粗定位拍照 ' M1 = xyzReqGraspPose(0) If M1 <> 0 Then Hlt MToken = M_00# ' ' GoTo *LOOP ' ' '------------------------------ ' 报错处理 '------------------------------ *LSYSERR: ' ' system error ' Hlt End TrajMove模板 ++++++++++++++++++++++++++++++++ 同步模板:XYZTRAJSYNC.prg .. code-block:: ' ' Title "XYZ TrajMove Sync Template" ' ' '------------------------------ ' init:初始化变量+连接 '------------------------------ #Include "XYZUTILS" Def Act 3, M_Err > 0 GoSub *LSYSERR Act 3 = 1 ' xyzInitParams() xyzConnect("192.168.0.10",11111) ' 服务器IP地址和端口号 ' '------------------------------ ' work flow:以下为主要工作区间 '------------------------------ ' ' 切换 flow ' M1 = xyzSwitchFlow("traj_sync.t") If M1 <> 0 Then Hlt ' ' 切换 item ' M1 = xyzSwitchItem(0, "item1") If M1 <> 0 Then Hlt ' ' M_Out(10) = 0 Mov JHome ' ' *LOOP ' ' 请求pick place规划 ' M1 = xyzReqPickPlace(0) If M1 <> 0 Then Hlt ' ' 获取取料入框轨迹 ' M1 = xyzGetPickIn(0) If M1 <> 0 Then Hlt If M_05# < 1 Then GoTo *CLEAREXIT EndIf ' 执行取料入框轨迹 ' 50表示走轨迹时候的圆滑半径,单位是mm xyzExecPickInTraj(50) M_Out(10) = 1 ' ' 获取取料出框轨迹 ' M1 = xyzGetPickOut(0) If M1 <> 0 Then Hlt ' 执行取料出框轨迹 xyzExecPickOutTraj(50) ' ' 获取放料入框轨迹 ' M1 = xyzGetPlaceIn(0) If M1 <> 0 Then Hlt ' 执行放料入框轨迹 xyzExecTraj(50) M_Out(10) = 0 ' ' 获取放料出框轨迹 ' M1 = xyzGetPlaceOut(0) If M1 <> 0 Then Hlt ' 执行放料出框轨迹 xyzExecTraj(50) ' ' GoTo *LOOP ' '------------------------------ ' normal exit '------------------------------ ' *CLEAREXIT ' work done:tote has beeen cleared Hlt End ' ' '------------------------------ ' system error '------------------------------ *LSYSERR: ' ' system error ' Hlt End 异步模板:XYZTRAJASYNC.prg .. code-block:: ' ' Title "XYZ TrajMove Async Template" ' ' '------------------------------ ' init:初始化变量+连接 '------------------------------ #Include "XYZUTILS" Def Act 3, M_Err > 0 GoSub *LSYSERR Act 3 = 1 ' xyzInitParams() xyzConnect("192.168.0.10",11111) ' 服务器IP地址和端口号 ' '------------------------------ ' work flow:以下为主要工作区间 '------------------------------ ' ' 切换 flow ' M1 = xyzSwitchFlow("traj_async.t") If M1 <> 0 Then Hlt ' ' 切换 item ' M1 = xyzSwitchItem(0, "item1") If M1 <> 0 Then Hlt ' ' M_Out(10) = 0 Mov JHome ' ' ' 请求pick place规划 ' M1 = xyzReqPickPlace(0) If M1 <> 0 Then Hlt ' ' *LOOP ' ' 获取取料入框轨迹 ' M1 = xyzGetPickIn(0) If M1 <> 0 Then Hlt If M_05# < 1 Then GoTo *CLEAREXIT EndIf ' 执行取料入框轨迹 ' 50表示走轨迹时候的圆滑半径,单位是mm xyzExecPickInTraj(50) M_Out(10) = 1 ' ' 获取取料出框轨迹 ' M1 = xyzGetPickOut(0) If M1 <> 0 Then Hlt ' 执行取料出框轨迹 xyzExecPickOutTraj(50) ' ' 提前请求下一次的请求pick place规划 ' M1 = xyzReqPickPlace(0) If M1 <> 0 Then Hlt ' ' 获取放料入框轨迹 ' M1 = xyzGetPlaceIn(0) If M1 <> 0 Then Hlt ' 执行放料入框轨迹 xyzExecTraj(50) M_Out(10) = 0 ' ' 获取放料出框轨迹 ' M1 = xyzGetPlaceOut(0) If M1 <> 0 Then Hlt ' 执行放料出框轨迹 xyzExecTraj(50) ' ' GoTo *LOOP ' '------------------------------ ' normal exit '------------------------------ ' *CLEAREXIT ' work done:tote has beeen cleared Hlt End ' ' '------------------------------ ' system error '------------------------------ *LSYSERR: ' ' system error ' Hlt End