整個(gè)配置過程相當(dāng)?shù)赝纯啵乙埠苄W(xué),到目前為止,依然不清楚是哪一個(gè)步驟使得配置成功啦!
1. 功能包安裝
sudo apt-get install ros-kinetic-multimaster-fkie
2. 實(shí)驗(yàn)配置
2.1. 固定IP地址
這一步是可有可無的,只要路由器能夠保證,電腦關(guān)機(jī)重啟后,能夠分配到同一個(gè)IP地址便沒有任何問題。如果目標(biāo)對(duì)象是一些嵌入式設(shè)備,完全可以將其IP地址給固定下來,但是IP固定之后,貌似無法聯(lián)網(wǎng),目前該問題還不清楚如何解決。
# 具體設(shè)置可以在Ubuntu的有線連接進(jìn)行設(shè)置,將IPV Settings的Method設(shè)置為Automatic(DHCP)
# 然后添加Address、Netmask、Gateway,點(diǎn)擊保存即可
# 修改完網(wǎng)絡(luò)設(shè)置,需要重啟
- Intel平臺(tái)設(shè)置
Address:192.168.0.100
Netmask:255.255.255.0
Gateway:192.168.0.1
- TX2平臺(tái)設(shè)置
Address:192.168.0.101
Netmask:255.255.255.0
Gateway:192.168.0.1
2.2. 查看和設(shè)置主機(jī)名【hostname】
其實(shí)終端前方的文本為:usrname@hostname
# 查看hostname
$ hostname
# 修改hostname
$ sudo gedit /etc/hostname
# 修改完hostname需要重啟才能生效
2.3. 修改/etc/hosts文件
sudo gedit /etc/hosts
# 修改完hosts文件后需要重啟網(wǎng)絡(luò)
sudo /etc/init.d/networking restart
- Intel平臺(tái)設(shè)置
hostname:intel
127.0.0.1 localhost
127.0.1.1 intel
192.168.0.101 tegra
192.168.0.100 intel
# 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
- TX2平臺(tái)設(shè)置
hostname:tegra
127.0.0.1 localhost
127.0.1.1 tegra
192.168.0.101 tegra
192.168.0.100 intel
# 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
2.4. 修改.bashrc文件,設(shè)置ROS_MASTER_URI
sudo gedit .bashrc,在.bashrc文件末尾分別添加如下文本,同時(shí)需要重啟終端才能生效。
- Intel平臺(tái)設(shè)置
hostname:intel
export ROS_MASTER_URI=http://192.168.0.100:11311
- TX2平臺(tái)設(shè)置
hostname:tegra
export ROS_MASTER_URI=http://192.168.0.101:11311
# 有的項(xiàng)目提示,需要將其中一臺(tái)電腦的端口修改為11312,沒有測(cè)試過
export ROS_MASTER_URI=http://192.168.0.101:11312
2.5. 查看multicast是否開啟和設(shè)置
# 多播組功能使用如下指令查看,如輸出為0,則說明開啟
# 一般是關(guān)閉的,輸出為1
cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
--------------------------------
# 暫時(shí)設(shè)置方法,重啟電腦將失效
sudo sh -c "echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts"
--------------------------------
# 永久設(shè)置方法
$ sudo gedit /etc/sysctl.conf
# 如果不存在,在文本末尾添加;如存在則將1更改為0
net.ipv4.icmp_echo_ignore_broadcasts=0
# 服務(wù)重啟
$ sudo service procps restart
2.6. 網(wǎng)絡(luò)配置是否成功
- 測(cè)試多播組是否設(shè)置成功
# 說實(shí)話該指令沒有理解,直接跳過
netstat -g
ping 224.0.0.1
- 網(wǎng)絡(luò)測(cè)試:互相ping和ssh連接測(cè)試
測(cè)試SSH是由于該功能包是建立在SSH通信的基礎(chǔ)上的
# Intel平臺(tái)測(cè)試
# ping IP地址
ping 192.168.0.101
# ping hostname
ping tegra
# ssh username@IP_address,輸入密碼即可連接成功
ssh tegra@192.168.0.101
# TX2平臺(tái)測(cè)試
# ping IP地址
ping 192.168.0.100
# ping hostname
ping intel
# ssh username@IP_address,輸入密碼即可連接成功
ssh intel@192.168.0.101
3. 實(shí)驗(yàn)指令
- Intel平臺(tái): Ubuntu 16.04 64位版本 ROS-kinetic (先啟動(dòng))
$ roscore
# 啟動(dòng)多播組發(fā)現(xiàn)節(jié)點(diǎn),傳遞多播組參數(shù)【_mcast_group】
$ rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.1
# 啟動(dòng)同步節(jié)點(diǎn)
$ rosrun master_sync_fkie master_sync
# 查看masters列表服務(wù)
$ rosservice call /master_discovery/list_masters
- TX2平臺(tái): Ubuntu 16.04 arm版本 ROS-kinetic (后啟動(dòng))
$ roscore
# 如果上面的IP地址更換,則這里可以設(shè)定端口
$ roscore -p 11312
# 啟動(dòng)多播組發(fā)現(xiàn)節(jié)點(diǎn),傳遞多播組參數(shù)【_mcast_group】
$ rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.1
# 啟動(dòng)同步節(jié)點(diǎn)
$ rosrun master_sync_fkie master_sync
# 查看masters列表服務(wù)
$ rosservice call /master_discovery/list_masters
- 測(cè)試通信話題: Intel ==> TX2
# 在Intel上發(fā)布測(cè)試話題 /test1
$ rostopic pub -r 1 /test1 std_msgs/Int32 1
# 在TX2上輸出話題信息 /test1
$ rostopic echo /test1
- 測(cè)試通信話題: TX2 ==> Intel
# 在Intel上發(fā)布測(cè)試話題 /test2
$ rostopic pub -r 1 /test2 std_msgs/Int32 2
# 在TX2上輸出話題信息 /test2
$ rostopic echo /test2
3.1. master_discovery_fkie節(jié)點(diǎn)的相關(guān)參數(shù)
# 輸出更加詳細(xì)的調(diào)試日志
rosrun master_discovery_fkie master_discovery _log_level:=DEBUG
# 設(shè)定多播組地址
rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.1
# 設(shè)定多播組接收和發(fā)送端口
rosrun master_discovery_fkie master_discovery _mcast_port:=11512
# 設(shè)定RPC端口
rosrun master_discovery_fkie master_discovery _rpc_port:=11612
# 設(shè)定需要發(fā)現(xiàn)的機(jī)器人的IP地址
rosrun master_discovery_fkie master_discovery _robot_hosts:=[137.132.82.147]
rosrun master_discovery_fkie master_discovery _robot_hosts:=[hostname]
# 設(shè)定hostname檢驗(yàn)無效
rosrun master_sync_fkie master_sync _check_host:=false
# 設(shè)定多播組發(fā)送無效
rosrun master_sync_fkie master_sync _send_mcast:=false
# 設(shè)定多播組接收無效
rosrun master_sync_fkie master_sync _listen_mcast:=false
# 根據(jù)netstat -g指令展示的多播組進(jìn)行選擇,也許是這個(gè)
rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.251
# 在其中一臺(tái)電腦設(shè)定節(jié)點(diǎn)名稱,其中name前面有兩單下劃線【_ _】
rosrun master_discovery_fkie master_discovery __name:=master_discovery_ai
3.2. master_sync_fkie節(jié)點(diǎn)的相關(guān)參數(shù)
$ rosrun master_sync_fkie master_sync __name:=master_sync_ai
$ rosrun master_sync_fkie master_sync _check_host:=false
4. 注意事項(xiàng)
- 多機(jī)通信之間的自定義消息一定要格式相同,不然無法實(shí)現(xiàn)有效通信
- 借助
roslaunch實(shí)現(xiàn)節(jié)點(diǎn)信息同步和參數(shù)文件配置設(shè)置
# 同步配置:sync_interface.sync
# For ignore/sync nodes, topics or services
# use follow declaration:
#{param name}:
# - {ros name}
# or for selected hosts:
# - {host name}:
# - {ros name}
# you can use follow wildcard: '*'
# A filter list with patterns. If this pattern merges to a node,
# topic or service it will not be synchronized.
do_not_sync:
# The ignore_* lists will be processed first.
ignore_hosts:
sync_hosts:
ignore_nodes:
sync_nodes:
ignore_topics:
ignore_publishers:
ignore_subscribers:
# 同步話題
sync_topics:
- /test
# 忽略服務(wù)
ignore_services:
- /*get_loggers
- /*set_logger_level
# 同步服務(wù)
sync_services:
# If sync_topics_on_demand is True the local subscribed and published topics
# are synchronized with remote even if they are not in the sync_* list.
sync_topics_on_demand: False
# The nodes which are running not at the same host as the ROS master are not
# synchronized by default. Use sync_remote_nodes to sync these nodes also.
sync_remote_nodes: False
# Performs resync after the host was offline: unregister and register again
# to avoid connection losses to python topic. These does not suppot reconnection!
resync_on_reconnect: True
# A configurable period that controls how long the offline-online period [sec]
# is before the resync kicks in.
resync_on_reconnect_timeout: 0
<!--multi_comm.launch-->
<?xml version="1.0"?>
<launch>
<node pkg="master_discovery_fkie" type="master_discovery" name="master_discovery">
<param name="mcast" value="224.0.0.1"/>
</node>
<node pkg="master_sync_fkie" type="master_sync" name="master_sync" output="screen">
<!-- 默認(rèn)同步所有節(jié)點(diǎn)、話題、服務(wù),添加文件路徑參數(shù)可以制定同步 -->
<!-- value必須以file:///開頭,后面可以是單斜杠的 -->
<param name="interface_url" value="file:///home/[usrname]/path_to_file/sync_interface.sync">
</node>
</launch>
- 重啟電腦
說不上為啥,但是可能會(huì)有意想不到的結(jié)果
- 重啟網(wǎng)絡(luò)服務(wù)
# 也許有好結(jié)果
sudo service network-manager restart
- 重啟SSH,出現(xiàn)
Failed to start ssh.service: Unit ssh.service not found.
# node_manager提示:connect to host localhost port 22: Connection refused
# 重啟SSH
$ sudo service ssh restart
>>> Failed to start ssh.service: Unit ssh.service not found.
# 安裝SSH組件
$ sudo apt-get install ssh
# 卸載open-SSH組件
$ sudo apt-get remove openssh-client openssh-server
# 安裝open-SSH組件
$ sudo apt-get install openssh-client openssh-server
# 查看相關(guān)組件
$ which ssh
$ which sshd
$ ssh localhost
# 遠(yuǎn)程連接:ssh username@IP_adrr
$ ssh nvidia@192.168.0.1
- 注釋
.bashrc
要通過SSH使用ROS,在Ubuntu 16系統(tǒng)上,用戶必須在其.bashrc文件中注釋以下行

注釋6-9行所在代碼
- 使用不同的節(jié)點(diǎn)名稱啟動(dòng)對(duì)應(yīng)節(jié)點(diǎn)
# 在其中一臺(tái)電腦設(shè)定節(jié)點(diǎn)名稱,其中name前面有兩單下劃線【_ _】
rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.1 __name:=master_discovery_ai
rosrun master_sync_fkie master_sync __name:=master_sync_ai
-
node_manager是GUI調(diào)試界面
5. 錯(cuò)誤備忘
- 出現(xiàn)
OSError:[Error 98] Address already in use
# 查找對(duì)應(yīng)的進(jìn)程的PID號(hào)
$ netstat -tunlp
# 結(jié)束當(dāng)前進(jìn)程,615為進(jìn)程的PID號(hào)
$ kill -9 6135
- 出現(xiàn)
Master_discovery node appear not to running. Wait for topic with type 'MasterState或Error while start RPC-XML server on port 11611: [Errno 98] Address already in use
sudo apt-get install ros-kinetic-multimaster-launch
rosrun master_discovery_fkie master_discovery _send_mcast:=Ture
- 出現(xiàn)
DeserializationError cannot deserialize: unknown error handler name ‘rosmsg‘
sudo apt-get install ros-kinetic-genpy
# 原因ros中的一些pkg的依賴pkg沒有相對(duì)應(yīng)的更新(雖然有但版本舊)
# 使用如下指令查看版本號(hào)
dpkg -l | grep genpy
-
rosdep update出現(xiàn)ERROR: unable to process source
reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml]:
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml]:
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
Failed to download target platform data for gbpdistro:
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
<urlopen error <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>
- 系統(tǒng)設(shè)置沒法點(diǎn)開
$ sudo apt-get install unity-control-center
# 需要重啟,才能生效
- 終端編輯框沒有顏色提示
# 修改 ~/.bashrc,
# 將里面的force_color_prompt=yes前面的注釋‘#’去掉
- 防火墻阻擋
sudo apt-get install ufw
# 防火墻狀態(tài)檢查
sudo ufw status
# 關(guān)閉防火墻
sudo ufw disable
# 激活防火墻
sudo ufw enable
參考鏈接
1. Yaoyu Hu博客:Multimaster ROS configuration and multimaster_fkie
2. Yaoyu Hu博客:使用測(cè)試程序
3. multimaster_fkie配置中文翻譯
4. ROS官網(wǎng)教程
5. Gazebo官網(wǎng)教程
6. node_manager教程
7. multi-master ROS systems
8. 官方項(xiàng)目地址
9. 從源碼安裝ROS包
10. sudo rosdep init出錯(cuò)