控制箱上电;
示教器打开浏览器访问目标网址192.168.58.2;
操作员(初始用户名:operator,密码:123)
程序员(初始用户名:programmer,密码:123)
管理员(初始用户名:admin,密码:123)
4.2.1. 控制区
备注
名称:使能按钮
作用:使能机器人
备注
名称:开始按钮
作用:上传并开始运行示教程序
备注
名称:停止按钮
作用:停止当前示教程序运行
备注
名称:暂停/恢复按钮
作用:暂停和恢复当前示教程序
--*********RVS_SE全自动标定与机器人抓包程序Demo法兰盘**********--
--*********程序编辑**纪洋***************--
--*********修改日期**06.12****************--
-- 标定/抓包程序功能切换开关 1为标定 2为抓包
Mode=2
--TCP通讯参数设置
ip = "192.168.58.123"
port = 2013
--通信标定标志位
connectsun=0
-----------RVS-SE通讯协议规则-------
Triger="GET_POSE #" --拍照,1表示每次一个目标数据
Save_pose="S,0,0,0,0,0,0,0,#" --保存姿态与图片
Cal="CAPTURE #" --标定
Open_cam="O,0,0,0,0,0,0,0,#" --打开相机
Close_cam="F,0,0,0,0,0,0,0,#" --关闭相机
R1="R,0,0,0,0,0,0,1,#" -- 定义区域1
R2="R,0,0,0,0,0,0,2,#" -- 定义区域2
-----------RVS通讯协议规则-------
RVS_Get_tcp="GET_TCP X Y Z RX RY RZ#" --拍照,1表示每次一个目标数据
RVS_Cal="CAPTURE #" --标定
-------标定数据说明----------
--机器人发送的Pose格式为 X,Y,Z, RX,RY,RZ
-- 单位是 mm 角度
--Pose数据为机器人当前工具Tool 在机器人基坐标系的位姿
-------标定数据说明----------
-----机器人与APPcenter连接成功的情况下------start
--安全位置
--先移动到HOME点
point_safe={}
point_safe= GetRobotTeachingPoint("HOMESAFE")
MoveJ(point_safe[7],point_safe[8],point_safe[9],point_safe[10],point_safe[11],point_safe[12],point_safe[1],point_safe[2],point_safe[3],point_safe[4],point_safe[5],point_safe[6],point_safe[13],point_safe[14],70,point_safe[16],40,0.000,0.000,0.000,0.000,0,0,0,0,0,0,0,0)
--示教P0定义为机器人一个安全位置
--MoveCart({point_safe[1], point_safe[2], point_safe[3], point_safe[4], point_safe[5], point_safe[6]}, 14,0,30,30,100,0)
--(视觉为服务器,机器人为客户端,默认未连接)
--机器人控制器与视觉控制器建立Socket通讯
connectsun = SocketOpen(ip,port,"socket_0")
--connect0=0 --通讯连接测试信号,与connect信号 对比试验
--标定程序
if connectsun==1 then
--for var=1,10000,1 do
--<执行体>
if Mode == 1 then --标定模式
for i=1,6 do -- 示教定义16个拍照位 名称位P1-P16
point={}
rob_pos={}
Index_P="Calib"..tostring(i) --sun
--5秒内完成保存当前标定点P[i]位置的图像和位姿数据
point = GetRobotTeachingPoint(Index_P)
rob_pos[1]=point[1] --获取拍照位X
rob_pos[2]=point[2] --获取拍照位Y
rob_pos[3]=point[3] --获取拍照位Y
rob_pos[4]=point[4] --获取拍照位RX
rob_pos[5]=point[5] --获取拍照位RY
rob_pos[6]=point[6] --获取拍照位RZ
--MoveCart(rob_pos,14,0,30,30,100,0)--机器人移动到标定拍照点位置
MoveJ(point[7],point[8],point[9],point[10],point[11],point[12],point[1],point[2],point[3],point[4],point[5],point[6],point[13],point[14],70,point[16],80,0.000,0.000,0.000,0.000,0,0,0,0,0,0,0,0)
WaitMs(2000) --机器人停稳
x,y,z,rx,ry,rz = GetActualTCPPose()
--WaitMs(500)
--数值转字符 数据格式为 "P,x,y,z,rx,ry,rz,0,#"
Tcp_pose = "ROBOT_TCP".." "..tostring(x/1000).." "..tostring(y/1000).." "..tostring(z/1000).." "..tostring(math.rad(rx)).." "..tostring(math.rad(ry)).." "..tostring(math.rad(rz)).."#"
--发送TCP_Pose至相机控制器
SocketSendString(Tcp_pose,"socket_0",500)
WaitMs(1000)
SocketSendString(RVS_Cal,"socket_0",100)
--2秒内RVS_SE软件界面刷新机器人返回当前位姿数据显示
--发送保存当前位姿至相机控制器
WaitMs(3000)
end
--标定完成后重新移动到安全点-----------
MoveJ(point_safe[7],point_safe[8],point_safe[9],point_safe[10],point_safe[11],point_safe[12],point_safe[1],point_safe[2],point_safe[3],point_safe[4],point_safe[5],point_safe[6],point_safe[13],point_safe[14],70,point_safe[16],40,0.000,0.000,0.000,0.000,0,0,0,0,0,0,0,0)
--标定完成后重新移动到安全点sunT-----------
--MoveCart({sunT[1], sunT[2], sunT[3], sunT[4], sunT[5], sunT[6]}, 2,0,30,90,100,0)
elseif Mode == 2 then
--获取拍照位,到达拍照位置
pointCapture={}
rob_posCapture={}
--num_p="P"..tostring(i)
pointCapture = GetRobotTeachingPoint("CapturePose")
rob_posCapture[1]=pointCapture[1]
rob_posCapture[2]=pointCapture[2]
rob_posCapture[3]=pointCapture[3]
rob_posCapture[4]=pointCapture[4]
rob_posCapture[5]=pointCapture[5]
rob_posCapture[6]=pointCapture[6]
MoveJ(pointCapture[7],pointCapture[8],pointCapture[9],pointCapture[10],pointCapture[11],pointCapture[12],pointCapture[1],pointCapture[2],pointCapture[3],pointCapture[4],pointCapture[5],pointCapture[6],pointCapture[13],pointCapture[14],70,pointCapture[16],80,0.000,0.000,0.000,0.000,0,0,0,0,0,0,0,0)
-- MoveCart({pointCapture[1], pointCapture[2], pointCapture[3], pointCapture[4], pointCapture[5], pointCapture[6]},0,0,30,30,100,0)
-- MoveCart(rob_posCapture,14,0,30,30,100,0)
if connectsun == 1 then
--获取机械臂法兰中心点位姿,位置单位[mm],姿态单位[°]
--x,y,z,rx,ry,rz = GetActualToolFlangePose()
x,y,z,rx,ry,rz = GetActualTCPPose()
--数值转字符
str_tcp = "ROBOT_TCP".." "..tostring(x/1000).." "..tostring(y/1000).." "..tostring(z/1000).." "..tostring(math.rad(rx)).." "..tostring(math.rad(ry)).." "..tostring(math.rad(rz)).."\n"
--str_tcp = "ROBOT_TCP".." "..tostring(x).." "..tostring(y)..
--" "..tostring(z).." "..tostring(rx).." "..tostring(ry).." "
--..tostring(rz).."\n"
--发送字符串至相机控制器
SocketSendString(str_tcp,"socket_0",0)
--获取相机控制器应答
rcv_tcp = SocketReadString("socket_0",5000)
--检查应答
--if rcv_tcp == "ROBOT_TCP\n" then
--机器人控制柜与相机控制器断开Socket通讯
--SocketClose("socket_0")
--end
end
WaitMs(200)
--关节
-- if connectsun == 1 then
--获取机械臂关节位置,单位[°]
-- j1,j2,j3,j4,j5,j6 = GetActualJointPosRadian()
-- --j1,j2,j3,j4,j5,j6 = GetActualJointPosDegree()
--数值转字符
-- str_jnt = "ROBOT_JOINTS".." "..tostring(j1).." "..tostring(j2).." "..tostring(j3).." "..tostring(j4).." "..tostring(j5).." "..tostring(j6).."\n"
--发送字符串至相机控制器
-- SocketSendString(str_jnt,"socket_0",0)
--获取相机控制器应答
--rcv_jnt = SocketReadString("socket_0",5000)
--检查应答
--if rcv_jnt == "ROBOT_JOINTS\n" then
--机器人控制柜与相机控制器断开Socket通讯
--SocketClose("socket_0")
--end
--end
--WaitMs(200)
--拍照
if connectsun == 1 then
--发送拍照字符串至相机控制器
SocketSendString("CAPTURE #","socket_0",0)
--获取相机控制器应答
WaitMs(1000)
rcv = SocketReadString("socket_0",0)
RegisterVar("string", "rcv")
--检查应答,RVS返回格式为x y z a b c 1,共61位
pos1 = {0,0,0,0,0,0,0}
RVSPOSE={0,0,0,0,0,0}
pos = str_split(rcv,",")
if type(pos) == "table" then
pos1[1] = tonumber(pos[1])
pos1[2] = tonumber(pos[2])
pos1[3] = tonumber(pos[3])
pos1[4] = tonumber(pos[4])
pos1[5] = tonumber(pos[5])
pos1[6] = tonumber(pos[6])
--isTrue = tonumber(pos[7])
end
RVSPOSE[1]=pos1[1]
RVSPOSE[2]=pos1[2]
RVSPOSE[3]=pos1[3]
RVSPOSE[4]=pos1[4]
RVSPOSE[5]=pos1[5]
RVSPOSE[6]=pos1[6]
MoveCart({RVSPOSE[1], RVSPOSE[2], RVSPOSE[3], RVSPOSE[4], RVSPOSE[5], RVSPOSE[6]},3,0,30,30,100,0)
-- MoveCart(RVSPOSE,14,0,30,30,100,0)
--机器人走视觉返回位置
WaitMs(5000)
SocketSendString("OK","socket_0",0)
end
end
end