ros跨平台订阅和发布消息(ip如何设置)
ros跨平台订阅和发布消息
1.连接同一局域网
2.设置ROS_MASTER_URI
2.1找到该平台的ip
现在是假设有无人机端和地面站端,我以地面站为master
那么现在就得找到无人机和地面站的ip地址
在ubuntu终端下输入:
ifconfig
得到结果:
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:06:33:84:3b txqueuelen 0 (以太网)
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
enp8s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether a0:69:74:07:63:16 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 214664 bytes 79280234 (79.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 214664 bytes 79280234 (79.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp0s20f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.153.63 netmask 255.255.255.0 broadcast 192.168.153.255
inet6 fe80::f58d:7aac:fa27:7ded prefixlen 64 scopeid 0x20<link>
inet6 240e:469:64b:c72b:ab3e:5a56:6a13:7264 prefixlen 64 scopeid 0x0<global>
inet6 240e:469:64b:c72b:8d36:641f:3c37:3a5e prefixlen 64 scopeid 0x0<global>
ether 64:79:f0:d9:79:20 txqueuelen 1000 (以太网)
RX packets 519353 bytes 595149253 (595.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 213166 bytes 52646499 (52.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
解释:
docker0: 是 Docker 虚拟网络接口,不用于外部网络通信。
enp8s0: 是你的以太网接口,但在此例中没有分配到IP地址。
lo: 是本地环回接口(localhost),它的IP地址是 127.0.0.1。
wlp0s20f3: 是你的无线网络接口,其IPv4地址 192.168.153.63 是你计算机在本地网络中的地址。(这也就是我们需要找到的)
2.2设置地面站的ROS_MASTER_URI
在地面站设置环境变量:
export ROS_MASTER_URI=http://192.168.153.63:11311
export ROS_IP=192.168.153.63
2.3设置无人机的ROS_MASTER_URI
在无人机终端运行
export ROS_MASTER_URI=http://192.168.153.63:11311
export ROS_IP=<current_device_ip>
假设无人机的 IP 地址是 192.168.1.20
代码就是
export ROS_MASTER_URI=http://192.168.153.63:11311
export ROS_IP=<192.168.1.20>
3 roscore
4.rosrun节点文件
原文地址:https://blog.csdn.net/zhangzhao147/article/details/142363151
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!