保证以下两点,就可以通信
lcm::LCM lcm("udpm://239.255.76.67:7667?ttl=1");
参考LCM通信库的安装及使用
其中重要的为每台机器A,B,C,…都使能UDP多播
$ ifconfig #查看用于通讯的网卡设备名字
我的电脑是这样,用的是有线网络,那就是eno2
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:d8:61:a4:9e:85 brd ff:ff:ff:ff:ff:ff
inet 10.1.1.140/24 brd 10.1.1.255 scope global noprefixroute eno2
valid_lft forever preferred_lft forever
inet6 fd00:3c6a:4854:3f3::1000/128 scope global dynamic noprefixroute
valid_lft 76819sec preferred_lft 76819sec
inet6 fd00:3c6a:4854:3f3:e87b:4245:de46:e7e6/64 scope global temporary dynamic
valid_lft 85971sec preferred_lft 13971sec
inet6 fd00:3c6a:4854:3f3:6e3e:2e18:d8d2:a888/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 85971sec preferred_lft 13971sec
inet6 fe80::6c21:fd94:436e:bc7a/64 scope link noprefixroute
valid_lft forever preferred_lft forever
sudo ifconfig eno2 multicast
sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev eno2
在进行多设备通讯时,需要将ttl设置为大于0的值,LCM默认ttl=0,默认只在本地回环进行通讯。同时,需要target IP 设定为支持组播(Multicast)的IP 分段:(224.0.0.0-239.255.255.255)