【multimaster_fkie package】ROS多機通信配置

整個配置過程相當?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 'MasterStateError 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出錯

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市坑雅,隨后出現(xiàn)的幾起案子辈挂,更是在濱河造成了極大的恐慌,老刑警劉巖裹粤,帶你破解...
    沈念sama閱讀 218,941評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件终蒂,死亡現(xiàn)場離奇詭異,居然都是意外死亡遥诉,警方通過查閱死者的電腦和手機拇泣,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,397評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來矮锈,“玉大人霉翔,你說我怎么就攤上這事“浚” “怎么了债朵?”我有些...
    開封第一講書人閱讀 165,345評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長瀑凝。 經(jīng)常有香客問我序芦,道長,這世上最難降的妖魔是什么粤咪? 我笑而不...
    開封第一講書人閱讀 58,851評論 1 295
  • 正文 為了忘掉前任谚中,我火速辦了婚禮,結(jié)果婚禮上寥枝,老公的妹妹穿的比我還像新娘宪塔。我一直安慰自己,他們只是感情好囊拜,可當我...
    茶點故事閱讀 67,868評論 6 392
  • 文/花漫 我一把揭開白布某筐。 她就那樣靜靜地躺著,像睡著了一般冠跷。 火紅的嫁衣襯著肌膚如雪来吩。 梳的紋絲不亂的頭發(fā)上敢辩,一...
    開封第一講書人閱讀 51,688評論 1 305
  • 那天,我揣著相機與錄音弟疆,去河邊找鬼戚长。 笑死,一個胖子當著我的面吹牛怠苔,可吹牛的內(nèi)容都是我干的同廉。 我是一名探鬼主播,決...
    沈念sama閱讀 40,414評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼柑司,長吁一口氣:“原來是場噩夢啊……” “哼迫肖!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起攒驰,我...
    開封第一講書人閱讀 39,319評論 0 276
  • 序言:老撾萬榮一對情侶失蹤蟆湖,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后玻粪,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體隅津,經(jīng)...
    沈念sama閱讀 45,775評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,945評論 3 336
  • 正文 我和宋清朗相戀三年劲室,在試婚紗的時候發(fā)現(xiàn)自己被綠了伦仍。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,096評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡很洋,死狀恐怖充蓝,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情喉磁,我是刑警寧澤谓苟,帶...
    沈念sama閱讀 35,789評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站协怒,受9級特大地震影響涝焙,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜斤讥,卻給世界環(huán)境...
    茶點故事閱讀 41,437評論 3 331
  • 文/蒙蒙 一纱皆、第九天 我趴在偏房一處隱蔽的房頂上張望湾趾。 院中可真熱鬧芭商,春花似錦、人聲如沸搀缠。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,993評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽艺普。三九已至簸州,卻和暖如春鉴竭,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背岸浑。 一陣腳步聲響...
    開封第一講書人閱讀 33,107評論 1 271
  • 我被黑心中介騙來泰國打工搏存, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人矢洲。 一個月前我還...
    沈念sama閱讀 48,308評論 3 372
  • 正文 我出身青樓璧眠,卻偏偏與公主長得像,于是被迫代替她去往敵國和親读虏。 傳聞我的和親對象是個殘疾皇子责静,可洞房花燭夜當晚...
    茶點故事閱讀 45,037評論 2 355

推薦閱讀更多精彩內(nèi)容