VelL(20)
AccL(20)
SpeedFactor(20)
MovL(P1)
x=50
y=50
r=15
function string.split(str,delimiter)
if str==nil or str=='' or delimiter==nil then
return nil
end
local result = {}
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result,match)
end
return result
end
function Connect(isServer,ip,prot)
::Cab_PC::
err, socket = TCPCreate(isServer,ip,prot)
print("err=",err)
Wait(100)
if err ~= 0 then
print("创建链接失败,重新创建链接...\r\n")
Wait(100)
goto Cab_PC
end
err = TCPStart(socket,0)
if err ~= 0 then
print("握手失败,重新发起...\r\n")
TCPDestroy(socket)
Wait(100)
goto Cab_PC
end
print("握手成功...\r\n")
end
function ReceiveData()
local DataArrayS={}
err,Recbuf=TCPRead(socket,0,"string")
if err==0 and Recbuf~="" then
DataArrayS=string.split(Recbuf,",")
else
Connect(false,"192.168.1.90",8604)
end
return DataArrayS
end
function SendData(socket,Str)
if Str~="" then
err=TCPWrite(socket, Str)
print("err=",err)
if err==0 then
print("Send Data OK")
else
Connect(false,"192.168.1.90",8604)
print("Send Data NG")
end
end
end
Connect(false,"192.168.1.90",8604)
print("hello world")
MovL(P1,{user=0,tool=1})
Wait(500)
currentPose_1=GetPose(0,1)
Wait(300)
print("currentPose_1=",currentPose_1)
Test1="A"..","..tonumber(currentPose_1.pose[1])..","..tonumber(currentPose_1.pose[2])..","..tonumber(currentPose_1.pose[6])
SendData(socket,Test1)
Wait(1000)
RelMovLUser({0,y,0,0,0,0})
Wait(500)
currentPose_2=GetPose(0,1)
Wait(300)
print("currentPose_2=",currentPose_2)
Test2="A"..","..tonumber(currentPose_2.pose[1])..","..tonumber(currentPose_2.pose[2])..","..tonumber(currentPose_2.pose[6])
SendData(socket,Test2)
Wait(1000)
RelMovLUser({0,y,0,0,0,0})
Wait(500)
currentPose_3=GetPose(0,1)
Wait(300)
print("currentPose_3=",currentPose_3)
Test3="A"..","..tonumber(currentPose_3.pose[1])..","..tonumber(currentPose_3.pose[2])..","..tonumber(currentPose_3.pose[6])
SendData(socket,Test3)
Wait(1000)