ROS分布式多机通信(ubuntu主从机配置)

1.确定主机及从机的IP地址(主从机需要在同一个网段)

查询计算机IP

ifconfig
xf@xf-Vostro-3670:~$ ifconfig 
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.170  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::219d:a81b:fc74:9ea2  prefixlen 64  scopeid 0x20<link>
        ether 8c:ec:4b:cc:f5:8d  txqueuelen 1000  (以太网)
        RX packets 406729  bytes 338826607 (338.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 256156  bytes 50472774 (50.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (本地环回)
        RX packets 294917  bytes 22558451 (22.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 294917  bytes 22558451 (22.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 测试主机IP为192.168.1.170,使用时需要改为自己的主机IP地址

xf@xf-ThinkPad-E15-Gen-2:~$ ifconfig 
enp2s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 38:f3:ab:b1:d3:63  txqueuelen 1000  (以太网)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (本地环回)
        RX packets 342  bytes 35461 (35.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 342  bytes 35461 (35.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.132  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::57c5:e950:74d3:e629  prefixlen 64  scopeid 0x20<link>
        ether 74:4c:a1:a6:7b:01  txqueuelen 1000  (以太网)
        RX packets 25039  bytes 4992590 (4.9 MB)
        RX errors 0  dropped 80  overruns 0  frame 0
        TX packets 3624  bytes 777491 (777.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 测试从机IP为192.168.1.132,使用时需要改为自己的从机IP地址

2.修改主机名查询静态表

sudo vi /etc/hosts

修改主机hosts

127.0.0.1       localhost
127.0.1.1       xf-Vostro-3670

192.168.1.132 xf-ThinkPad-E15-Gen-2

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

 修改从机hosts

127.0.0.1       localhost
127.0.1.1       xf-ThinkPad-E15-Gen-2

192.168.1.170 xf-Vostro-3670

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

3.修改.bashrc

主机.bashrc配置:在~/.bashrc文件最后添加

export ROS_MASTER_URI=http://192.168.1.170:11311
export ROS_HOSTNAME=192.168.1.170

从机.bashrc配置:在~/.bashrc文件最后添加

export ROS_MASTER_URI=http://192.168.1.170:11311
export ROS_HOSTNAME=192.168.1.132

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值