整個配置過程相當?shù)赝纯啵乙埠苄W(xué),到目前為止昨凡,依然不清楚是哪一個步驟使得配置成功啦命满!
1. 功能包安裝
sudo apt-get install ros-kinetic-multimaster-fkie
2. 實驗配置
2.1. 固定IP地址
這一步是可有可無的童芹,只要路由器能夠保證涮瞻,電腦關(guān)機重啟后,能夠分配到同一個IP地址便沒有任何問題假褪。如果目標對象是一些嵌入式設(shè)備署咽,完全可以將其IP地址給固定下來,但是IP固定之后生音,貌似無法聯(lián)網(wǎng)宁否,目前該問題還不清楚如何解決。
# 具體設(shè)置可以在Ubuntu的有線連接進行設(shè)置缀遍,將IPV Settings的Method設(shè)置為Automatic(DHCP)
# 然后添加Address慕匠、Netmask、Gateway域醇,點擊保存即可
# 修改完網(wǎng)絡(luò)設(shè)置台谊,需要重啟
- Intel平臺設(shè)置
Address:192.168.0.100
Netmask:255.255.255.0
Gateway:192.168.0.1
- TX2平臺設(shè)置
Address:192.168.0.101
Netmask:255.255.255.0
Gateway:192.168.0.1
2.2. 查看和設(shè)置主機名【hostname】
其實終端前方的文本為: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平臺設(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平臺設(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
文件末尾分別添加如下文本锅铅,同時需要重啟終端才能生效。
- Intel平臺設(shè)置
hostname:intel
export ROS_MASTER_URI=http://192.168.0.100:11311
- TX2平臺設(shè)置
hostname:tegra
export ROS_MASTER_URI=http://192.168.0.101:11311
# 有的項目提示减宣,需要將其中一臺電腦的端口修改為11312盐须,沒有測試過
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è)置方法姨蟋,重啟電腦將失效
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ò)配置是否成功
- 測試多播組是否設(shè)置成功
# 說實話該指令沒有理解眼溶,直接跳過
netstat -g
ping 224.0.0.1
- 網(wǎng)絡(luò)測試:互相ping和ssh連接測試
測試SSH是由于該功能包是建立在SSH通信的基礎(chǔ)上的
# Intel平臺測試
# ping IP地址
ping 192.168.0.101
# ping hostname
ping tegra
# ssh username@IP_address悠砚,輸入密碼即可連接成功
ssh tegra@192.168.0.101
# TX2平臺測試
# ping IP地址
ping 192.168.0.100
# ping hostname
ping intel
# ssh username@IP_address,輸入密碼即可連接成功
ssh intel@192.168.0.101
3. 實驗指令
- Intel平臺: Ubuntu 16.04 64位版本 ROS-kinetic (先啟動)
$ roscore
# 啟動多播組發(fā)現(xiàn)節(jié)點堂飞,傳遞多播組參數(shù)【_mcast_group】
$ rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.1
# 啟動同步節(jié)點
$ rosrun master_sync_fkie master_sync
# 查看masters列表服務(wù)
$ rosservice call /master_discovery/list_masters
- TX2平臺: Ubuntu 16.04 arm版本 ROS-kinetic (后啟動)
$ roscore
# 如果上面的IP地址更換灌旧,則這里可以設(shè)定端口
$ roscore -p 11312
# 啟動多播組發(fā)現(xiàn)節(jié)點,傳遞多播組參數(shù)【_mcast_group】
$ rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.1
# 啟動同步節(jié)點
$ rosrun master_sync_fkie master_sync
# 查看masters列表服務(wù)
$ rosservice call /master_discovery/list_masters
- 測試通信話題: Intel ==> TX2
# 在Intel上發(fā)布測試話題 /test1
$ rostopic pub -r 1 /test1 std_msgs/Int32 1
# 在TX2上輸出話題信息 /test1
$ rostopic echo /test1
- 測試通信話題: TX2 ==> Intel
# 在Intel上發(fā)布測試話題 /test2
$ rostopic pub -r 1 /test2 std_msgs/Int32 2
# 在TX2上輸出話題信息 /test2
$ rostopic echo /test2
3.1. master_discovery_fkie
節(jié)點的相關(guān)參數(shù)
# 輸出更加詳細的調(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)的機器人的IP地址
rosrun master_discovery_fkie master_discovery _robot_hosts:=[137.132.82.147]
rosrun master_discovery_fkie master_discovery _robot_hosts:=[hostname]
# 設(shè)定hostname檢驗無效
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指令展示的多播組進行選擇绰筛,也許是這個
rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.251
# 在其中一臺電腦設(shè)定節(jié)點名稱枢泰,其中name前面有兩單下劃線【_ _】
rosrun master_discovery_fkie master_discovery __name:=master_discovery_ai
3.2. master_sync_fkie
節(jié)點的相關(guān)參數(shù)
$ rosrun master_sync_fkie master_sync __name:=master_sync_ai
$ rosrun master_sync_fkie master_sync _check_host:=false
4. 注意事項
- 多機通信之間的自定義消息一定要格式相同,不然無法實現(xiàn)有效通信
- 借助
roslaunch
實現(xiàn)節(jié)點信息同步和參數(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">
<!-- 默認同步所有節(jié)點铝噩、話題衡蚂、服務(wù),添加文件路徑參數(shù)可以制定同步 -->
<!-- value必須以file:///開頭,后面可以是單斜杠的 -->
<param name="interface_url" value="file:///home/[usrname]/path_to_file/sync_interface.sync">
</node>
</launch>
- 重啟電腦
說不上為啥毛甲,但是可能會有意想不到的結(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
# 遠程連接:ssh username@IP_adrr
$ ssh nvidia@192.168.0.1
- 注釋
.bashrc
要通過SSH使用ROS,在Ubuntu 16系統(tǒng)上玻募,用戶必須在其.bashrc文件中注釋以下行
注釋6-9行所在代碼
- 使用不同的節(jié)點名稱啟動對應(yīng)節(jié)點
# 在其中一臺電腦設(shè)定節(jié)點名稱只损,其中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. 錯誤備忘
- 出現(xiàn)
OSError:[Error 98] Address already in use
# 查找對應(yīng)的進程的PID號
$ netstat -tunlp
# 結(jié)束當前進程,615為進程的PID號
$ 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沒有相對應(yīng)的更新(雖然有但版本舊)
# 使用如下指令查看版本號
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è)置沒法點開
$ 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博客:使用測試程序
3. multimaster_fkie配置中文翻譯
4. ROS官網(wǎng)教程
5. Gazebo官網(wǎng)教程
6. node_manager教程
7. multi-master ROS systems
8. 官方項目地址
9. 從源碼安裝ROS包
10. sudo rosdep init出錯