###### tags: `eurobot2023` {%hackmd @925/Style %} # multimaster 使用說明 ## 1. 安裝 ```= sudo apt install ros-noetic-fkie-multimaster ``` ## 2. 修改 bashrc ```= sudo nano ~/.bashrc ``` 11311 是固定的 port,IP 要修改成本機的位址 `192.168.xx.xx`。 可用 `ifconfig` 查詢本機 IP 位址。 ```yaml= # 在文件最下方新增以下兩行 export ROS_HOSTNAME="192.168.50.151" export ROS_MASTER_URI=http://192.168.50.151:11311 # 儲存退出 ``` ```yaml= source ~/.bashrc ``` ## 3. 使用 跑兩個背景程式,兩個都要開才能運作。 ```yaml= roscore rosrun fkie_master_discovery master_discovery rosrun fkie_master_sync master_sync ``` ## 4. 開機一併執行檔案 ### A. 開機 roscore + rosrun multimaster (REQUIRED) :::spoiler 這個適用 Raspberry Pi 4B <font color="yellow">1. 寫開機檔</font> ```yaml= cd ~/.config/autostart/ nano init.desktop ``` `init.desktop` 內容如下: ```yml= [Desktop Entry] Type=Application Name=roscore Exec=/bin/bash -c "source /opt/ros/noetic/setup.bash && (roscore &) && sleep 5 && (rosrun fkie_master_discovery master_discovery & rosrun fkie_master_sync master_sync)" Termianl=True # Termainal=false: not showing output terminal ``` <font color="yellow">2. 給權限</font> ```yaml= chmod +x ~/.config/autostart/init.desktop ``` <font color="yellow">3. 測試</font> ```yaml= sudo reboot # 重開後 rosnode list # /master_discovery # /master_sync # /rosout ``` ::: :::spoiler 這個適用 lattePanda Delta 3 -- 解決 ping 問題 --- lattepanda 開機要 53 秒,目前合理推測是有些服務來不及或延遲啟動? 可以先 ping 來很奇怪地解決"沒辦法 SSH 的問題"。 <font color="yellow">1. 到 `etc/init.d` 寫腳本 `ping.sh`</font> ```xml= cd ~ cd ../.. sudo nano /etc/init.d/ping.sh ``` ```script= #!/bin/bash sleep 5 # ping 5 times ping -c 5 192.168.50.1 ``` <font color="yellow">2. 給權限</font> ```= sudo chmod +x /etc/init.d/ping.sh ``` <font color="yellow">3. 更新,每次修改都要做</font> ```= sudo update-rc.d ping.sh defaults ``` <font color="yellow">4. 加到 runlevel N 5 裡面。</font> ```yaml= # S99 代表在 boot 末階段時執行腳本 sudo ln -s /etc/init.d/ping.sh /etc/rc5.d/S99ping.sh ``` <font color="yellow">5. 試跑一次</font> ```= sudo /etc/init.d/ping.sh start ``` ::: :::spoiler 這個適用 lattePanda Delta 3 -- 開啟 multimaster --- <font color="yellow">1. 到 `etc/init.d` 寫腳本 `multimaster.sh`</font> ```xml= cd ~ cd ../.. sudo nano /etc/init.d/multimaster.sh ``` ```script= #!/bin/bash source /opt/ros/noetic/setup.bash nohup roscore > /dev/null & sleep 5 nohup rosrun fkie_master_discovery master_discovery > /dev/null & sleep 5 nohup rosrun fkie_master_sync master_sync > /dev/null & ``` <font color="yellow">2. 給權限</font> ```= sudo chmod +x /etc/init.d/multimaster.sh ``` <font color="yellow">3. 更新,每次修改都要做</font> ```= sudo update-rc.d multimaster.sh defaults ``` <font color="yellow">4. 加到 runlevel N 5 裡面。</font> ```yaml= # S99 代表在 boot 末階段時執行腳本 sudo ln -s /etc/init.d/multimaster.sh /etc/rc5.d/S99multimaster.sh ``` <font color="yellow">5. 試跑一次</font> ```= sudo /etc/init.d/multimaster.sh start ::: ## 5. 從 A 機 launch B(C、D...) 機 ### A. 在 A 機上開 node manager ```yaml= #terminal node_manager ``` ### B. 點點點 ### ## ※ 備註 Router 需要修改設定,已經調過。 如果之後有問題可以再檢查設定是否正確。 #### <font color="magenza"> 1. enable multicast forwarding </font> > <font color="skyblue">Click on the "LAN" menu and select "IPTV" tab. In "Special Apllications" section, enable "Enable Multicast Routing." Click "Apply".</font> #### <font color="magenza"> 2. enable IGMP snooping </font> > <font color="skyblue">Select the "IGMP Snooping" tab and enable "Enable IGMP Snooping."