您好!欢迎光临工博士商城

ABB机器人配件专营店

产品:37    
联系我们
您当前的位置:首页 » 新闻中心 » ABB机器人与视觉软件Halcon通讯
产品分类
新闻中心
ABB机器人与视觉软件Halcon通讯
发布时间:2019-11-06        浏览次数:1253        返回列表
 ABB机器人与视觉软件Halcon通讯


声明:本媒体部分图片、文章来源于网络,

版权归原作者所有,如有侵权,请与我联系删除。



1. HALCON 为现在主流工业视觉处理软件,提供各类视觉识别算子,提供不同软件接口,也可通过HALCON HDevelop进行编程处理,如下图

ABB机器人与视觉软件Halcon通讯


2. 在视觉处理前后,通常都需要和外设(例如ABB机器人)进行通讯,此处举例socket通讯

3. 在HALCON的HELP中,提供了详细的示例代码。

4. 此处举例HALCON作为socket通讯的server,机器人作为socket通讯的client

5. 在HALCON创建如下代码

Protocol := 'TCP4'
Timeout := 10.0
*
* 创建一个监听,设置端口为4660,超时为10s
open_socket_accept (4660, ['protocol','timeout'], [Protocol,Timeout], AcceptingSocket)
* Strip AddressFamily from Protocl
tuple_regexp_match (Protocol, 'TCP|HALCON', BaseProtocol)
if (BaseProtocol == 'TCP' or BaseProtocol == 'HALCON')
* Wait for an incoming connection, use the timeout of the
* AcceptingSocket
dev_error_var (Error, 1)
dev_set_check ('~give_error')
OpenStatus := 5
while (OpenStatus != 2)
socket_accept_connect (AcceptingSocket, 'auto', Socket)
OpenStatus := Error
endwhile
dev_set_check ('give_error')
* Set the same timeout on the newly created socket
set_socket_param (Socket, 'timeout', Timeout)
else
* UDP sockets do not need an accept()
Socket := AcceptingSocket
endif
get_socket_param (Socket, 'address_info', Address)
*
Answer := []
while (Answer != 'End')
receive_data (Socket, 'z', Answer, From)
To:=[]
Data:='received '+Answer
Format := 'z'
send_data (Socket, Format, Data, To)
endwhile
stop ()
close_socket (Socket)
close_socket (AcceptingSocket)


6. 在ABB机器人端创建如下代码

PROC main1()
VAR robtarget ptmp;
VAR string send_string;
SocketClose socket1;
SocketCreate socket1;
SocketConnect socket1,"127.0.0.1",4660\Time:=WAIT_MAX;
SocketSend socket1\Str:="Hello Halcon"+" "+CTime();
SocketReceive socket1\Str:=received_string\Time:=WAIT_MAX;
TPWrite "Server wrote - "+received_string;
SocketSend socket1\Str:="End";
SocketReceive socket1\Str:=received_string\Time:=WAIT_MAX;
TPWrite "Server wrote - "+received_string;
received_string:="";

ERROR
SocketClose socket1;


7. 先运行HALCON的server,再运行机器人端的client程序。

HALCON的server
  数据发送回机器人

8. HALCON会先接受
ABB机器人发来的Hello Halcon,再将接受到的数据发送回ABB机器人






 

联系热线:15026710082   联系人:姚国利 联系地址:上海市宝山区富联一路98弄6号

技术和报价服务:星期一至星期六8:00-22:00 ABB机器人配件专营店