idminer
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    **TurtleBot3(ROS1)-Kinetic 中文線上手冊** === - 20231123 中譯發布,不會即時修正,內容如有差異不同,請以[**英文線上手冊**](https://emanual.robotis.com/docs/en/platform/turtlebot3/quick-start/) 的 Kinetic 內容為主 O : 可支援 ∆ : 需要確認 X : 不支援,自行開發 | 特色 | Kinetic | Melodic | Noetic | Dashing | Foxy | Galactic | Humble | | --- | --- | --- | --- | --- | --- | --- | --- | | 遙控 | O | O | O | O | O | O | O | | SLAM | O | O | O | O | O | O | O | | 導航 | O | O | O | O | O | O | O | | 模擬 | O | O | O | O | O | O | O | | 機器手臂 | O | O | O | O | O | ∆ | O | | Home Service Challenge | O | O | O | X | X | X | X | | 自動駕駛挑戰賽 | O | X | O | X | X | X | X | | 機器學習 | O | O | X | O | X | X | X | | 範例 | Kinetic | Melodic | Noetic | Dashing | Foxy | Galactic | Humble | | --- | --- | --- | --- | --- | --- | --- | --- | | Interactive Markers | O | X | X | X | X | X | X | | Obstacle Detection | O | X | X | O | X | X | X | | Position Control | O | X | X | O | X | X | X | | Point Operation | O | X | X | O | X | X | X | | Patrol | O | X | X | O | X | X | X | | Follower | O | X | X | X | X | X | X | | Panorama | O | X | X | X | X | X | X | | Auto Parking | O | X | X | O | X | X | X | | Auto Parking(Vision) | O | X | X | X | X | X | X | | Multi TurtleBot3 | O | X | X | X | X | X | X | # **1. TurtleBot3 Overview** --- 通用章節,請看 Melodic 版 # **2. TurtleBot3 特色** --- 通用章節,請看 Melodic 版 # **3. TB3 快速入門指南** --- {%youtube ji2kQXgCjeM %} ## 3.1. Remote PC(桌電/筆電) 設定 :::warning 警告: 以下介紹的內容是用來設定 Remote PC (也就是你的桌電或筆電),以便來遠端控制 TurtleBot3 用。千萬不要使用在 TurtleBot3 的 SBC 單板電腦上。 ::: :::danger **相容性警示** - 樹莓派 4 不支援 ROS Kinetic 版 - Jetson Nano 不支援 ROS Kinetic 版 ::: :::info 備註: 操作的內容已在Ubuntu 16.04 及 ROS Kinetic Kame 版本上測試過。 ::: ### 3.1.1. 在 Remote PC 下載及安裝 Ubuntu 首先要在 Remote PC(你的桌電或是筆電)上安裝 Ubuntu(一種 Linux 作業系統). 請先下載 Ubuntu 16.04 LTS Desktop 版及參考安裝步驟進行安裝. - [Ubuntu 16.04 LTS Desktop image 64-bit 下載點](https://releases.ubuntu.com/16.04.7/) - [Ubuntu 安裝步驟](https://ubuntu.com/tutorials/install-ubuntu-desktop#1-overview) ### 3.1.2. 在 Remote PC 安裝 ROS Ctrl+Alt+T 開啟 terminal 視窗,輸入以下指令,一次一行 - 請先參考這個 [**script 檔**](https://raw.githubusercontent.com/ROBOTIS-GIT/robotis_tools/master/install_ros_kinetic.sh) ``` $ sudo apt-get update $ sudo apt-get upgrade $ wget https://raw.githubusercontent.com/ROBOTIS-GIT/robotis_tools/master/install_ros_kinetic.sh $ chmod 755 ./install_ros_kinetic.sh $ bash ./install_ros_kinetic.sh ``` - 如果安裝失敗,請參考[**官方 ROS Kinetic 安裝指南**](http://wiki.ros.org/kinetic/Installation/Ubuntu) ### 3.1.3. 安裝相關 ROS Packages ``` $ sudo apt-get install ros-kinetic-joy ros-kinetic-teleop-twist-joy \ ros-kinetic-teleop-twist-keyboard ros-kinetic-laser-proc \ ros-kinetic-rgbd-launch ros-kinetic-depthimage-to-laserscan \ ros-kinetic-rosserial-arduino ros-kinetic-rosserial-python \ ros-kinetic-rosserial-server ros-kinetic-rosserial-client \ ros-kinetic-rosserial-msgs ros-kinetic-amcl ros-kinetic-map-server \ ros-kinetic-move-base ros-kinetic-urdf ros-kinetic-xacro \ ros-kinetic-compressed-image-transport ros-kinetic-rqt* \ ros-kinetic-gmapping ros-kinetic-navigation ros-kinetic-interactive-markers ``` ### 3.1.4. 安裝 TurtleBot3 Packages TurtleBot3 可透過 Debian Packages 來安裝 ``` $ sudo apt-get install ros-kinetic-dynamixel-sdk $ sudo apt-get install ros-kinetic-turtlebot3-msgs $ sudo apt-get install ros-kinetic-turtlebot3 ``` - 如果需要用原始碼來 build TurtleBot3 Packages,可參照下列指令,如有同名的套件請先移除。 ``` $ sudo apt-get remove ros-kinetic-dynamixel-sdk $ sudo apt-get remove ros-kinetic-turtlebot3-msgs $ sudo apt-get remove ros-kinetic-turtlebot3 $ mkdir -p ~/catkin_ws/src $ cd ~/catkin_ws/src/ $ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/DynamixelSDK.git $ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git $ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/turtlebot3.git $ cd ~/catkin_ws && catkin_make $ echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc ``` ### 3.1.5. 設定 TurtleBot3 Model Name 設定預設的 TURTLEBOT3_MODEL,可輸入以下指令 - 使用 TurtleBot3 Burger ``` $ echo "export TURTLEBOT3_MODEL=burger" >> ~/.bashrc ``` - 使用 TurtleBot3 Waffle Pi ``` $ echo "export TURTLEBOT3_MODEL=waffle_pi" >> ~/.bashrc ``` ### 3.1.6. 網路設定 ![](https://i.imgur.com/TwGccJK.png) 1. Remote PC 端: 將 PC 連上 WiFi,在 terminal 視窗輸入下方指令來找出 remote PC 的 IP 位址 ``` $ ifconfig ``` 下圖紅色方框內, 顯示的是 remote PC 的 IP 位址 ![](https://i.imgur.com/4diIDP3.png) 2. 開啟檔案,使用以下指令來更新 ROS IP 設定 ``` $ nano ~/.bashrc ``` 3. 按 Ctrl + END 或 Alt + / 移動游標到最後一行。然後將檔案內的 ROS_MASTER_URI 的 localhost 以及 ROS_HOSTNAME 後面接的 IP 位址,更改為上面所得到的 remote PC(桌電/筆電) 的 IP 位址,如下圖所示。 ![](https://i.imgur.com/GNkBW0H.png) 4. Source bashrc 檔的指令 ``` $ source ~/.bashrc ``` ## 3.2. SBC 單板電腦(樹莓派 3B+)設定 :::info - **樹莓派 4,Jetson Nano** 不支援 ROS Kinetic - 安裝時需要供電及時間較久,**不適合使用電池**,建議使用TB3 內附的 SMPS 電源線接市電來供電。 - 需另備 HDMI 螢幕、鍵盤、滑鼠以完成設定 - 如使用 Intel Joule 為 SBC,可參考 [**Intel Joule Setup**](https://emanual.robotis.com/docs/en/popup/turtlebot3/joule_setup) 指引 ::: ### 3.2.1. 準備 microSD 卡及讀卡機 如果 PC 沒有 microSD 槽,請改用 microSD 讀卡機來燒錄映像檔。 ![](https://i.imgur.com/k9QUeo1.png) ### 3.2.2. 下載 TB3 SBC OS image Kinetic 需要 Ubuntu 16.04,Kinetic 版的映像檔使用 Raspberry Pi OS(Raspbian OS) - 下載 [Raspberry Pi 3B+ ROS Kinetic image](http://www.robotis.com/service/download.php?no=1738) - SHA256 : eb8173f3727db08087990b2c4e2bb211e70bd54644644834771fc8b971856b97 :::info - recovery 映像檔如有修改,不會預先通知 - 樹莓派 4 不支援 Ubuntu 16.04 也不支援 Debian Jessie,故不支援 ROS Kinetic ::: ### 3.2.3. 解壓縮 image 將下載的 .img 檔解壓縮存到本地硬碟 ### 3.2.4. 燒錄 image 可使用不同的映像檔燒錄工具,如 Raspberry Pi Imager 或 Linux 的 Disks utility 工具程式 #### 3.2.4.1. 使用 Raspberry Pi Imager - 從樹莓派官網下載 [**Raspberry Pi Imager**](https://www.raspberrypi.org/software/) - 可參考 [Raspberry Pi Imager 詳細文件](https://www.raspberrypi.org/blog/raspberry-pi-imager-imaging-utility/) ![](https://emanual.robotis.com/assets/images/platform/turtlebot3/setup/rpi_imager.gif) 步驟 1. 按 CHOOSE OS 2. 按 Use Custom 選擇儲存於硬碟的 .img 映像檔 3. 按 CHOOSE STORAGE 選擇 microSD 4. 按 WRITE 開始燒錄映像檔 #### 3.2.4.2. 使用 Disks Utility Disks utility 工具程式已經內含在 Ubuntu Desktop 版內,搜尋 Disks 就可找到開啟此工具程式。 ![](https://emanual.robotis.com/assets/images/platform/turtlebot3/setup/disks.gif) 步驟 1. 在左邊控制面板選擇 microSD 2. 選擇 Restore Disk Image 選項 3. 開啟存在硬碟內的 .img 映像檔 4. 按 Start Restoring... > Restore 鍵 :::info 使用 Intel Joule 570x 做為 SBC 的方法。因 Intel Joule 已經停產,所以後續的支援已經沒有。 1. [下載 Ubuntu 16.04 映像檔 for Intel Joule](http://people.canonical.com/~platform/snappy/tuchuck/desktop-final/tuchuck-xenial-desktop-iso-20170317-0.iso) 2. 將下載的 image 燒錄到可開機的 USB 碟 3. 從 USB 碟安裝 Ubuntu 16.04 ::: ### 3.2.5. Raspberry Pi 開機 1. 連接 HDMI 螢幕到樹莓派的 HDMI port 2. 連接鍵盤跟滑鼠到樹莓派的 USB port 3. 插入 microSD 卡 4. 連接電源(透過USB or OpenCR)讓樹莓派開機 :::danger HDMI 螢幕必須在開機前就接上樹莓派,要不然樹莓派的 HDMI port 會 disable ::: ### 3.2.6. 設定樹莓派 3B+ :::info Note: 如果碰到有關 ROS GPG Key 的 apt failures(因為目前的 GPG key 已過期),你需要去更新 GPG Key。請參照 [ROS GPG Key Expiration Incident](https://emanual.robotis.com/docs/en/platform/turtlebot3/sbc_setup/#https://discourse.ros.org/t/ros-gpg-key-expiration-incident/20669) 來解決。 ::: 1. 在 Raspbian OS 啟動執行後,Wifi 連上跟 Remote PC 的同一網域 2. 使用以下指令找出 Raspberry Pi 的指定 IP address,通常此無線 IP address 會在 wlan0 section 找到。 ``` $ ifconfig ``` 3. 在 Remote PC 開新的 terminal 後連上 Raspberry Pi 的 IP address。預設密碼是 turtlebot ``` $ ssh pi@{IP_ADDRESS_OF_RASPBERRY_PI} ``` 4. 登入到 SBC 後,執行下列指令來同步時間 sync time ``` $ sudo apt-get install ntpdate $ sudo ntpdate ntp.ubuntu.com ``` 5. 載入 Raspberry Pi 設定介面 ``` $ sudo raspi-config ``` 6. 選擇 Advanced Options > Expand Filesystem 後 exit 結束 7. 編輯 ROS 的網路設定檔 ``` $ nano ~/.bashrc ``` 8. Ctrl + END 或 Alt + / 到檔案最底部,然後修改 ROS_MASTER_URI 的 IP 及 ROS_HOSTNAME ``` export ROS_MASTER_URI=http://{IP_ADDRESS_OF_REMOTE_PC}:11311 export ROS_HOSTNAME={IP_ADDRESS_OF_RASPBERRY_PI_3} ``` 9. 存檔,結束 nano 編輯器 10. 套用所有變更 ``` $ source ~/.bashrc ``` ### 3.2.7. 新光達 LDS-02 的設定 | LDS-01 | LDS-02 | |:------------------------------------:|:------------------------------------:| | ![](https://i.imgur.com/HwtZjjx.png) | ![](https://i.imgur.com/BuuZp7A.png) | 2022 年版 TurtleBot3 標配的光達已經改為 LDS-02。請使用下列指令在 SBC(樹莓派) 上來設定 LDS-02 光達。 1. 安裝 LDS-02 driver 及更新 TB3 package ``` $ sudo apt update $ sudo apt install libudev-dev $ cd ~/catkin_ws/src $ git clone -b develop https://github.com/ROBOTIS-GIT/ld08_driver.git $ cd ~/catkin_ws/src/turtlebot3 && git pull $ rm -r turtlebot3_description/ turtlebot3_teleop/ turtlebot3_navigation/ turtlebot3_slam/ turtlebot3_example/ $ cd ~/catkin_ws && catkin_make ``` 2. Export LDS_MODEL to bashrc 檔。LDS model 可以是 LDS-01 或 LDS-02。 ``` $ echo 'export LDS_MODEL=LDS-02' >> ~/.bashrc $ source ~/.bashrc ``` ## 3.3. OpenCR 控制板設定 1. 使用 microUSB 連接線連接樹莓派及 OpenCR 2. 樹莓派安裝所需套件來上傳 OpenCR 韌體 ``` $ sudo dpkg --add-architecture armhf $ sudo apt-get update $ sudo apt-get install libc6:armhf ``` 3. 依照 TB3 的款式,設定 OpenCR_MODEL 參數為 burger 或 waffle ``` $ export OPENCR_PORT=/dev/ttyACM0 $ export OPENCR_MODEL=burger $ rm -rf ./opencr_update.tar.bz2 ``` 4. 下載韌體解壓縮 ``` $ wget https://github.com/ROBOTIS-GIT/OpenCR-Binaries/raw/master/turtlebot3/ROS1/latest/opencr_update.tar.bz2 $ tar -xvf opencr_update.tar.bz2 ``` 5. 上傳韌體到 OpenCR ``` $ cd ./opencr_update $ ./update.sh $OPENCR_PORT $OPENCR_MODEL.opencr ``` 6. Burger 如果成功上傳韌體,會出現下列資訊 ![](https://i.imgur.com/wL37GsT.png) 7. 如果上傳失敗,可以嘗試在 recovery mode 下重新上傳韌體。OpenCR 的 recovery mode 啟動順序如下。在 recovery mode 時,OpenCR 的 STATUS led 燈會定時的閃爍。 - 按住 PUSH SW2 鍵 - 按一下 Reset 鍵然後鬆開 - 再鬆開 PUSH SW2 鍵 ![](https://i.imgur.com/ZilkkEU.png) **補充資料: 使用 Arduino IDE 來上傳韌體步驟** :::info OpenCR board manager 並不支援 ARM based SBC 的 Arduino IDE,如樹莓派 或 NVidia Jetson。 請在 PC 上用 Arduino IDE 來上傳韌體。 ::: 1. 如 PC 的 OS 是 Linux,下列指令設定 OpenCR 的 USB port。如果其他 OS(OSX or Windows),可跳過此步驟。 ``` $ wget https://raw.githubusercontent.com/ROBOTIS-GIT/OpenCR/master/99-opencr-cdc.rules $ sudo cp ./99-opencr-cdc.rules /etc/udev/rules.d/ $ sudo udevadm control --reload-rules $ sudo udevadm trigger $ sudo apt install libncurses5-dev:i386 ``` 2. 安裝 Arduino IDE - [下載最新的 Arduino IDE](https://www.arduino.cc/en/software) 3. 安裝好後,執行 Arduino IDE 4. 按 Ctrl 及 , 來打開 Preferences menu 5. 在 Additional Boards Manager URLs 輸入下列位址 ``` https://raw.githubusercontent.com/ROBOTIS-GIT/OpenCR/master/arduino/opencr_release/package_opencr_index.json ``` ![](https://i.imgur.com/zcRVecI.png) 6. 開啟 TurtleBot3 韌體。依你的平台選擇對應的韌體。 - **Burger**: File > Examples > turtlebot3 > turtlebot3_burger > turtlebot3_core - **Waffle/Waffle Pi**: File > Examples > turtlebot3 > turtlebot3_waffle > turtlebot3_core 7. 連接 OpenCR 板到 PC 上,從 Tools > Board 選單選擇 OpenCR > OpenCR Board 8. 從 Tools > Port 選單中選擇連接 OpenCR 的 USB port 9. upload 圖示或 Ctrl+U 來上傳韌體 ![](https://i.imgur.com/S3zNgU6.png) ![](https://i.imgur.com/fxp7cNS.png) 10. 如果上傳失敗,可以嘗試在 recovery mode 下重新上傳韌體。OpenCR 的 recovery mode 啟動順序如下。在 recovery mode 時,OpenCR 的 STATUS led 燈會定時的閃爍。 - 按住 PUSH SW2 鍵 - 按一下 Reset 鍵然後鬆開 - 再鬆開 PUSH SW2 鍵 ![](https://i.imgur.com/ZilkkEU.png) ### 3.3.1. OpenCR 測試 :::info Note: 如果測試後,輪子並沒有照設定的移動,請參照 FAQ 14.3. “Setup DYNAMIXELs for TurtleBot3” 重新設定智能馬達。 ::: 你可以使用 PUSH SW1 及 PUSH SW2 按鍵,來檢查 TB3 是否正確組裝。這個流程是測試左右兩個 Dynamixel 智能馬達及 OpenCR 控制板。 ![](https://i.imgur.com/staqXpo.jpg) 1. 在組裝好 TB3 後,將電池連上 OpenCR,打開電源開關,應會看到 OpenCR 板上的 Power LED 燈亮起 2. 將 TB3 放在地板上。為安全起見,建議安全半徑為 1m。 3. 按住 PUSH SW1 鍵幾秒鐘,會讓 TB3 往前直行 30cm。 4. 按住 PUSH SW2 鍵幾秒鐘,會讓 TB3 原地旋轉 180 度。 ## 3.4. 硬體組裝 ![](https://i.imgur.com/CEvRMfd.png) ### 3.4.1. 組裝手冊 TB3 出貨時是盒裝,零配件是未組裝狀態。請下載相對應的 PDF 來組裝 - [**TB3 Burger 漢堡款組裝手冊下載**](http://www.robotis.com/service/download.php?no=748) - [**TB3 Waffle 鬆餅款組裝手冊下載**](http://www.robotis.com/service/download.php?no=749) - [**TB3 Waffle Pi 鬆餅 Pi 款組裝手冊下載**](http://www.robotis.com/service/download.php?no=750) ### 3.4.2. TB3 組裝影片 如果難以由 PDF 手冊進行組裝,請參考以下 Youtube 組裝影片。(PS: 採智科技可以提供 TB3 組裝服務,請你在訂購時先跟我們的業務確認。) - TB3 Burger 組裝影片 1 {%youtube rvm-m2ogrLA %} - TB3 Burger 組裝影片 2 {%youtube 5D9S_tcenL4 %} - TB3 Waffle 組裝影片 {%youtube 1nTMyr4ybi0 %} ## 3.5. Bringup 開始啟用 ### 3.5.1. 執行 roscore from Remote PC ``` $ roscore ``` ### 3.5.2. Bringup 啟動 TB3 1. 在 PC 上 Ctrl + Alt + T 開新 terminal,連上樹莓派的 IP address。使用預設的密碼 turtlebot ``` $ ssh pi@{IP_ADDRESS_OF_RASPBERRY_PI} ``` 2. 啟動基礎套件開始 TB3 應用。 ``` $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` 3. 如果使用的 TB3 是 burger,視窗會出現訊息 ``` SUMMARY ======== PARAMETERS * /rosdistro: kinetic * /rosversion: 1.12.13 * /turtlebot3_core/baud: 115200 * /turtlebot3_core/port: /dev/ttyACM0 * /turtlebot3_core/tf_prefix: * /turtlebot3_lds/frame_id: base_scan * /turtlebot3_lds/port: /dev/ttyUSB0 NODES / turtlebot3_core (rosserial_python/serial_node.py) turtlebot3_diagnostics (turtlebot3_bringup/turtlebot3_diagnostics) turtlebot3_lds (hls_lfcd_lds_driver/hlds_laser_publisher) ROS_MASTER_URI=http://192.168.1.2:11311 process[turtlebot3_core-1]: started with pid [14198] process[turtlebot3_lds-2]: started with pid [14199] process[turtlebot3_diagnostics-3]: started with pid [14200] [INFO] [1531306690.947198]: ROS Serial Python Node [INFO] [1531306691.000143]: Connecting to /dev/ttyACM0 at 115200 baud [INFO] [1531306693.522019]: Note: publish buffer size is 1024 bytes [INFO] [1531306693.525615]: Setup publisher on sensor_state [turtlebot3_msgs/SensorState] [INFO] [1531306693.544159]: Setup publisher on version_info [turtlebot3_msgs/VersionInfo] [INFO] [1531306693.620722]: Setup publisher on imu [sensor_msgs/Imu] [INFO] [1531306693.642319]: Setup publisher on cmd_vel_rc100 [geometry_msgs/Twist] [INFO] [1531306693.687786]: Setup publisher on odom [nav_msgs/Odometry] [INFO] [1531306693.706260]: Setup publisher on joint_states [sensor_msgs/JointState] [INFO] [1531306693.722754]: Setup publisher on battery_state [sensor_msgs/BatteryState] [INFO] [1531306693.759059]: Setup publisher on magnetic_field [sensor_msgs/MagneticField] [INFO] [1531306695.979057]: Setup publisher on /tf [tf/tfMessage] [INFO] [1531306696.007135]: Note: subscribe buffer size is 1024 bytes [INFO] [1531306696.009083]: Setup subscriber on cmd_vel [geometry_msgs/Twist] [INFO] [1531306696.040047]: Setup subscriber on sound [turtlebot3_msgs/Sound] [INFO] [1531306696.069571]: Setup subscriber on motor_power [std_msgs/Bool] [INFO] [1531306696.096364]: Setup subscriber on reset [std_msgs/Empty] [INFO] [1531306696.390979]: Setup TF on Odometry [odom] [INFO] [1531306696.394314]: Setup TF on IMU [imu_link] [INFO] [1531306696.397498]: Setup TF on MagneticField [mag_link] [INFO] [1531306696.400537]: Setup TF on JointState [base_link] [INFO] [1531306696.407813]: -------------------------- [INFO] [1531306696.411412]: Connected to OpenCR board! [INFO] [1531306696.415140]: This core(v1.2.1) is compatible with TB3 Burger [INFO] [1531306696.418398]: -------------------------- [INFO] [1531306696.421749]: Start Calibration of Gyro [INFO] [1531306698.953226]: Calibration End ``` ### 3.5.3. 在 RViz 載入 TurtleBot3 1. Remote 開新的 terminal 啟動 robot state publisher ``` $ roslaunch turtlebot3_bringup turtlebot3_remote.launch ``` 2. Remote PC 開新的 terminal 啟動 RViz ``` $ rosrun rviz rviz -d `rospack find turtlebot3_description`/rviz/model.rviz ``` ![](https://i.imgur.com/WY9Q3lb.png) ## 3.6. 基本操作 ### 3.6.1. Teleoperation 遙控 :::warning **警示**:在執行遙控前,請先從 SBC 啟動 TB3,且在桌上測試 TB3 時須注意以防掉落桌面。 ::: TurtleBot3 可用不同的設備來遙控。只要先確認 SBC 及 ROS 版本都先裝好了所需的 ROS packages。 {%youtube Z4s18hlazb4 %} :::info **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ::: #### 3.6.1.1. 鍵盤 :::info TIP: 在執行指令前,TURTLEBOT3_MODEL的參數 ${TB3_MODEL},需依照 TB3 的款式,更改為正確的參數- burger, waffle,或 waffle_pi ::: 1. 在 PC 上新開 terminal,執行 turtlebot3_teleop_key。如 TURTLEBOT3_MODEL 參數未指定,請替換 ${TB3_MODEL} 為 burger 或 waffle 或 waffle_pi ``` $ export TURTLEBOT3_MODEL=${TB3_MODEL} $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch ``` 3. 如果所需節點都開啟成功,terminal 會顯示操作訊息 ``` Control Your Turtlebot3 Moving around w a s d x w/x : increase/decrease linear velocity a/d : increase/decrease angular velocity space key, s : force stop CTRL-C to quit ``` :::info **如何預先定義好 TURTLEBOT3_MODEL** 如果 TURTLEBOT3_MODEL 參數已經預先定義在 .bashrc 檔內,則 export TURTLEBOT3_MODEL=${TB3_MODEL} 指令可以省略。當新的 terminal 開啟時,.bashrc 檔會自動載入 - 定義 TurtleBot3 Burger 為預設 model 範例 ``` $ echo 'export TURTLEBOT3_MODEL=burger' >> ~/.bashrc $ source ~/.bashrc ``` - 定義 TurtleBot3 Waffle Pi 為預設 model 範例 ``` $ echo 'export TURTLEBOT3_MODEL=waffle_pi' >> ~/.bashrc $ source ~/.bashrc ``` ::: #### 3.6.1.2. RC-100 遙控器 ROBOTIS RC-100B 遙控器已經預設在 TB3 OpenCR 控制板的韌體內。此遙控器須配合 BT-410 藍芽模組一起使用。TB3 Waffle Pi 款已經內含 RC-100B 遙控器及 BT-410 藍芽模組。當使用 RC-100 時,不需要執行任何節點,因為 turtlebot_core node 節點已在韌體內產生了 /cmd_vel topic 直接連接到 OpenCR 控制板。 ![](https://i.imgur.com/kr1quhv.png) 1. 連接 BT-410 到 OpenCR 的任一 UART port 2. 使用 RC-100 遙控 TB3 - Up / Down: 直線加速或減速 - Left / Right: 角速度加速或減速 #### 3.6.1.3. PS3 搖桿 1. 將 PS3 搖桿, 透過藍芽或是 USB 線連到 remote PC(桌電或筆電) 2. 安裝使用 PS3 搖桿的 teleoperation packages ``` $ sudo apt-get install ros-kinetic-joy ros-kinetic-joystick-drivers ros-kinetic-teleop-twist-joy ``` 3. 啟動 teleoperation node ``` $ roslaunch teleop_twist_joy teleop.launch ``` #### 3.6.1.4. XBOX 360 搖桿 1. 將 XBOX 360 搖桿, 透過無線連接器或是 USB 線連到 remote PC 2. 安裝使用 XBOX 360 搖桿的 teleoperation packages ``` $ sudo apt-get install xboxdrv ros-kinetic-joy ros-kinetic-joystick-drivers ros-kinetic-teleop-twist-joy ``` 3. 啟動 XBOX 360 搖桿 teleoperation node ``` $ sudo xboxdrv --silent $ roslaunch teleop_twist_joy teleop.launch ``` #### 3.6.1.5. Wii Remote 1. 將 Wii Remote 搖桿, 透過藍芽連到 remote PC 2. 安裝使用 Wii Remote 搖桿的 teleoperation packages ``` $ sudo apt-get install ros-kinetic-wiimote libbluetooth-dev libcwiid-dev $ cd ~/catkin_ws/src $ git clone https://github.com/ros-drivers/joystick_drivers.git $ cd ~/catkin_ws && catkin_make ``` 3. 啟動 Wii remote teleoperation node ``` $ rosrun wiimote wiimote_node $ rosrun wiimote teleop_wiimote ``` ### 3.6.2. Topic Monitor :::info 要檢視TB3的 topics,可使用 ROS 提供的 [**rqt**](http://wiki.ros.org/rqt),它是 ROS GUI 開發的 Qt-based 框架。它是一個工具可以顯示 TB3 所有 topics 包含 topic name,type,bandwidth,Hz,value in GUI等資訊 ::: 1. 從 PC 下指令開啟 rqt。如果 topic monitor 視窗沒有出現,可以選擇 plugin -> Topics -> Topic Monitor. ``` $ rqt ``` ![](https://i.imgur.com/RnSRoDH.png) 2. 當 topic monitor 載入,topic values 是沒有監控的。點擊每個 topic 前的 checkbox 方塊框打 V 來開始監控。 ![](https://i.imgur.com/6sYjNmu.png) 3. 點擊 checkbox 前的 ▶ 三角箭號圖示,來看詳細的 topic 資訊 ![](https://i.imgur.com/2N83rWm.png) - /battery_state 顯示電池狀態的有關資訊,如當下的電壓,尚有電池容量。 ![](https://i.imgur.com/rs6Hwwc.png) - /diagnostics 顯示連接到 TB3 的各種零件狀態,如 MPU9250、Dynamixel X 智能馬達、LDS-01 光達、電池及 OpenCR 控制板 ![](https://i.imgur.com/6MneRpc.png) - /odom 顯示 TB3 的測距訊息。Topic 有 encoder 數據的方向及位置資料。 ![](https://i.imgur.com/XNE96ZS.png) - /sensor_state 顯示 encoder 數值、電池、扭力等訊息 ![](https://i.imgur.com/N0EpXrY.png) - /scan 顯示所有 LDS 光達的數據訊息,如 angle_max and min, range_max and min, indicates, ranges 等 ![](https://i.imgur.com/hENspQW.png) 此外,只要添加了新的 topics,你就可以通過 rqt 程式來監控 topics 資訊。 # **4. SLAM 地圖定位** --- :::info Note: - 請在 Remote PC 上執行 SLAM - 在執行任何操作前,請務必先 Bringup 啟動 TB3 ::: **SLAM(Simultaneous Localization and Mapping)** 即時定位與地圖構建, 是一種通過估算在任一空間中的當前位置, 來繪製地圖的技術. SLAM 已是前代的 TurtleBot2 機器人就廣為所知的特色功能. 以下的影片展示 TurtleBot3, 如何以小巧且實惠的平台來精確的繪製地圖. {%youtube lkW4-dG2BCY %} 影片說明: - 機器人: TurtleBot3 Burger - 感測器: LiDAR 光達(Laser Distance Sensor) - ROS 套件: Gmapping / Cartographer - 地點: ROBOTIS 實驗室及總部 15 樓走廊 - 時間長: 55 分 - 距離: 共計 351 公尺 **Youtube TB3 SLAM 影片 2** {%youtube 7mEKrT_cKWI %} 影片2 說明: * 機器人: TurtleBot3 Burger and Waffle * 感測器: LiDAR 光達(Laser Distance Sensor, LDS-01) * ROS 套件: Gmapping * 地點: ROBOTIS 總部教室 * 時間長: 約 4 分 * 距離: 共計 15 公尺 **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ## 4.1. 執行 SLAM node 1. 從 Remote PC 執行 roscore ``` $ roscore ``` 2. TB3 SBC 啟用(Bringup)基本套件來開始 TB3 應用。如以啟用可跳過此步驟 - 在 Remote PC 開新的 terminal (Ctrl + Alt + T),連上 SBC 的 IP address。預設密碼是 turtlebot ``` $ ssh pi@{IP_ADDRESS_OF_RASPBERRY_PI} $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` 3. 在 Remote PC 開新的 terminal, 啟動 SLAM 檔案。GMapping 是預設的 SLAM 方法。另外 TURTLEBOT3_MODEL 的參數需設定 burger, waffle, 或 waffle_pi。 ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_slam turtlebot3_slam.launch ``` :::info **如何儲存 TURTLEBOT3_MODEL 參數?** 如果在 .bashrc 檔內 TURTLEBOT3_MODEL 參數已預設好,那 $ export TURTLEBOT3_MODEL=${TB3_MODEL} 指令可以忽略。 開新的 terminal 時, .bashrc 檔會自動載入 - 定義 TB3 Burger 為預設模型 ``` $ echo 'export TURTLEBOT3_MODEL=burger' >> ~/.bashrc $ source ~/.bashrc ``` - 定義 TB3 Waffle Pi 為預設模型 ``` $ echo 'export TURTLEBOT3_MODEL=waffle_pi' >> ~/.bashrc $ source ~/.bashrc ``` ::: :::info **使用其他的 SLAM 方法** - **GMapping** ([ROS Wiki](http://wiki.ros.org/gmapping),[Github](https://github.com/ros-perception/slam_gmapping)) 1. 在 Remote PC 安裝相關套件。(套件在章節 Remote PC 設定時,已經安裝好) 2. 執行 Gmapping SLAM node ``` $ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping ``` - **Cartographer** ([ROS Wiki](http://wiki.ros.org/cartographer),[Github](https://github.com/googlecartographer/cartographer)) 1. 在 Remote PC 安裝相關套件。 Cartographer 套件由 Google 開發,0.2.0版支援 ROS1 Kinetic。如要在 Kinetic 使用本套件,你應該下載原始碼後 build 此套件,而不要安裝已編譯的二進位套件。詳情可參考[官方 wiki 頁面](https://google-cartographer-ros.readthedocs.io/en/latest/#building-installation)。 ``` $ sudo apt-get install ninja-build libceres-dev libprotobuf-dev protobuf-compiler libprotoc-dev $ cd ~/catkin_ws/src $ git clone https://github.com/googlecartographer/cartographer.git $ git clone https://github.com/googlecartographer/cartographer_ros.git $ cd ~/catkin_ws $ src/cartographer/scripts/install_proto3.sh $ rm -rf protobuf/ $ rosdep install --from-paths src --ignore-src -r -y --os=ubuntu:xenial $ catkin_make_isolated --install --use-ninja ``` 2. 啟動 Cartographer SLAM node ``` $ source ~/catkin_ws/install_isolated/setup.bash $ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer ``` - **Hector** ([ROS Wiki](http://wiki.ros.org/hector_slam),[Github](https://github.com/tu-darmstadt-ros-pkg/hector_slam)) 1. 在 Remote PC 安裝相關套件。 ``` $ sudo apt-get install ros-kinetic-hector-mapping ``` 2. 啟動 Hector SLAM node ``` $ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=hector ``` - **Karto** ([ROS Wiki](http://wiki.ros.org/slam_karto),[Github](https://github.com/ros-perception/slam_karto)) 1. 在 Remote PC 安裝相關套件。 ``` $ sudo apt-get install ros-kinetic-slam-karto ``` 2. 啟動 Karto SLAM node ``` $ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=karto ``` - **Frontier Exploration** ([ROS Wiki](http://wiki.ros.org/frontier_exploration),[Github](https://github.com/paulbovbel/frontier_exploration)) Frontier Exploration 使用 gmapping 套件, 且下列套件也要一起安裝 1. 在 Remote PC 安裝相關套件。 ``` $ sudo apt-get install ros-kinetic-frontier-exploration ros-kinetic-navigation-stage ``` 2. 啟動 Frontier Exploration SLAM node ``` $ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=frontier_exploration ``` ::: ## 4.2. 執行 Teleoperation Node 一旦 SLAM node 成功執行,TB3 就會使用 teleoperation 開始對未知區域繪製地圖。此時避免機器人做出劇烈的運動很重要,比如直線速度變化太快或旋轉太快。使用機器人製作地圖時,機器人應該要掃描需量測環境的每個角落。它需要一些經驗來建立一個乾淨的地圖,所以我們需要多次練習 SLAM 以學習建圖技巧。 1. 在 Remote PC 開新 terminal 執行 teleoperation node。TURTLEBOT3_MODEL 參數需對應好 - burger,waffle,waffle_pi ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch Control Your TurtleBot3! --------------------------- Moving around: w a s d x w/x : increase/decrease linear velocity a/d : increase/decrease angular velocity space key, s : force stop CTRL-C to quit ``` 2. 開始探索及繪製地圖 ![](https://i.imgur.com/U5daA9T.png) ## 4.3. 微調指南 對不同的環境,Gmapping 可有許多參數來改變其效能。你可以在 [ROS Wiki](http://wiki.ros.org/gmapping) 網頁了解全部的參數,或參考 ROS Robot Programming 書的 Chapter 11 章。 本節微調指南會提供一些提示,供你配置一些重要參數。如果你想改變 SLAM 效能則會取決於你的環境,這些提示可能會幫助你並節省你的時間。 以下參數定義於 turtlebot3_slam/config/gmapping_params.yaml 檔內 ### 4.3.1. **maxUrange** 此參數設定光達最大可用範圍 ### 4.3.2. **map_update_interval** 此參數定義地圖更新的時間(以秒為單位)。如果此值設置越小,地圖更新頻率會更頻繁,此時電腦就需要更大的計算量。設置這個參數取決於你的環境。 ![](https://i.imgur.com/FDMg0C5.png) ### 4.3.3. **minimumScore** 此參數設定感測器掃描數據匹配結果,是成功或失敗的最小分數值。這可以減少機器人在大區域內的預期位置的誤差。如果設置正確,可以看到以下類似資訊。 ``` Average Scan Matching Score=278.965 neff= 100 Registering Scans:Done update frame 6 update ld=2.95935e-05 ad=0.000302522 Laser Pose= -0.0320253 -5.36882e-06 -3.14142 ``` 如果設置太高,則會看到下列警示 ``` Scan Matching Failed, using odometry. Likelihood=0 lp:-0.0306155 5.75314e-06 -3.14151 op:-0.0306156 5.90277e-06 -3.14151 ``` ### 4.3.4. **linearUpdate** 當機器人移動多遠掃描一次 ### 4.3.5. **angularUpdate** 當機器人轉動多大時掃描一次。最好設數值小於 linearUpdate 較佳。 ## 4.4. 儲存地圖 地圖會根據機器人移動時的 odometry 測距數據,tf 資訊,及感測器掃描的資訊來建圖。當 TB3 移動時,地圖數據會呈現在 RViz 視窗。在建好所需區域的完整地圖後,將地圖資料儲存在硬碟以備後續使用。 1. 啟動在 map_server package 中的 map_saver node 來產生地圖檔。地圖檔會儲存在 map_saver node 所在的資料夾。除非另外命名,map 是預設的地圖檔名,會產生 map.pgm 及 map.yaml 兩個檔。 ``` $ rosrun map_server map_saver -f ~/map ``` : -f 選項是用來指定資料夾位置以及要儲存的檔名。以上的指令是指 map.pgm 及 map.yaml 檔,會被儲存在 home 資料夾 ~/ (/home/${username}). ## 4.5. 地圖 地圖是 ROS 社群中常用的二維 **Occupancy Grid Map(OGM)** 地圖。儲存的地圖大略如下圖所示,**白色**是機器人可以移動的空白區域,**黑色**是機器人不能移動的佔用區域,**灰色**則是未知區域。地圖可在 Navigation 導航中使用。 ![](https://i.imgur.com/NKeh7u8.png) 下圖顯示了使用 TurtleBot3 創建大型地圖的結果。花了大約一個小時才製作出一幅移動距離約為 350 公尺的地圖。 ![](https://i.imgur.com/RfsuCzp.png) # **5. Navigation 導航** --- :::warning **警示**:此節 TB3 會移動及旋轉,請將機器人放置在安全的地面 ::: :::info **備註**: - 請在 Remote PC 執行 Navigation。 - 在執行任何操作前,請先 Bringup 啟動 TB3。 - 導航需要使用 SLAM 產生的地圖。請確認有地圖數據。 ::: **Navigation 導航**是將機器人從一個位置移動到給定環境中的指定目的地。為此,地圖必需要包含給定環境中的家具,物體和牆壁的幾何信息。如前面的 SLAM 章節所述,地圖是由感測器得到的距離訊息,和機器人本身的方位訊息來創建。 導航讓機器人能夠通過使用圖資、機器人編碼器、IMU 感測器、和距離感測器等,從當前的方位,移動到地圖上指定的目標方位。執行此任務的過程如下節所述。 ## 5.1. 執行 Navigation node 1. 從 Remote PC 執行 roscore。如已執行可跳過此步驟。 ``` $ roscore ``` 2. TB3 SBC 啟用(Bringup)基本套件來開始 TB3 應用。如以啟用可跳過此步驟 - 在 Remote PC 開新的 terminal (Ctrl + Alt + T),連上 SBC 的 IP address。預設密碼是 turtlebot ``` $ ssh pi@{IP_ADDRESS_OF_RASPBERRY_PI} $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` 3. 在 Remote PC 開新的 terminal, 啟動 Navigation 檔案。另外 TURTLEBOT3_MODEL 的參數需設定 burger, waffle, 或 waffle_pi。 ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=$HOME/map.yaml ``` :::info **如何儲存 TURTLEBOT3_MODEL 參數?** 如果在 .bashrc 檔內 TURTLEBOT3_MODEL 參數已預設好,那 $ export TURTLEBOT3_MODEL=${TB3_MODEL} 指令可以忽略。 開新的 terminal 時, .bashrc 檔會自動載入 - 定義 TB3 Burger 為預設模型 ``` $ echo 'export TURTLEBOT3_MODEL=burger' >> ~/.bashrc $ source ~/.bashrc ``` - 定義 TB3 Waffle Pi 為預設模型 ``` $ echo 'export TURTLEBOT3_MODEL=waffle_pi' >> ~/.bashrc $ source ~/.bashrc ``` ::: ## 5.2. 估計 Initial Pose **Initial Pose Estimation**必須在跑 Navigation 之前就執行,因為這個程序會初始化 AMCL 參數,這在進行 Navigation 時很重要。 TurtleBot3 必須正確定位在地圖上,LDS 感測器數據與顯示的地圖要完全重疊。 1. 點擊 RViz 選單的 2D Pose Estimate 鍵 ![](https://i.imgur.com/TExqd9f.png) 2. 在地圖上點擊真正機器人的所在位置,拉出大的綠色箭號指向機器人正面的方向。 3. 重複步驟 1 跟 2,直到 LDS 感測器的數據跟儲存地圖正確的重疊。 ![](https://i.imgur.com/FT0c7LM.png) 4. 啟動 keyboard teleoperation node 來準確定位在地圖上的機器人位置 ``` $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch ``` 5. 來回移動機器人一點以收集周圍環境信息,並縮小 TurtleBot3 在地圖上的估計位置,地圖上是以微小的綠色箭頭顯示。 ![](https://i.imgur.com/X3Dq64y.png) ![](https://i.imgur.com/H9R3zpy.png) 6. 在 teleop node terminal 上按 Ctrl + C 來結束 keyboard teleoperation node,這可以防止在導航期間從多個節點發布不同的 cmd_vel 值。 ## 5.3. Set Navigation Goal 設定導航目標 1. 在 RViz 選單點擊 Navigation2 Goal 鍵 ![](https://i.imgur.com/eV0DgMc.png) 2. 在地圖上點擊來設定機器人的目的地,並拉動綠色箭號,當作機器人抵達目的地後要面對的方向 - 綠色箭號是指定機器人目的地的一個標記 - 箭頭的根部是機器人目的地的 x 和 y 座標位置,箭頭指向的方位是機器人的 theta (θ) 角方向。 - 當 x, y, θ 都決定後,TB3 就會開始往目的地移動。 ![](https://i.imgur.com/sEYo8RI.jpg) {%youtube VYlMywwYALU %} :::info **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ::: :::info 有關 **Navigation**的詳細資訊 - 機器人會依據 global path planner 產生到達 Navigation Goal 目的地的路徑,並依路徑移動。如果路徑上碰到障礙物,Navigation 會使用 local path planner 來避開障礙物。 - 如果不能產生到達 Navigation Goal 目的地的路徑時,則會造成 Navigation Goal 設定失敗。如果在機器人到達目的地前,要停止機器人移動,可以將 TB3 當前位置設為 Navigation Goal 即可。 - [官方 ROS Navigation Wiki](http://wiki.ros.org/navigation) ::: ## 5.4. Tuning 微調指南 對不同的機器人,Navigation stack 有許多參數可用來改變其效能。你可以在 [ROS Navigation Wiki 網頁](http://wiki.ros.org/navigation),[Basic Navigation Tuning Guide](http://wiki.ros.org/navigation/Tutorials/Navigation%20Tuning%20Guide),[ROS Navigation Tuning Guide by Kaiyu Zheng](http://kaiyuzheng.me/documents/navguide.pdf) 了解全部的參數,或參考 ROS Robot Programming 書的 Chapter 11 章。 本微調指南提供一些提示,供你配置重要參數。如果你想改變效能則會取決於你的環境,這些提示可能會幫助你並節省你的時間。 ### 5.4.1. **inflation_radius** - 定義於 turtlebot3_navigation/param/costmap_common_param_${TB3_MODEL}.yaml - 這個參數可把障礙放大到膨脹半徑的區域。路徑會被規劃,而不會穿過膨脹區域。將其值設置為比機器人半徑大是比較保險的。要了解更多訊息,請參閱[costmap_2d wiki 網頁](http://wiki.ros.org/costmap_2d#Inflation)。 ![](https://i.imgur.com/R7BPyR0.png) ### 5.4.2. **cost_scaling_factor** - 定義於 turtlebot3_navigation/param/costmap_common_param_${TB3_MODEL}.yaml - 此因子會乘以 cost value。因為它是一個反比的因素,所以如這個參數增加,cost value 就會降低。 ![](https://i.imgur.com/CpHcjRA.png) 最好的路徑是讓機器人穿過障礙物之間的中心。 將此因子設置得較小以遠離障礙物。 ### 5.4.3. **max_vel_x** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 此因子被設定為平移速度的最大值。 ### 5.4.4. **min_vel_x** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 此因子被設定為平移速度的最小值。如果設為負值,機器人可以向後移動。 ### 5.4.5 **max_trans_vel** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 最大平移速度的實際值。機器人不能比此值更快。 ### 5.4.6. **min_trans_vel** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 最小平移速度的實際值。機器人不能比此值還慢。 ### 5.4.7. **max_rot_vel** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 最大旋轉速度的實際值。機器人不能比此值更快。 ### 5.4.8. **min_rot_vel** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 最小旋轉速度的實際值。機器人不能比此值還慢。 ### 5.4.9. **acc_lim_x** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 平移加速度限制的實際值。 ### 5.4.10. **acc_lim_theta** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 旋轉加速度限制的實際值。 ### 5.4.11. **xy_goal_tolerance** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 機器人到達目標方位時所允許的 x,y 距離。 ### 5.4.12. **yaw_goal_tolerance** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 當機器人達到其目標方位時所允許的 yaw 偏航角度。 ### 5.4.13. **sim_time** - 定義於 turtlebot3_navigation/param/dwa_local_planner_params_${TB3_MODEL}.yaml - 此因子是以秒為單位設定前向模擬(forward simulation)。值設太低,會沒有足夠時間來通過狹窄地區。值設太高則不允許快速轉動。你可以在下圖中看到黃線長度的偏差。 ![](https://i.imgur.com/TqbKBEi.png) # **6. Simulation 模擬** --- :::info Note: - 請在 Remote PC 跑 Simulation - 第一次跑 Simulation 時會花比較長的時間來設定環境 ::: :::success TurtleBot3 支持模擬開發環境,可以在模擬中使用虛擬機器人進行編程開發。有兩種開發環境可以做到這一點,一種是使用**帶有 3D 可視化工具 RViz 的假節點 fake node**;另一種是使用 **3D 機器人模擬器 Gazebo**。 - **假節點 fake node**適合用來測試機器人模型和移動,但它不支援感測器。 - 如果需要執行 SLAM 或 Navigation,**Gazebo**會是一個可行的解決方案,因為它支持 IMU、LDS 和攝影機等感測器。 在本教程中,將主要介紹在 ROS 開發人員中使用最廣泛的 Gazebo 模擬器。 - [**Gazebo 教學**](http://gazebosim.org/tutorials) ::: ## 6.1. Gazebo Simulation {%youtube UzOoJ6a_mOg %} :::info **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ::: Gazebo Simulation 使用 ROS Gazebo package,因此必須事先安裝支援 ROS1 Kinetic 的 Gazebo 版本。 ### 6.1.1. 安裝 Simulation Package **TurtleBot3 Simulation Package** 需要 turtlebot3 及 turtlebot3_msgs packages 為先決條件。沒有這兩個 packages,無法啟動 Simulation。 如果還沒有安裝所需 packages,可參照 Remote PC 設定章節來安裝。 ``` $ cd ~/catkin_ws/src/ $ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git $ cd ~/catkin_ws && catkin_make ``` ### 6.1.2. 啟動 Simulation World 世界地圖 TB3 有三種模擬的世界地圖可選擇。啟動 Gazebo 後可以任選其一。 :::info 啟動一個新的世界地圖前,需確認完全關閉前一個地圖 ::: 1. Empty World 空白世界地圖 ![](https://i.imgur.com/iAaFFfd.png) ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch ``` 2. TurtleBot3 World 世界地圖 ![](https://i.imgur.com/LNTEQ0d.png) ``` $ export TURTLEBOT3_MODEL=waffle $ roslaunch turtlebot3_gazebo turtlebot3_world.launch ``` 3. TurtleBot3 House 房間地圖 ![](https://i.imgur.com/bK9B8a9.png) ``` $ export TURTLEBOT3_MODEL=waffle_pi $ roslaunch turtlebot3_gazebo turtlebot3_house.launch ``` :::info **備註**: 如果首次執行 TurtleBot3 House,則下載地圖文件需要幾分鐘或更長時間,具體取決於網路速度 ::: ### 6.1.3. 操作 TB3 要使用鍵盤來控制 TB3,需在新的 terminal 啟動 teleoperation node ``` $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch ``` :::success **如何執行自動避障** 要先準備一個簡單的 collision avoidance node 來讓機器人與障礙物保持一定距離,並轉向避免碰撞 要在 TurtleBot3 World 世界地圖內自動駕駛 TB3,請依照以下說明操作 1. Ctrl + C 結束 turtlebot3_teleop_key node,關閉 teleop node 2. 在 terminal 輸入指令 ``` $ roslaunch turtlebot3_gazebo turtlebot3_simulation.launch ``` ::: :::success **如何可視化 Simulation data(RViz2)?** 當 simulation 進行時,RViz 可以看到已公布的 topics。在新的 terminal 啟動 RViz ``` $ roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch ``` ![](https://i.imgur.com/MYLjIjb.png) ::: ## 6.2. SLAM 模擬 我們可以在 Gazebo 模擬器中來用虛擬機器人來進行虛擬 SLAM,而無須使用實體的機器人來實作。在 Gazebo 中,你可以選擇上面提到的各種地圖環境和機器人模型來進行模擬,SLAM 模擬跟用 TB3 實作 SLAM 會很相似。 下列操作會需要之前章節為先決條件,請回看 Simulation 章節內容。 ### 6.2.1. 開啟 Simulation World 世界地圖 Gazebo 有三個地圖可開啟,但因要 SLAM 來建地圖,建議使用 **TurtleBot3 World** 或 **TurtleBot3 House** 地圖。 使用下列指令來開啟地圖,此範例載入 TurtleBot3 World 世界地圖。也需注意 TURTLEBOT3_MODEL 所對應的參數 burger, waffle, waffle_pi ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_gazebo turtlebot3_world.launch ``` :::success **如何載入 TurtleBot3 House 地圖** ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_gazebo turtlebot3_house.launch ``` ::: ### 6.2.2. 執行 SLAM Node 在 Remote PC 開新 terminal(Ctrl + Alt + T) 並跑 SLAM node。預設是使用 Gmapping SLAM 方法。也需注意 TURTLEBOT3_MODEL 所對應的參數 burger, waffle, waffle_pi ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping ``` ### 6.2.3. 執行 Teleoperation Node 在 Remote PC 開新 terminal(Ctrl + Alt + T) 並跑 teleoperation node。也需注意 TURTLEBOT3_MODEL 所對應的參數 burger, waffle, waffle_pi ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch Control Your TurtleBot3! --------------------------- Moving around: w a s d x w/x : increase/decrease linear velocity a/d : increase/decrease angular velocity space key, s : force stop CTRL-C to quit ``` ### 6.2.4. 儲存地圖 當地圖成功產生後,在 Remote PC 開新 terminal(Ctrl + Alt + T) 並儲存地圖 ![](https://i.imgur.com/JZK7zZ5.png) ``` $ rosrun map_server map_saver -f ~/map ``` ![](https://i.imgur.com/Q5ozbRR.png) 所儲存的 map.pgm 檔 :::info **如何多個 TB3 一起 SLAM?** 要建立多個機器人用的地圖,需要 multirobot-map-merge package。 起依照以下的說明進行,來操作多個 TB3。 1. 安裝需要的 packages ``` $ sudo apt-get install ros-kinetic-multirobot-map-merge ``` 2. 將多個 TB3 載入 TurtleBot3 House 地圖。載入三個 TB3 都已設好初始位置及方位。 ``` $ roslaunch turtlebot3_gazebo multi_turtlebot3.launch ``` ![](https://i.imgur.com/4SuW3GP.png) 3. 為每個 TB3 啟動 SLAM ``` $ ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_slam turtlebot3_gmapping.launch set_base_frame:=tb3_0/base_footprint set_odom_frame:=tb3_0/odom set_map_frame:=tb3_0/map $ ROS_NAMESPACE=tb3_1 roslaunch turtlebot3_slam turtlebot3_gmapping.launch set_base_frame:=tb3_1/base_footprint set_odom_frame:=tb3_1/odom set_map_frame:=tb3_1/map $ ROS_NAMESPACE=tb3_2 roslaunch turtlebot3_slam turtlebot3_gmapping.launch set_base_frame:=tb3_2/base_footprint set_odom_frame:=tb3_2/odom set_map_frame:=tb3_2/map ``` 4. 將每個 TB3 各自的地圖數據合併為一個地圖數據 ``` $ roslaunch turtlebot3_gazebo multi_map_merge.launch ``` 5. 啟動 RViz ``` $ rosrun rviz rviz -d `rospack find turtlebot3_gazebo`/rviz/multi_turtlebot3_slam.rviz ``` 6. 操作每個 TB3 ``` $ ROS_NAMESPACE=tb3_0 rosrun turtlebot3_teleop turtlebot3_teleop_key $ ROS_NAMESPACE=tb3_1 rosrun turtlebot3_teleop turtlebot3_teleop_key $ ROS_NAMESPACE=tb3_2 rosrun turtlebot3_teleop turtlebot3_teleop_key ``` ![](https://i.imgur.com/9lwqbN8.png) 7. 儲存地圖 ``` $ rosrun map_server map_saver -f ~/map ``` ::: ## 6.3. Navigation Simulation 模擬導航 就如在 Gazebo 模擬器跑虛擬 SLAM,你也可以進行虛擬導航 Navigation,而無須使用實體的機器人來實作。當然在跑虛擬 Navigation 前,必須準備好合適的地圖環境。虛擬導航跟實作會很相似。 ### 6.3.1. 開啟模擬的世界地圖 :::info Ctrl + C 來結束之前章節開啟的全部應用 ::: 在之前 SLAM 章節使用 TurtleBot3 World 地圖。相同的 Gazebo 環境也用在模擬 Navigation。一樣要注意所使用的 TURTLEBOT3_MODEL 參數- burger, waffle, waffle_pi。 ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_gazebo turtlebot3_world.launch ``` :::success **如何載入 TurtleBot3 House 地圖** ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_gazebo turtlebot3_house.launch ``` ::: ### 6.3.2. 執行 Navigation Node 在 Remote PC 開新 terminal(Ctrl + Alt + T) 並跑 Navigation node。 ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=$HOME/map.yaml ``` ### 6.3.3. 估計 Initial Pose 初始方位 **Initial Pose Estimation**必須在跑 Navigation 之前就執行,因為這個程序會初始化 AMCL 參數,這在進行 Navigation 時很重要。 TurtleBot3 必須正確定位在地圖上,LDS 感測器數據與顯示的地圖要完全重疊。 1. 點擊 RViz 選單的 2D Pose Estimate 鍵 ![](https://i.imgur.com/TExqd9f.png) 2. 在地圖上點擊真正機器人的所在位置,拉出大的綠色箭號指向機器人正面的方向。 3. 重複步驟 1 跟 2,直到 LDS 感測器的數據跟儲存地圖正確的重疊。 ![](https://i.imgur.com/FT0c7LM.png) 4. 啟動 keyboard teleoperation node 來準確定位在地圖上的機器人位置 ``` $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch ``` 5. 來回移動機器人一點以收集周圍環境信息,並縮小 TurtleBot3 在地圖上的估計位置,地圖上是以微小的綠色箭頭顯示。 ![](https://i.imgur.com/X3Dq64y.png) ![](https://i.imgur.com/H9R3zpy.png) 6. 在 teleop node terminal 上按 Ctrl + C 來結束 keyboard teleoperation node,這可以防止在導航期間從多個節點發布不同的 cmd_vel 值。 ### 6.3.4. Set Navigation Goal 設定導航目標 1. 在 RViz 選單點擊 Navigation2 Goal 鍵 ![](https://i.imgur.com/eV0DgMc.png) 2. 在地圖上點擊來設定機器人的目的地,並拉動綠色箭號,當作機器人抵達目的地後要面對的方向 - 綠色箭號是指定機器人目的地的一個標記 - 箭頭的根部是機器人目的地的 x 和 y 座標位置,箭頭指向的方位是機器人的 theta (θ) 角方向。 - 當 x, y, θ 都決定後,TB3 就會開始往目的地移動。 ![](https://i.imgur.com/sEYo8RI.jpg) {%youtube VYlMywwYALU %} :::info **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ::: ## 6.4. Fake Node Simulation {%youtube iHXZSLBJHMg %} :::info **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ::: 要使用 turtlebot3_fake_node,你需要安裝 turtlebot3_simulation 套件。按照以下指示安裝套件。 :::success **提示**:Ubuntu 的 Terminal (終端機)可以在螢幕左上方的 Search 圖示找到. 快捷鍵可以使用 Ctrl-Alt-T. ::: :::info **備註**:turtlebot3_simulation 套件需要事先安裝 turtlebot3 套件和 turtlebot3_msgs 套件作為先決條件。如果你沒有在 PC Setup 設定章節中安裝先決套件,請先安裝此 2 個先決套件。 ::: ``` $ cd ~/catkin_ws/src/ $ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git $ cd ~/catkin_ws && catkin_make ``` 要啟動虛擬機器人,請執行 turtlebot3_fake 套件中的 turtlebot3_fake.launch 檔,如下所示。 turtlebot3_fake 是一個非常簡單的模擬節點,可以在沒有實際機器人的情況下來模擬機器人運行。你甚至可以在 RViz 工具中,用 teleoperation node 遙控節點來遙控虛擬的 TurtleBot3 機器人。 須注意對應的 TURTLEBOT3_MODEL 參數- burger, waffle, waffle_pi ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_fake turtlebot3_fake.launch ``` ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch ``` ## 6.5. 單獨的 Gazebo 模擬 :::info **備註**:本節的說明僅針對想要在沒有 ROS 的環境下模擬 TB3 的用戶而開發。不過,我們強烈建議使用 ROS 環境來模擬 TB3 機器人。 ::: 1. 安裝 Gazebo7 程式庫 ``` $ sudo apt-get install libgazebo7-dev ``` 2. 從 Github 下載 Gazebo Plugin 原始碼 ``` $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_gazebo_plugin ``` 3. 將 Gazebo Plugin 插件路徑加入 .bashrc 檔 ``` $ nano ~/.bashrc ``` :::success **提示**: turtlebot3_gazebo_plugin path = ~/turtlebot3_gazebo_plugin ::: ``` export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:${turtlebot3_gazebo_plugin path}/build export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${turtlebot3_gazebo_plugin path}/models ``` 4. Make 及 Build ``` $ cd ${turtlebot3_gazebo_plugin path} $ mkdir build $ cd build $ cmake .. $ make ``` 5. 執行 Gazebo plugin 插件 :::success **提示**: 在執行指令前,你必須先指定使用的 TurtleBot3 模型。指令內的 ${TB3_MODEL} 所對應的 TB3 模型名稱,有 burger,waffle,waffle_pi 三種。 ::: ``` $ cd ${turtlebot3_gazebo_plugin} $ gazebo worlds/turtlebot3_${TB3_MODEL}.world ``` ![](https://i.imgur.com/phZ6JHR.png) ![](https://i.imgur.com/AQ4TRyG.png) 6. 鍵盤遙控操作 ``` w - set linear velocity up x - set linear velocity down d - set angular velocity up a - set angular velocity down s - set all velocity to zero ``` 7. Topic Subscribe 訂閱 topic 指令 - 顯示全部 topic ``` $ gz topic -l ``` - 訂閱光達 scan 數據 ``` $ gz topic -e /gazebo/default/user/turtlebot3_${TB3_MODEL}/lidar/hls_lfcd_lds/scan ``` - 訂閱攝影機影像數據 for Waffle 鬆餅款 (Intel RealSense R200) ``` $ gz topic -e /gazebo/default/user/turtlebot3_waffle/image/intel_realsense_r200/image ``` for Waffle Pi 鬆餅 Pi 款(Raspberry Pi camera) ``` $ gz topic -e /gazebo/default/user/turtlebot3_waffle_pi/image/raspberry_pi_cam/image ``` 8. 執行 listener ``` $ cd ${turtlebot3_gazebo_plugin}/build $ ./lidar_listener ${TB3_MODEL} ``` 9. 打開新的 terminal 視窗輸入下方指令。 ``` $ cd ${turtlebot3_gazebo_plugin}/build $ ./image_listener ${TB3_MODEL} ``` **參考資源**: - [Gazebo API](http://osrf-distributions.s3.amazonaws.com/gazebo/api/dev/index.html) - [How to contribute model](http://gazebosim.org/tutorials?tut=model_contrib&cat=build_robot) - [How to make model](http://gazebosim.org/tutorials?tut=build_model&cat=build_robot) - [Tutorial for making Hello World plugin](http://gazebosim.org/tutorials?tut=plugins_hello_world&cat=write_plugin) - [Tutorial for making model plugin](http://gazebosim.org/tutorials?cat=guided_i&tut=guided_i5) - [Tutorial for making sensor plugin](http://gazebosim.org/tutorials?tut=contact_sensor) - [Tutorial for topic subscription](http://gazebosim.org/tutorials?tut=topics_subscribed) # **7. Manipulation 機器手臂** --- :::info **備註**: - 操作的內容已在 Ubuntu 16.04 及 ROS Kinetic Kame 版本上測試過。 - 如要了解更多 OpenManipulator-X 機器手臂資訊,請參考 [OpenManipulator-X 線上手冊(英)](https://emanual.robotis.com/docs/en/platform/openmanipulator_x/overview/) ::: :::warning - 樹莓派 4 及 Jetson Nano 不支援 Kinetic。請選擇別的 ROS 或 ROS2 版本 - 此手冊內容如有更新變動,不會預先通知。 ::: :::success **提示**:Ubuntu 的 Terminal (終端機)可以在螢幕左上方的 Search 圖示找到. 快捷鍵可以使用 Ctrl-Alt-T. ::: ## 7.1. TurtleBot3 跟 OpenManipulator-X 機器手臂 ![](https://i.imgur.com/zVrFxkE.png) ROBOTIS 的 OpenManipulator-X 小型機器手臂,是支援 ROS 的機器手臂之一。其優點是使用 Dynamixel 智能馬達跟 3D 列印出來的零配件,可製造出成本低的機器手臂。 OpenManipulator-X 小型機器手臂的優點,是可與 TB3 Waffle 跟 TB3 Waffle Pi 款相容。通過這種相容性,可以彌補手臂自由度的不足,並可通過 TB3 已加載的 SLAM 和 Navigation 導航的功能,讓 TB3 變成更具完整性的服務機器人。TB3 及 OpenManipulator-X 的結合可以作為 mobile manipulator 移動式機器手臂使用,執行下列影片中的操作。 {%youtube Qhvk5cnX2hM %} {%youtube P82pZsqpBg0 %} {%youtube DLOq8yNcCoE %} :::info **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ::: ## 7.2. 手臂軟體設定 :::info **備註**:在安裝 open_manipulator_with_tb3 套件之前,請確認先前已經在你的 RemotePC(桌電或筆電)和 SBC(Raspberry Pi 3) 設定時,都已安裝了turtlebot3 和 open_manipulator 套件。 ::: 1. 在 Remote PC 上下載,build OpenManipulator-X 相關套件,以便後續手臂組裝後使用 ``` $ cd ~/catkin_ws/src/ $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_manipulation.git $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_manipulation_simulations.git $ git clone https://github.com/ROBOTIS-GIT/open_manipulator_dependencies.git $ sudo apt install ros-kinetic-ros-control* && ros-kinetic-control* && ros-kinetic-moveit* $ cd ~/catkin_ws && catkin_make ``` ## 7.3. 手臂硬體組裝 - [CAD 檔](http://www.robotis.com/service/download.php?no=767) for (TurtleBot3 Waffle Pi + OpenMANIPULATOR) ![](https://i.imgur.com/uuJYUEI.png) - 首先拆下 LDS-01 or LDS-02 光達並將其移到 TurtleBot3 的前半部(紅圈代表螺絲的建議位置)。 - 接著在 TurtleBot3 上固定 OpenManipulator 手臂(黃色圓圈表示螺絲的建議位置)。 ![](https://i.imgur.com/Lmu2YDc.png) ![](https://i.imgur.com/Uan7SJU.png) TurtleBot3 Waffle Pi + OpenMANIPULATOR-X 組合示意圖 ## 7.4. OpenCR 控制板設定 :::info **備註**:要使用 OpenManipulator-X 機器手臂,需要先上傳韌體到 OpenCR,你可以選擇一種上傳韌體的方法。但我們強烈建議使用 **shell script 腳本**。 如果需要修改 TurtleBot3 的韌體,則可以使用第二種方法。 - 方法 1:[Shell script 腳本](https://emanual.robotis.com/docs/en/platform/turtlebot3/manipulation/#shell-script),使用 shell script 腳本上傳預建好的二進位檔。 - 方法 2:[Arduino IDE](https://emanual.robotis.com/docs/en/platform/turtlebot3/manipulation/#arduino-ide),build 原始碼並使用 Arduino IDE 上傳生成的二進位檔。 OpenCR Arduino board manager 不支援 Arm-based 的處理器,如 Raspberry or Jetson Nano。建議在 PC 上操作。 ::: :::warning **警示**:在進行上傳韌體到 OpenCR 前,請確保所有 DYNAMIXEL 智能馬達都已連接到 OpenCR 控制板。 否則,樹莓派可能會出現意外問題。 ::: 將 OpenManipulator-X 手臂安裝到 TB3 後,需要上傳控制手臂馬達的韌體到 OpenCR 板,請依照下列步驟。 1. TB3 SBC 端: 下載 OpenCR 韌體到 SBC 樹莓派,上傳正確的韌體 ``` $ export OPENCR_PORT=/dev/ttyACM0 $ export OPENCR_MODEL=om_with_tb3 $ rm -rf ./opencr_update.tar.bz2 $ wget https://github.com/ROBOTIS-GIT/OpenCR-Binaries/raw/master/turtlebot3/ROS1/latest/opencr_update.tar.bz2 $ tar -xvf opencr_update.tar.bz2 $ cd ./opencr_update $ ./update.sh $OPENCR_PORT $OPENCR_MODEL.opencr ``` 2. 當上傳完成,你會看到 terminal 上出現 **jump_to_fw** 的字串。 :::danger **注意身體位置** 當韌體上傳成功,OpenCR 板會重開機,OpenManipulator-X 手臂會移動到初始姿態。建議你將手臂先擺放跟下圖類似的姿態,避免手臂初始化時,會跟身體做碰觸。 ![](https://i.imgur.com/hBSACtG.png) ::: ### 7.4.1. 使用 Arduino IDE 來上傳韌體 :::info OpenCR board manager 並不支援 ARM based SBC 的 Arduino IDE,如樹莓派 或 NVidia Jetson。 請在 PC 上用 Arduino IDE 來上傳韌體。 ::: 1. 如 PC 的 OS 是 Linux,下列指令設定 OpenCR 的 USB port。如果其他 OS(OSX or Windows),可跳過此步驟。 ``` $ wget https://raw.githubusercontent.com/ROBOTIS-GIT/OpenCR/master/99-opencr-cdc.rules $ sudo cp ./99-opencr-cdc.rules /etc/udev/rules.d/ $ sudo udevadm control --reload-rules $ sudo udevadm trigger $ sudo apt install libncurses5-dev:i386 ``` 2. 安裝 Arduino IDE - [下載最新的 Arduino IDE](https://www.arduino.cc/en/software) 3. 安裝好後,執行 Arduino IDE 4. 按 Ctrl + , 來打開 Preferences menu 5. 在 Additional Boards Manager URLs 輸入下列位址 ``` https://raw.githubusercontent.com/ROBOTIS-GIT/OpenCR/master/arduino/opencr_release/package_opencr_index.json ``` ![](https://i.imgur.com/zcRVecI.png) 6. 打開 TurtleBot3 with OpenMANIPULATOR 韌體。因你的平台選擇對應的韌體。 - TurtleBot3 with OpenMANIPULATOR : **File > Examples > turtlebot3 > turtlebot3_with_open_manipulator > turtlebot3_with_open_manipulator_core** 7. 連接 OpenCR 板到 PC 上,從 Tools > Board 選單選擇 OpenCR > OpenCR Board 8. 從 Tools > Port 選單中選擇連接 OpenCR 的 USB port 9. upload 圖示或 Ctrl+U 來上傳韌體 sketch ![](https://i.imgur.com/S3zNgU6.png) ![](https://i.imgur.com/fxp7cNS.png) 10. 如果上傳失敗,可以嘗試在 recovery mode 下重新上傳韌體。OpenCR 的 recovery mode 啟動順序如下。在 recovery mode 時,OpenCR 的 STATUS led 燈會定時的閃爍。 - 按住 PUSH SW2 鍵 - 按一下 Reset 鍵然後鬆開 - 再鬆開 PUSH SW2 鍵 ![](https://i.imgur.com/ZilkkEU.png) ## 7.5. Bringup 啟動 TB3 與機器手臂 :::info **備註**:請再次確認 [turtlebot3_core.launch](https://github.com/ROBOTIS-GIT/turtlebot3/blob/467c76bc4fa2e34162f57107388839d82d3bcc0e/turtlebot3_bringup/launch/turtlebot3_core.launch#L5) 檔內的 OpenCR usb port name,已指派給 PC ::: ### 7.5.1. 執行 roscore 在 Remote PC 新開 terminal 執行 roscore ``` $ roscore ``` ### 7.5.2. 定義 TurtleBot3 Model 在 TB3 SBC 新開 terminal,定義 .bashrc 檔內 TURTLEBOT3_MODEL 參數,waffle or waffle_pi ``` $ export TURTLEBOT3_MODEL=waffle_pi ``` ### 7.5.3. 啟動 TB3 在 TB3 SBC,啟動 TB3 開始 rosserial 及 LDS sensor ``` $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` ## 7.6. 模擬 使用 Gazebo 模擬器來模擬 TB3與機器手臂 ### 7.6.1. 執行 Gazebo [**Remote PC**] 在 Gazebo 模擬器內載入 TB3 with OpenManipulator-X 的檔案 ``` $ roslaunch turtlebot3_manipulation_gazebo turtlebot3_manipulation_gazebo.launch ``` ![](https://i.imgur.com/bdUDx22.png) ### 7.6.2. 執行 move_group node [**Remote PC**] 要能夠使用 Moveit 功能,需啟動 move_group node。使用下列指令開啟 Gazebo,點擊 [▶] 鍵來開始模擬。如果啟動成功,會出現 “You can start planning now!” 訊息。 ``` $ roslaunch turtlebot3_manipulation_moveit_config move_group.launch ``` ### 7.6.3. 執行 RViz [**Remote PC**] 在 RViz 內可以使用 Moveit 特色,Moveit 環境數據在 moveit.rviz 檔內設置後給 RViz 讀取。 你可以使用 interactive marker 控制已安裝的機器手臂,並模擬 goal position 的移動,這有助於通過事先的模擬移動,來防止可能的物理性接觸。 ``` $ roslaunch turtlebot3_manipulation_moveit_config moveit_rviz.launch ``` ![](https://i.imgur.com/mJC0Eo8.png) ### 7.6.4. 執行 ROBOTIS GUI Controller 圖形介面控制器 [**Remote PC**] 你也可以使用 ROBOTIS GUI 在 Gazebo 內控制 OpenManipulator-X 機器手臂。GUI controller 支援 **Task Space Control** 及 **Joint Space Control** 兩種方式由你選擇。 - Task Space Control: 基於 OpenMANIPULATOR-X 末端執行器的有效夾持位置(表示為爪手之間的小紅色立方體)進行控制。 - Joint Space Control: 根據每個關節角度進行控制。 ``` $ roslaunch turtlebot3_manipulation_gui turtlebot3_manipulation_gui.launch ``` ![](https://i.imgur.com/CTTz6PQ.png) ## 7.7. 操作實體的 OpenManipulator-X 手臂 請依照下列指示來操作 ### 7.7.1. 執行 roscore [**Remote PC**] 在 ROS1 執行 roscore ``` $ roscore ``` ### 7.7.2. 執行 Bringup 啟動 [**TB3 SBC**] 在 TB3 SBC,啟動 TB3 開始 rosserial 及 LDS sensor ``` $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` [**Remote PC**] 在 TB3 執行 OpenManipulator-X 的 Bringup 啟動套件 ``` $ roslaunch turtlebot3_manipulation_bringup turtlebot3_manipulation_bringup.launch ``` ### 7.7.3. 執行 move_group node ``` $ roslaunch turtlebot3_manipulation_moveit_config move_group.launch ``` ### 7.7.4. 執行 RViz [**Remote PC**] 在 RViz 上觀看數據及使用 interactive marker ``` $ roslaunch turtlebot3_manipulation_moveit_config moveit_rviz.launch ``` ### 7.7.5. 執行 ROBOTIS GUI Controller [**Remote PC**] 使用 ROBOTIS GUI Controller 取代 RViz tool 來控制機器手臂 ``` $ roslaunch turtlebot3_manipulation_gui turtlebot3_manipulation_gui.launch ``` ## 7.8. SLAM TB3 與 OpenManipulator-X 使用 SLAM 功能在未知地圖上建圖 ![](https://i.imgur.com/11B4KzY.png) ### 7.8.1. 執行 roscore [**Remote PC**] 在 ROS1 執行 roscore ``` $ roscore ``` ### 7.8.2. 執行 Bringup 啟動 [**TB3 SBC**] 在 TB3 SBC,啟動 TB3 開始 rosserial 及 LDS sensor ``` $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` :::info OpenManipulator-X 手臂在 SLAM 時是不需要的,控制手臂的 move_group 及 bringup node 可以無需執行 ::: ### 7.8.3. 執行 SLAM node [**Remote PC**] 執行 SLAM node 來 update 未知地圖,預設是 gmapping package. ``` $ roslaunch turtlebot3_manipulation_slam slam.launch ``` ### 7.8.4. 執行 turtlebot3_teleop_key Node [**Remote PC**] 使用 turtlebot3_teleop_key Node 來控制 TB3 移動建立地圖 ``` $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch ``` 一旦建好地圖,執行 map_saver node 儲存地圖 ``` $ rosrun map_server map_saver -f ~/map ``` ## 7.9. Navigation 導航 使用 Navigation node 讓 TB3+OpenManipulator-X 移動到指定位置 ### 7.9.1. 執行 roscore [**Remote PC**] 在 ROS1 執行 roscore ``` $ roscore ``` ### 7.9.2. 執行 Bringup 啟動 [**TB3 SBC**] 在 TB3 SBC,啟動 TB3 開始 rosserial 及 LDS sensor ``` $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` ### 7.9.3. 執行 Navigation Node [**Remote PC**] 下列指令執行 Navigation node,會呼叫 urdf 格式(Unified Robot Description Format) 機器人模型及 RViz 設定資料來設置 GUI 環境,Navigation 參數及更新地圖。 ``` $ roslaunch turtlebot3_manipulation_navigation navigation.launch ``` ![](https://i.imgur.com/SUuants.png) ### 7.9.4. 如何在 Navigation 時控制 OpenManipulator-X 手臂 Navigation node 執行後,當 TurtleBot3 接近目標位置時,你可以運行此節點來控制 TurtleBot3 上的 OpenManipulator-X手臂。但是,當 TurtleBot3 處於移動狀態時,OpenManipulator-X 手臂的運動會受到外部影響,如重心或振動的影響而不穩定;因此建議在 TurtleBot3 不移動時使用機器手臂。 #### 7.9.4.1. 執行 OpenManipulator 的 Bringup 啟動 [**Remote PC**] 執行 turtlebot3_manipulation_bringup node 就如單獨使用手臂一樣。此節點包含 arm_controller 跟 gripper_controller. ``` $ roslaunch turtlebot3_manipulation_bringup turtlebot3_manipulation_bringup.launch ``` #### 7.9.4.2. 執行 move_group Node move_group node 支援兩種方式控制 OpenManipulator-X 手臂: Moveit! 及 ROBOTIS GUI。選擇任一你偏愛的方式。此章節只介紹 ROBOTIS GUI 方式。 ``` $ roslaunch turtlebot3_manipulation_moveit_config move_group.launch ``` :::info 請參考 [MoveIt!](https://moveit.ros.org/) 來詳細了解 ::: #### 7.9.5. 執行 ROBOTIS GUI Controller [**Remote PC**] 使用此節點來控制 TB3 上的 OpenManipulator-X 手臂 ``` $ roslaunch turtlebot3_manipulation_gui turtlebot3_manipulation_gui.launch ``` ## 7.10. TurtleBot3 Home Service Challenge 居家服務挑戰賽 :::info 備註: - 操作的內容已在Ubuntu 16.04 及 ROS Kinetic Kame 版本上測試過。 - 詳細資訊可參考 [OpenMANIPULATOR e-Manual](https://emanual.robotis.com/docs/en/platform/openmanipulator/) and [ROS1 Turtlebot3 Manipulation](https://emanual.robotis.com/docs/en/platform/turtlebot3/manipulation) ::: ![](https://i.imgur.com/mQY3ATB.jpg) 居家服務挑戰賽場館及物品 {%youtube 3aZXpVsEi0c %} 宣傳影片 ### 7.10.1. 入門 :::warning Note: 在安裝 Home Service Challenge package 前務必先完成下列動作 - [TurtleBot3 PC Set up](https://emanual.robotis.com/docs/en/platform/turtlebot3/quick-start/#pc-setup) - [TurtleBot3 SBC Set up](https://emanual.robotis.com/docs/en/platform/turtlebot3/sbc_setup/#sbc-setup) - [OpenMANIPULATOR-X packages](https://emanual.robotis.com/docs/en/platform/openmanipulator_x/quick_start_guide/#install-ros-packages) ::: #### 7.10.1.1. 先決條件 要參加此挑戰賽,需具有 - TurtleBot3 Waffle Pi 機器人 - OpenManipulator-X 機器手臂 - Remote PC (跑 ROS1) #### 7.10.1.2. Remote PC setup 1. [Remote PC] 安裝 Home Service Challenge packages ``` $ cd ~/catkin_ws/src/ $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_home_service_challenge.git $ cd ~/catkin_ws && catkin_make ``` 2. [Remote PC] 安裝額外相關 package ``` $ sudo apt-get install ros-kinetic-ar-track-alvar ros-kinetic-ar-track-alvar-msgs ``` 3. [Remote PC] 在 RViz 載入 TB3 Waffle(or Waffle Pi) with OpenManipulator-X 手臂 ``` $ export TURTLEBOT3_MODEL=${TB3_MODEL} $ roslaunch turtlebot3_manipulation_description turtlebot3_manipulation_view.launch use_gui:=true ``` :::info Note: ${TB3_MODEL} 可設為 waffle or waffle_pi ::: ![](https://i.imgur.com/dAvSRaq.png) RViz 視窗 4. [Remote PC] 要遠端使用 PC,需建 SSH keys,建立script 腳本檔案來產生 SSH key ``` $ nano ~/tb3_ssh_keygen ``` 5. [Remote PC] 複製貼上下列腳本,然後存檔 ``` #!/bin/bash argc=$# args=("$@") if [ 0 -eq $argc ] then echo "need to argument that host ip for ssh connection" echo "Usage: $0 [ip address] ..." exit 1 fi for((index = 0; index < $#; index++ )) do ssh-keygen -R ${args[$index]} ssh-keyscan ${args[$index]} >> ~/.ssh/known_hosts done ``` 6. [Remote PC] 讓檔案變為執行檔 ``` $ chmod +x ~/tb3_ssh_keygen ``` 7. [Remote PC] 以 TB3 IP address 執行此檔。Remote PC 跟 TB3 需在相同 WiFi 網域。 ``` $ ~/tb3_ssh_keygen {IP_ADDRESS_OF_TURTLEBOT3} ``` 8. 檢查 ~/.ssh/known_hosts 檔,看 SSH 是否成功產生。 ![](https://i.imgur.com/5m0EOKn.png) #### 7.10.1.3. TB3 SBC 設定 1. [Turtlebot3 SBC] 編輯 env.bash 檔,位於 /home/pi 目錄下 ``` $ nano ~/env.bash ``` 2. [Turtlebot3 SBC] 複製貼上下列腳本,然後存檔 ``` #!/bin/bash # check if other turtlebot3_core is already running is_running=`ps ax | grep turtlebot3_core` IFS=' ' read -ra is_runnings <<< "$is_running" process_name=${is_runnings[4]} if [ ${process_name} == "python" ] then echo "other turtlebot3_core is already running." exit 1 fi #### ROS #### source /opt/ros/kinetic/setup.bash source ~/catkin_ws/devel/setup.bash #### ROS Network #### ip_address=`hostname -I` ip_address_trim=${ip_address%% * } ip_address_no_space="$(echo -e "${ip_address_trim}" | tr -d '[:space:]')" export ROS_HOSTNAME=${ip_address_no_space} ##### Set TURTLEBOT3 Model #### export TURTLEBOT3_MODEL=waffle_pi exec "$@" ``` 3. 讓檔案變成可執行檔 ``` $ chmod +x ~/env.bash ``` #### 7.10.1.4. OpenCR 設定 參考章節 7.4. OpenCR 設定 #### 7.10.1.5. 硬體設定 參考本章節 7 硬體設定 ### 7.10.2. Camera Calibration 攝影機校準 校準攝影機來減少失真。請一步一步依照下列攝影機校準過程。 #### 7.10.2.1. 攝影機設定 1. [**Remote PC**] 以下指令遠端操作攝影機。確認 Remote PC 跟 TB3 都在同一網域。 ``` $ roslaunch turtlebot3_home_service_challenge_tools turtlebot3_pi_cam_remote.launch address:=TURTLEBOT_IP ``` 2. [**Remote PC**] 執行 rqt_image_view` ``` $ rqt_image_view ``` 3. 在 check box 勾選 /raspicam_node/image/compressed (or /raspicam_node/image/) topic ![](https://i.imgur.com/kjdlYGB.png) 4. [**Remote PC**] 執行 rqt_reconfigure ``` $ rosrun rqt_reconfigure rqt_reconfigure ``` 5. 點擊 raspicam_node,調整各參數值,以便能清楚看到從攝影機傳來的影像 ![](https://i.imgur.com/wZdnfgG.png) 6. 開啟 camera.yaml 檔,位於 turtlebot3_home_service_challenge_tools/config/camera_calibration 7. 將修改後的參數值填入並存檔 ``` ISO: 400 awb_mode: auto brightness: 50 contrast: 0 exposureCompensation: 0 exposure_mode: auto hFlip: false saturation: 0 sharpness: 0 shutterSpeed: 0 vFlip: false videoStabilisation: false zoom: 1.0 ``` #### 7.10.2.2. Camera 內部參數校準 在 A4 尺寸的紙張上印出用於 Camera 內部參數校準的棋盤。 - 棋盤檔位於 [ROS Wiki](http://wiki.ros.org/camera_calibration/Tutorials/StereoCalibration?action=AttachFile&do=view&target=check-108.pdf) - camera 校準的詳細資訊,可參考 ROS Wiki 的 [Camera Calibration 手冊](http://wiki.ros.org/camera_calibration) ![](https://i.imgur.com/f55Axz8.png) 棋盤檔 1. [**Remote PC**] 以下指令遠端操作攝影機,須加上 IP address。確認 Remote PC 跟 TB3 都在同一網域。 ``` $ roslaunch turtlebot3_home_service_challenge_tools turtlebot3_pi_cam_remote.launch enable_raw:=true address:=TURTLEBOT_IP ``` 2. 在 Remote PC 執行 camera 內部校準啟動檔 ``` $ rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.024 image:=/raspicam_node/image camera:=/raspicam_node ``` :::info Note: 根據棋盤紙大小 A3、A4 或其他尺寸,黑白方塊的尺寸可能會有所不同。在這種情況下,根據棋盤紙中的正方形大小,可調整所下指令中 - square 選項的值(0.024)。 ::: ![](https://i.imgur.com/85iRFVo.png) 3. 使用棋盤紙來校準 camera,點擊 CALIBRATE :::success Note: 向左、右、上、下和各種角度移動和傾斜棋盤紙,以獲取 X、Y、Size和 Skew 校準數據。随着充分數據的計算,X、Y、Size 和 Skew 將有一個綠色的橫條。 ::: ![](https://i.imgur.com/TPOcJf4.png) 4. 點擊 Commit 來儲存內部校準數據到預設資料夾(~/.ros/camera_info) ![](https://i.imgur.com/e5yQ5nO.png) 5. 從 TB3 SBC 的 ~/.ros/camera_info 目錄,打開 camerav2_1280x720.yaml 檔來檢查保存的數據,會類似以下形式 ``` image_width: 1280 image_height: 720 camera_name: camerav2_1280x720 camera_matrix: rows: 3 cols: 3 data: [1280.628466572832, 0, 658.384219880362, 0, 1277.989132765768, 360.8363923435625, 0, 0, 1] distortion_model: plumb_bob distortion_coefficients: rows: 1 cols: 5 data: [0.2032697817127332, -0.4147569733010375, -0.001420915782245743, 0.003110652248245379, 0] rectification_matrix: rows: 3 cols: 3 data: [1, 0, 0, 0, 1, 0, 0, 0, 1] projection_matrix: rows: 3 cols: 4 data: [1312.630981445312, 0, 661.4149459665205, 0, 0, 1312.107055664062, 360.0239481801327, 0, 0, 0, 1, 0] ``` ### 7.10.3. SLAM 1. [**Remote PC**] 以下指令遠端操作攝影機,須加上 IP address。確認 Remote PC 跟 TB3 都在同一網域。 ``` $ roslaunch turtlebot3_home_service_challenge_tools turtlebot3_robot_remote.launch address:=TURTLEBOT_IP ``` 2. [**Remote PC**] 執行 SLAM node ``` $ roslaunch turtlebot3_home_service_challenge_tools slam.launch ``` 3. [**Remote PC**] 執行 keyboard teleoperation node ``` $ roslaunch turtlebot3_home_service_challenge_tools mobile_teleop_key.launch ``` 執行後,下列訊息會出現在 terminal 視窗 ``` Control Your TurtleBot3! --------------------------- Moving around: w a s d x w/x : increase/decrease linear velocity a/d : increase/decrease angular velocity space key, s : force stop CTRL-C to quit ``` 4. 使用 keyboard 來更新地圖 ![](https://i.imgur.com/wTxyjZo.png) 5. [**Remote PC**] 當地圖全部更新後存檔 ``` $ ROS_NAMESPACE=tb3_hsc rosrun map_server map_saver -f tb3_hsc ``` ![](https://i.imgur.com/Niluv59.png) ### 7.10.4. Missions 任務 #### 7.10.4.1. 執行 demo and manager package 1. [**Remote PC**] 執行 demo package 指令,須加上 TB3 IP 。此套件包含多種特色: Remote Bringup with a machine tag, Moveit, Navigation, Camera sensing。 Remote PC 跟 TB3 要在同一網域。 ``` $ roslaunch turtlebot3_home_service_challenge_tools turtlebot3_home_service_challenge_demo_remote.launch address:=TURTLEBOT_IP ``` ![](https://i.imgur.com/0Dsuba1.png) 2. [**Remote PC**] 執行 manager package,是用來進行 Home Service 挑戰賽的任務 ``` $ roslaunch turtlebot3_home_service_challenge_manager manager.launch ``` #### 7.10.4.2. 指令 [**Remote PC**] 在挑戰賽時使用下列指令 - **Ready**: TB3 將準備開始一項任務 ``` $ rostopic pub -1 /tb3_hsc/command std_msgs/String ready_mission ``` - **Start**: TB3 將開始任務 ``` $ rostopic pub -1 /tb3_hsc/command std_msgs/String start_mission ``` - **Stop**: TB3 將停止執行任務 ``` $ rostopic pub -1 /tb3_hsc/command std_msgs/String stop_mission ``` - **Restart**: TB3 將在給定的 scenario 情境下,重新開始任務 ``` $ rostopic pub -1 /tb3_hsc/command std_msgs/String restart_mission:SCENARIO_NAME ``` :::info 當使用指令時,必須從 scenario.yaml 內包含一個情境。有關詳細 scenario 情境,可參考下面的 Configuration 設置章節 ::: #### 7.10.4.3. Operation Test 操作測試 [**Remote PC**] 發布下列 topics 來測試 navigation 導航跟 manipulation 機器手臂功能 - Navigation ``` $ rostopic pub -1 /tb3_hsc/command std_msgs/String nav_start $ rostopic pub -1 /tb3_hsc/command std_msgs/String nav_ar_marker_0 $ rostopic pub -1 /tb3_hsc/command std_msgs/String nav_ar_marker_1 $ rostopic pub -1 /tb3_hsc/command std_msgs/String nav_ar_marker_2 ``` - Manipulation ``` $ rostopic pub -1 /tb3_hsc/command std_msgs/String arm_home $ rostopic pub -1 /tb3_hsc/command std_msgs/String arm_joint $ rostopic pub -1 /tb3_hsc/command std_msgs/String arm_task $ rostopic pub -1 /tb3_hsc/command std_msgs/String open_gripper $ rostopic pub -1 /tb3_hsc/command std_msgs/String close_gripper ``` #### 7.10.4.4. Configuration 設置 [**Remote PC**] 依據所給的環境,可修改設置檔內的資料 - scenario.yaml: 此檔案包含 scenario 情境資料 - 檔案路徑: /turtlebot3_home_service_challenge_manager/script/scenario.yaml - 腳本 script ``` SCENARIO_NAME: # start - scenario - finish task: TASK_NAME args: [0, 1, 2] timeout: 10 #sec, 0 : no time out next_scenario: find_object scenario_on_failure: standby retry_times: 0 #times, 0 : no retry ``` - room.yaml: 此檔案包含 Home Service 挑戰賽場地資訊 - 檔案路徑: /turtlebot3_home_service_challenge_manager/config/room.yaml - 腳本 script ``` room_1: name: toilet object: marker: ar_marker_0 position: [0.25, 0, 0.15] target: marker: ar_marker_4 position: [0.25, 0, 0.15] x: [1.5, 0.6] y: [1.5, 0.2] ``` - config.yaml: 此設定檔案包含 manager package 的資料 - 檔案路徑: /turtlebot3_home_service_challenge_manager/config/config.yaml #### 7.10.4.5. Home Service 挑戰賽任務細節 居家服務挑戰賽的目標,是按照給定的規則,將四個不同的物體,從客廳移動到特定的地方,然後返回起點。 使用 demo package,在挑戰賽中移動物體的流程如下: 1. 導航到客廳的一個目標 - 找到目標,然後使用 Navigation package 抵達目標 ![](https://i.imgur.com/aIW6pF8.png) 2. 接近目標 - 為了精確接近目標,TurtleBot3 輪子直接通過 AR marker 計算目標位置來控制。(使用的 topic: /tb3_hsc/cmd_vel)。為了產生可靠的效能,Closed-loop 和控制系統可以使用指定的次數。 ![](https://i.imgur.com/mbQ8t5x.png) 3. 使用 OpenManipulator-X 爪夾抓取目標處物件 - 使用 moveit package 來抓取物件(Joint space control, Task space control 及 Gripper control) ![](https://i.imgur.com/ts0SYxx.png) moveit 流程圖 ![](https://i.imgur.com/KMUy4Zq.png) 使用 moveit package 抓取目標 4. 離開到下個房間放置物件(使用的 topic: /tb3_hsc/cmd_vel) - 當從目標處往回走時,輪子由 mamager 程式使用 /tb3_hsc/cmd_vel topic 直接控制 5. 導航到要安置物件的目標處 - 找下一個目標,使用 Navigation package 抵達目標處 ![](https://i.imgur.com/UCpeegt.png) 6. 接近目標 7. 使用爪手放置物件 8. 使用 Navigation package 回到起始點 ![](https://i.imgur.com/fFmOgnh.png) ### 7.10.5. 模擬 在 Gazebo 模擬器模擬 TB3 附 OpenManipulator-X 機器手臂 1. [**Remote PC**] 執行 Gazebo ``` $ roslaunch turtlebot3_home_service_challenge_simulation competition.launch ``` ![](https://i.imgur.com/hZ9apud.png) 2. [**Remote PC**] 在 Gazebo 跑 simulation demo ``` $ roslaunch turtlebot3_home_service_challenge_tools turtlebot3_home_service_challenge_demo_simulation.launch ``` ![](https://i.imgur.com/Qny1ECm.png) 3. [**Remote PC**] 執行 Home Service Manager ``` $ roslaunch turtlebot3_home_service_challenge_manager manager.launch ``` 4. 使用 Home Service Manager 指令(參考 7.10.4.2.) # **8. [ROS1] Automonous Driving 自駕車挑戰賽** --- ![](https://i.imgur.com/52GNGkx.jpg) AutoRace 是一個自動駕駛機器人平台的競賽。 ## 8.1. 開始準備 :::info **備註**: - 操作的內容已在 Ubuntu 16.04 及 ROS Kinetic 和 ROS Noetic 版本上測試過。 ::: :::info **備註**: 手冊中的內容可能隨時更新,恕不另行通知。 ::: - AutoRace 原始碼: [turtlebot3_autorace packages](https://github.com/ROBOTIS-GIT/turtlebot3_autorace) **教學影片** - Tutorial 1: Traffice Light 紅綠燈 {%youtube yp7MVZCiaWs %} - Tutorial 2: Lane Tracking 道路線追蹤 {%youtube 1RBOfPWdpsc %} - Tutorial 3: Parking 停車 {%youtube ValFotgBfC0 %} - Tutorial 4: Node Optimization 最佳化節點 {%youtube YpjHOzx432M %} - Tutorial 5: Level Crossing 平交道柵欄 {%youtube MBDMBq6IDd4 %} - Tutorial 6: Tunnel 隧道 {%youtube ezkwAs1kVkM %} 以下說明描述 TurtleBot3 如何使用 AutoRace 套件包在 ROS 上構建自動駕駛。 ### 8.1.1. 自動駕駛需要哪些設備需求? **1. TurtleBot3 Burger 漢堡款 or 改裝** - 使用 AutoRace 套件包在 ROS 上進行自動駕駛的基礎款。 - AutoRace 套件包的開源碼是基於 TurtleBot3 Burger 開發的 **2. Remote PC 筆電/桌電** - 跟 TB3 的 SBC 單板電腦溝通 - 安裝 ROS 1 的筆電,桌電,或其他裝置 **3. 附加配件 (Raspberry Pi 相機及固定架)** - 你可以更換不同 camera 只要有支援 ROS - 用來校準 camera 的原始碼,是基於 [Fisheye Lens 魚眼鏡頭](https://www.waveshare.com/rpi-camera-g.htm)模組來開發 **4. AutoRace 比賽軌道及相關所需物件** - 從 [autorace_track](https://github.com/ROBOTIS-GIT/autorace_track) 下載 3D CAD 檔案用於製作 AutoRace 軌道,交通標誌,交通信號燈和其他物件。 - 從 [autorace_referee](https://github.com/ROBOTIS-GIT/autorace_referee) 下載裁判程式原始碼 ### 8.1.2. 安裝 AutoRace 套件 以下說明介紹如何安裝套件包和校準 camera。 1. 在 Remote PC 及 SBC 安裝 AutoRace 套件包。開 terminal ``` $ cd ~/catkin_ws/src/ $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_autorace.git $ cd ~/catkin_ws && catkin_make ``` 2. 在 Remote PC 及 SBC 安裝額外的相依套件包 ``` $ sudo apt-get install ros-kinetic-image-transport ros-kinetic-cv-bridge ros-kinetic-vision-opencv python-opencv libopencv-dev ros-kinetic-image-proc ``` 3. 需要校準 SBC 上的 camera (請參考下節) ## 8.2. 校準 SBC 上的 camera 校準 camera 是自動駕駛很重要的步驟,以下介紹如何簡單地逐步校準 camera。 ### 8.2.1. 攝影機影像校準 1. 在 Remote PC 啟動 roscore ``` $ roscore ``` 2. 在 SBC 啟用 camera ``` $ roslaunch turtlebot3_autorace_camera turtlebot3_autorace_camera_pi.launch ``` 3. 在 Remote PC 上執行 rqt_image_view ``` $ rqt_image_view ``` 4. 然後在多選框上 V勾選 /camera/image/compressed (或 /camera/image/) topic,應該會在螢幕上看到影像 ![](https://i.imgur.com/sJwvMaa.png) 5. 在 Remote PC 上執行 rqt_reconfigure ``` $ rosrun rqt_reconfigure rqt_reconfigure ``` 6. 點擊 camera,修改參數值以便能看到清晰足夠亮的影像 ![](https://i.imgur.com/bZHqHC1.png) 7. 打開 turtlebot3_autorace_camera/calibration/camera_calibration/camera.yaml 檔 8. 將修改後的參數值填入檔案內。下次啟動時就會使用新參數。 ![](https://i.imgur.com/PAOvQKP.png) ### 8.2.2. Camera 內部參數校準 在 A4 尺寸的紙張上印出用於 Camera 內部參數校準的棋盤。 - 棋盤檔位於 turtlebot3_autorace_camera/data/checkerboard_for_calibration.pdf。 - 修改 turtlebot3_autorace_camera/launch/turtlebot3_autorace_intrinsic_camera_calibration.launch 內的參數值。 - camera 校準的詳細資訊,可參考 ROS Wiki 的 [Camera Calibration 手冊](http://wiki.ros.org/camera_calibration) \ ![](https://i.imgur.com/f55Axz8.png) \ 棋盤檔 1. 在 Remote PC 啟動 roscore ``` $ roscore ``` 2. 在 SBC 啟用 camera ``` $ roslaunch turtlebot3_autorace_camera turtlebot3_autorace_camera_pi.launch ``` 3. 在 Remote PC 執行 camera 內部校準啟動檔 ``` $ export AUTO_IN_CALIB=calibration $ roslaunch turtlebot3_autorace_camera turtlebot3_autorace_intrinsic_camera_calibration.launch ``` 4. 使用棋盤紙來校準 camera,點擊 CALIBRATE ![](https://i.imgur.com/Jxtx6GH.png) 5. 點擊 SAVE 來儲存校準後的資料 ![](https://i.imgur.com/GKy1Cmq.png) 6. 在 /tmp 資料夾下會新增一個 calibrationdata.tar.gz 資料夾 ![](https://i.imgur.com/R7TgETz.png) 7. 從 calibrationdata.tar.gz 內抽取出 ost.yaml 檔 ![](https://i.imgur.com/Gm4aWrE.png) ost.yaml ![](https://i.imgur.com/zxmGVfY.png) 在 ost.yaml 檔的內部參數校準數據 8. 從 ost.yaml 內複製數據,貼上 camerav2_320x240_30fps.yaml 檔 ![](https://i.imgur.com/lAQnOd3.png) camerav2_320x240_30fps.yaml ![](https://i.imgur.com/4CfNpxF.png) 在 camerav2_320x240_30fps.yaml 內的內部參數校準數據 ### 8.2.3. camera 外部參數校準 1. 在 Remote PC 啟動 roscore ``` $ roscore ``` 2. 在 SBC 啟用 camera ``` $ roslaunch turtlebot3_autorace_${Autorace_Misson}_camera turtlebot3_autorace_camera_pi.launch ``` :::warning **警示**: 請一定要指定哪個任務的校準 ${Autorace_Misson} (i.e, roslaunch turtlebot3_autorace_traffic_light_camera turtlebot3_autorace_camera_pi.launch) ::: 3. 在 Remote PC 輸入指令 ``` $ export AUTO_IN_CALIB=action $ export GAZEBO_MODE=false $ roslaunch turtlebot3_autorace_${Autorace_Misson}_camera turtlebot3_autorace_intrinsic_camera_calibration.launch ``` 4. 在 Remote PC 執行 camera 外部校準啟動檔 ``` $ export AUTO_EX_CALIB=calibration $ roslaunch turtlebot3_autorace_${Autorace_Misson}_camera turtlebot3_autorace_extrinsic_camera_calibration.launch ``` 5. 在 Remote PC 執行 rqt ``` $ rqt ``` 6. 點擊 plugins > visualization > Image view,可以新增多個攝影機視角圖的視窗 7. 在兩個視窗分別選擇 /camera/image_extrinsic_calib/compressed topic 及 /camera/image_projected_compensated topic - 兩個視窗其中一個將顯示紅色矩形影像,另一個將顯示地面投影視圖(鳥瞰視圖)。 ![](https://i.imgur.com/jYVsD5a.png) /camera/image_extrinsic_calib/compressed topic ![](https://i.imgur.com/uPt1P7D.png) /camera/image_projected_compensated topic 8. 在 Remote PC 上執行 rqt_reconfigure ``` $ rosrun rqt_reconfigure rqt_reconfigure ``` 9. 調整在 /camera/image_projection 和 /camera/image_compensation_projection 的參數 - 更改 /camera/image_projection 的參數,會影響 /camera/image_extrinsic_calib/compressed topic - 內部攝影機校準將會轉換被紅色矩形所包圍的影像,並顯示從車道上方所看到的影像 ![](https://i.imgur.com/MicGUT9.png) rqt_reconfigure ![](https://i.imgur.com/Jm2Uz8v.png) 參數修改後的結果 ### 8.2.4. 檢查校準的結果 當完成了全部 camera 校準過程(camera 影像校準、內部參數校準、外部參數校準)後,**請確認校準結果都已經套用在 camera。** 以下過程敘述影像辨識的設定。 1. 在 Remote PC 啟動 roscore ``` $ roscore ``` 2. 在 SBC 啟用 camera ``` $ roslaunch turtlebot3_autorace_${Autorace_Misson}_camera turtlebot3_autorace_camera_pi.launch ``` :::warning **警示**: 請一定要指定哪個任務的校準 ${Autorace_Misson} (i.e, roslaunch turtlebot3_autorace_traffic_light_camera turtlebot3_autorace_camera_pi.launch) ::: 3. 在 Remote PC 執行 camera 內部校準啟動檔 ``` $ export AUTO_IN_CALIB=action $ roslaunch turtlebot3_autorace_${Autorace_Misson}_camera turtlebot3_autorace_intrinsic_camera_calibration.launch ``` 4. 在 Remote PC 開新 terminal,下指令 ``` $ export AUTO_EX_CALIB=action $ roslaunch turtlebot3_autorace_${Autorace_Misson}_camera turtlebot3_autorace_extrinsic_camera_calibration.launch ``` 現在,以下的說明將主要用來調整物體辨識的 feature detector / color filter (特徵檢測器/濾色器)。之後的每一次調整都是相互獨立的。不過如果要對每個參數一個一個做調整,請確認先做好當下這個參數的調整後,然後再繼續下一個參數調整。 ## 8.3. Lane Detection 賽道偵測 賽道偵測套件可讓 TB3 不受外部干擾,在兩條車道線內行走。 以下的步驟描述,如何使用 lane detection 賽道偵測功能及透過 rqt 來校準 camera. 1. 將 TB3 放到賽道上,在黃色及白色的車道線之間. :::info 備註: 確認黃色車道線在 TB3 左側,白色車道線在右側。 ::: 2. 在 Remote PC 啟動 roscore ``` $ roscore ``` 3. 在 SBC 啟用 camera ``` $ roslaunch turtlebot3_autorace_${Autorace_Misson}_camera turtlebot3_autorace_camera_pi.launch ``` :::warning **警示**: 請一定要指定哪個任務的校準 ${Autorace_Misson} (i.e, roslaunch turtlebot3_autorace_traffic_light_camera turtlebot3_autorace_camera_pi.launch) ::: 4. 在 Remote PC 執行 camera 內部校準啟動檔 ``` $ export AUTO_IN_CALIB=action $ export GAZEBO_MODE=false $ roslaunch turtlebot3_autorace_${Autorace_Misson}_camera turtlebot3_autorace_intrinsic_camera_calibration.launch ``` 5. 在 Remote PC 執行 camera 外部校準啟動檔 ``` $ export AUTO_EX_CALIB=action $ roslaunch turtlebot3_autorace_${Autorace_Misson}_camera turtlebot3_autorace_extrinsic_camera_calibration.launch ``` 6. 在 Remote PC 執行 lane detection launch 檔 ``` $ export AUTO_DT_CALIB=calibration $ roslaunch turtlebot3_autorace_${Autorace_Misson}_detect turtlebot3_autorace_detect_lane.launch ``` 7. 在 Remote PC 執行 rqt ``` $ rqt ``` 8. 點擊 plugins > visualization > Image view,可以新增多個攝影機視角圖的視窗 9. 在新增的三個視窗分別選擇 topics: /detect/image_yellow_lane_marker/compressed, /detect/image_lane/compressed, /detect/image_white_lane_marker/compressed - 左側(黃線)及右側(白線)視窗,會顯示過濾後的影像 ![](https://i.imgur.com/XMIaULK.png) /detect/image_yellow_lane_marker/compressed topic 的影像視角 ![](https://i.imgur.com/EoTUHzD.png) /detect/image_white_lane_marker/compressed topic 的影像視角 - 中間的視窗顯示從 TB3 來的 camera 視角 ![](https://i.imgur.com/LmfNcN0.png) /detect/image_lane/compressed topic 的影像視角 10. 在 Remote PC 執行 rqt_reconfigure ``` $ rosrun rqt_reconfigure rqt_reconfigure ``` 11. 點擊 Detect Lane,然後調整參數來做車道線的顏色過濾 ![](https://i.imgur.com/Dk51LiZ.png) Detect Lane 參數列表 ![](https://i.imgur.com/ZH84rvU.png) 在 rqt_reconfigure 經過參數調整後的過濾影像 :::success **指示**:由於你的實際環境(包括房間內的光線亮度等)的影響,車道線顏色過濾的校準過程有時會非常困難。因此,你應該有耐心地執行此過程。要快速完成所有操作,請將位於 turtlebot3autorace[Autorace_Misson]_detect/param/lane/ 內 lane.yaml 的值輸入到 reconfiguration 參數上,然後開始校準。 - 首先校準 hue(色調) low – high 值。(1) Hue(色調)值表示顏色,每種顏色(如黃色,白色)都有自己的色調值區域(請參閱 hsv map)。 - 然後校準 saturation(飽和度) low – high值。(2) 每種顏色也有其自己的飽和範圍。 - 最後,校準 lightness(亮度)的 low – high 值。(3)然而在原始碼中,因具有自動調整功能,因此校準 lightness(亮度)的 low 值是沒有意義的。只需將 lightness(亮度)的 high 值設置為 255 即可。清晰的過濾後的車道線影像,會給你提供清晰的車道效果。 ::: 12. 開啟在 turtlebot3autorace[Autorace_Misson]_detect/param/lane/ 下的 lane.yaml 檔。你需要將修改後的值覆寫到此檔內。這會使 camera 在下次啟動時,就會使用你所設置的參數。 ![](https://i.imgur.com/bRkKF2G.png) 13. 結束 rqt_rconfigure 及 turtlebot3_autorace_detect_lane 程序 14. 在 Remote PC 開新 terminal 輸入 ``` $ export AUTO_DT_CALIB=action $ roslaunch turtlebot3_autorace_${Autorace_Misson}_detect turtlebot3_autorace_detect_lane.launch ``` 15. 檢查輸出的結果是否正確 - 在 Remote PC 開新 terminal 輸入 ``` $ roslaunch turtlebot3_autorace_${Autorace_Misson}_control turtlebot3_autorace_control_lane.launch ``` - 在 Remote PC 開新 terminal 輸入 ``` $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` 16. 輸入這些指令後,TB3 會啟動開始運行 ## 8.4. 交通號誌 Traffic Sign 偵測 TB3 的 node 使用 SIFT algorithm 演算法來偵測交通號誌。當 TB3 在賽道上行駛時,會執行已編程好的程序。請遵照下列步驟來使用 Traffic sign detection。 :::info **備註**: 如交通號誌中有更多邊線(edge),SIFT 演算法就可以提供更好的辨識結果。 ::: 1. 使用 TB3 的 camera 及 rqt_image_view 節點來拍攝交通號誌的照片 2. 使用 Linux OS 中提供的任何 photo editor 照片編輯器,來編輯照片的大小和形狀。 3. 把 TB3 機器人放在車道上。此時,交通號誌應放置在機器人容易看到的地方。 :::info **備註**: 請注意此時 TB3 要尚未啟動狀態。如果節點已啟動,機器人會突然在軌道上運行。 ::: 4. 在 Remote PC 執行 rqt_image_view ``` $ rqt_image_view ``` 5. 在選擇框中點擊 /camera/image_compensated 的 topic。如果一切正常,螢幕會顯示機器人視角圖視窗。 6. 在 Remote PC 上按 Alt + Print Screen 鍵來擷取照片,用 photo editor 來編輯照片。 7. 將編輯後的照片放在 [turtlebot3_autorace 套件所存放的位置] /turtlebot3_autorace/turtlebot3_autorace_detect/file/detect_sign/ 資料夾下,然後根據需要重新命名檔案。(如果想要更改預設檔名,你也應該更改在 detect_sign.py 原始碼中的檔名。) 8. 在 Remote PC 開新 terminal 輸入 ``` $ roslaunch turtlebot3_autorace_${Autorace_Misson}_detect turtlebot3_autorace_detect_sign.launch ``` 9. 在 Remote PC 開新 terminal 輸入 ``` $ rqt_image_view ``` 10. 在選擇框中點擊 /detect/image_traffic_sign/compressed 的 topic。如果一切正常及成功的識別出交通號誌,螢幕將顯示交通號誌檢測結果。 ## 8.5. TurtleBot3 AutoRace 自駕車競賽的任務詳解 AutoRace 是給自動駕駛機器人平台的一個比賽。 為了能給機器人應用程式的開發,提供不同情境,比賽會盡可能減少硬性的規定。整個比賽內容完全是開源的,基於 ROS 來運行,包含全部的軟體(裁判系統的原始碼)和全部的硬體(比賽地圖的 stp / dwg 檔案)。內容會持續的更新,請參與比賽,展現你的技術。 :::warning **警示**: 如要參加比賽,請務必閱讀完本章節 Autonomous Driving。 ::: ### 8.5.1. 第一關: Traffic Light 紅綠燈 AutoRace 第一關是 Traffic Light 紅綠燈。TB3 要判斷紅綠燈後開始比賽。 {%youtube JNj_STs3OSg %} #### 8.5.1.1. 紅綠燈的 camera 校準 1. 在 Remote PC 開新 terminal 輸入 ``` $ export AUTO_DT_CALIB=calibration $ roslaunch turtlebot3_autorace_traffic_light_detect turtlebot3_autorace_detect_traffic_light.launch ``` 2. 在 Remote PC 執行 rqt ``` $ rqt ``` 3. 選擇 4 個 traffic light topics: /detect/image_red_light, /detect/image_yellow_light, /detect/image_green_light, /detect/image_traffic_light 4. 執行 rqt_reconfigure ``` $ rosrun rqt_reconfigure rqt_reconfigure ``` 5. 對 traffic light topics 調整參數,以便增強偵測的效果。調整參數的方式,跟 Lane Detection 小節內所教的相似 6. 開啟位於 turtlebot3_autorace_traffic_light_detect/param/traffic_light/ 資料夾的 traffic_light.yaml 檔 7. 將修改後的參數覆寫到此檔後存檔 8. 結束 rqt 及 rqt_reconfigure 程序。下一步是要測試校準的結果是否成功。 9. 在 Remote PC 開新 terminal 輸入 ``` $ export AUTO_DT_CALIB=action $ roslaunch turtlebot3_autorace_traffic_light_detect turtlebot3_autorace_detect_traffic_light.launch ``` 10. 執行 rqt_image_view ``` $ rqt_image_view ``` 11. 看看 traffic light 校準是否成功 #### 8.5.1.2. 運行 Traffic Light 任務 :::warning **警示**: 在執行 traffic light node 之前,務必要閱讀過上小節 Camera Calibration for Traffic Lights ::: 1. 在 Remote PC 下指令 ``` $ export AUTO_IN_CALIB=action $ export GAZEBO_MODE=false $ roslaunch turtlebot3_autorace_traffic_light_camera turtlebot3_autorace_intrinsic_camera_calibration.launch ``` 2. 在 Remote PC 下指令 ``` $ export AUTO_EX_CALIB=action $ export AUTO_DT_CALIB=action $ roslaunch turtlebot3_autorace_traffic_light_core turtlebot3_autorace_core.launch ``` 3. 在 Remote PC 下指令 ``` $ rostopic pub -1 /core/decided_mode std_msgs/UInt8 "data: 3" ``` ### 8.5.2. 第二關: Intersection 十字路口 AutoRace 第 2 關是 Intersection 十字路口。TB3 在十字路口,要辨識特定的轉彎號誌(左轉或右轉),依照指示轉向。 {%youtube 8K4GMbfXFXI %} #### 8.5.2.1. 如何運行 Interaction 任務 1. 在 Remote PC 下指令 ``` $ export AUTO_IN_CALIB=action $ roslaunch turtlebot3_autorace_intersection_camera turtlebot3_autorace_intrinsic_camera_calibration.launch ``` 2. 在 Remote PC 下指令 ``` $ export AUTO_EX_CALIB=action $ export AUTO_DT_CALIB=action $ roslaunch turtlebot3_autorace_intersection_core turtlebot3_autorace_core.launch ``` 3. 在 Remote PC 下指令 ``` $ rostopic pub -1 /core/decided_mode std_msgs/UInt8 "data: 2" ``` ### 8.5.3. 第三關: Construction 避障 AutoRace 第三關 Construction 避障。TB3 行駛時須避開賽道上的障礙物。 {%youtube 88nXiX8UUtw %} #### 8.5.3.1. 如何運行 Construction 避障任務 1. 在 Remote PC 下指令 ``` $ export AUTO_IN_CALIB=action $ export GAZEBO_MODE=false $ roslaunch turtlebot3_autorace_construction_camera turtlebot3_autorace_intrinsic_camera_calibration.launch ``` 2. 在 Remote PC 下指令 ``` $ export AUTO_EX_CALIB=action $ export AUTO_DT_CALIB=action $ roslaunch turtlebot3_autorace_construction_core turtlebot3_autorace_core.launch ``` 3. 在 Remote PC 下指令 ``` $ rostopic pub -1 /core/decided_mode std_msgs/UInt8 "data: 2" ``` ### 8.5.4. 第四關: Parking 停車 AutoRace 第四關 Parking 停車。TB3 偵測停車號誌,自行開入空置的停車格內。 {%youtube F3ZG8PlagaA %} #### 8.5.4.1. 如何運行 Parking 任務 1. 在 Remote PC 下指令 ``` $ export AUTO_IN_CALIB=action $ export GAZEBO_MODE=false $ roslaunch turtlebot3_autorace_parking_camera turtlebot3_autorace_intrinsic_camera_calibration.launch ``` 2. 在 Remote PC 下指令 ``` $ export AUTO_EX_CALIB=action $ export AUTO_DT_CALIB=action $ roslaunch turtlebot3_autorace_parking_core turtlebot3_autorace_core.launch ``` 3. 在 Remote PC 下指令 ``` $ rostopic pub -1 /core/decided_mode std_msgs/UInt8 "data: 2" ``` ### 8.5.5. 第五關: Level Crossing 柵欄 AutoRace 第五關 Level Crossing 柵欄。TB3 前方有柵欄,當柵欄放下時停止等待,柵欄升起時通過。 {%youtube xyBaLeg4Ifk %} #### 8.5.5.1. 為 Level Crossing 做 camera 校準 1. 在 Remote PC 下指令 ``` $ export AUTO_DT_CALIB=calibration $ roslaunch turtlebot3_autorace_level_crossing_detect turtlebot3_autorace_detect_level.launch ``` 2. 執行 rqt ``` $ rqt ``` 3. 選擇 2 個 topics: /detect/image_level_color_filtered, /detect/image_level 4. 執行 rqt_reconfigure ``` $ rosrun rqt_reconfigure rqt_reconfigure ``` 5. 選擇 /detect_level 及對 Level Crossing topics 調整參數,以便增強偵測 level crossing 物件的效果。調整參數的方式,跟 Lane Detection 小節內所教的相似 6. 開啟位於 turtlebot3_autorace_stop_bar_detect/param/level/ 下的 level.yaml 檔 7. 將修改後數值複寫入此檔後存檔 8. 執行 detect level launch 檔 ``` $ export AUTO_DT_CALIB=action $ roslaunch turtlebot3_autorace_detect turtlebot3_autorace_detect_level.launch ``` #### 8.5.5.2. 如何運行 Level Crossing 任務 1. 在 Remote PC 下指令 ``` $ export AUTO_IN_CALIB=action $ export GAZEBO_MODE=false $ roslaunch turtlebot3_autorace_level_crossing_camera turtlebot3_autorace_intrinsic_camera_calibration.launch ``` 2. 在 Remote PC 下指令 ``` $ export AUTO_EX_CALIB=action $ export AUTO_DT_CALIB=action $ roslaunch turtlebot3_autorace_level_crossing_core turtlebot3_autorace_core.launch ``` 3. 在 Remote PC 下指令 ``` $ rostopic pub -1 /core/decided_mode std_msgs/UInt8 "data: 2" ``` ### 8.5.6. 第六關: Tunnel 隧道 AutoRace 第六關 Tunnel 隧道。TB3 需成功的從隧道出口駛出。 {%youtube QtBx_MKLsPs %} #### 8.5.6.1. 如何運行 Tunnel 任務 1. 在 Remote PC 下指令 ``` $ export AUTO_IN_CALIB=action $ export GAZEBO_MODE=false $ roslaunch turtlebot3_autorace_tunnel_camera turtlebot3_autorace_intrinsic_camera_calibration.launch ``` 2. 在 Remote PC 下指令 ``` $ export AUTO_EX_CALIB=action $ export AUTO_DT_CALIB=action $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_autorace_tunnel_core turtlebot3_autorace_core.launch ``` 3. 在 Remote PC 下指令 ``` $ rostopic pub -1 /core/decided_mode std_msgs/UInt8 "data: 2" ``` ## 8.6. TurtleBot3 AutoRace 的過去 AutoRace 過去已經舉辦多屆,內容暫不翻譯 # **9. [ROS 1] Machine Learning 機器學習** --- Machine Learning 機器學習是一種數據分析技術,可教導電腦識別人類和動物的自然特徵 – 通過經驗來學習。有三種類型的機器學習演算法: - supervised learning(監督學習) - unsupervised learning(無監督學習) - reinforcement learning(強化學習) 此應用程式是使用 DQN(Deep Q-Learning)的強化學習演算法。Reinforcement learning(強化學習)關注於 software agents 軟體代理應該如何在環境中採取行動,以便能最大化累積獎勵的概念。 {%youtube WADmP0wzLxs %} :::info **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ::: 這影片展示了在 Gazebo 模擬器中 TurtleBot3 使用 reinforcement learning(強化學習)。這種強化學習演算法,是在 LDS 光達上套用了 DQN(Deep Q-Learning)演算法。 我們準備了以下四步驟的強化學習教程。 ## 9.1. 為 TB3 安裝機器學習軟體 要完成本教程,你需要在 Ubuntu 16.04 和 ROS1 kinetic 上安裝 Tensorflow(開源機器學習程式庫 by Google),Keras(開源深度學習程式庫 by Python),和 Anaconda(開源的 Python 發行版本)。 {%youtube s0qgunKt654 %} ### 9.1.1. 安裝 Anaconda 您可以下載 [Anaconda 5.2.0](https://repo.anaconda.com/archive/Anaconda2-5.2.0-Linux-x86_64.sh) for Python 2.7 版本。 下載 Anaconda 後,到下載檔案的資料夾並輸入以下命令。 安裝時在 terminal 上 yes 同意授權條款,同時將 Anaconda2 安裝路徑加到 .bashrc 檔內 ``` $ bash Anaconda2-5.2.0-Linux-x86_64.sh ``` 安裝好 Anaconda 後, ``` $ source ~/.bashrc $ python -V ``` 如果 Anaconda 安裝成功,你會看到 Python 2.7.xx :: Anaconda, Inc. 文字。 ### 9.1.2. 安裝 ROS 相依套件 首先安裝必須套件 ``` $ pip install msgpack argparse ``` 要同時使用 ROS 和 Anaconda,還必須安裝 ROS 相依套件。 ``` $ pip install -U rosinstall empy defusedxml netifaces ``` ### 9.1.3. 安裝 TensorFlow 本教程使用的是 python 2.7(僅限 CPU 版)。 如果你想使用其他 python 版本和 GPU 版,請參閱 [TensorFlow](https://www.tensorflow.org/install/) 連結。 ``` $ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp27-none-linux_x86_64.whl ``` ### 9.1.4. 安裝 Keras [Keras](https://keras.io/) 是一個高級類神經網路 API,用 Python 編寫,能夠在 TensorFlow 之上運行。 ``` $ pip install keras==2.1.5 ``` 有關 tensorboard incompatible 訊息可以忽略,因為範例不會使用,但你也可以安裝 tensorboard 來解決 ``` $ pip install tensorboard ``` ### 9.1.5. 安裝 TB3 機器學習套件 :::warning **警示**:在安裝此套件之前,請先安裝 [turtlebot3](https://github.com/ROBOTIS-GIT/turtlebot3),[turtlebot3_msgs](https://github.com/ROBOTIS-GIT/turtlebot3_msgs) 和 [turtlebot3_simulations](https://github.com/ROBOTIS-GIT/turtlebot3_simulations) 套件。 ::: ``` $ cd ~/catkin_ws/src/ $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_machine_learning.git $ cd ~/catkin_ws && catkin_make ``` :::info 在 Gazebo 模擬器執行 Machine Learning,需要先安裝 turtlebot3_simulations package,以下是指令。 ``` $ cd ~/catkin_ws/src/ $ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git $ cd ~/catkin_ws && catkin_make ``` ::: :::info numpy 可能需要移除及重裝來糾正問題,可能需要移除好幾次以便完全移除 numpy。 ``` $ pip uninstall numpy $ pip show numpy $ pip uninstall numpy $ pip show numpy ``` 如果完全移除,則輸入 pip show numpy 時,不會看到任何有關 numpy 的訊息。 重裝 numpy 指令 ``` $ pip install numpy pyqtgraph ``` ::: ## 9.2. 設定參數 DQN Agent 的目標是讓 TurtleBot3 能避開障礙物到達目的地。當 TurtleBot3 越接近目的地時,它會獲得一個正的獎勵(positive reward),當它離目的地越來越遠時,它會獲得負的獎勵(negative reward)。當 TurtleBot3 碰撞到障礙物或經過一段時間後,這段事件(episode)就會結束了。在這一事件期間,當 TurtleBot3 在達到目的地時,會獲得大的正獎勵,而當 TurtleBot3 碰到障礙物時,會獲得大的負獎勵。 {%youtube 807_cByUBSI %} :::info **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ::: ### 9.2.1. 設定 state 狀態 State 狀態是對周圍環境的觀察,並描述當前的情況。在這裡,state_size 值是 26 並且有 24 個 LDS 光達數據(到目的地的距離,和到目的地的角度)。 TB3 的 LDS 光達預設值是 360。你可以在 turtlebot3/turtlebot3_description/urdf/turtlebot3_burger.gazebo.xacro 來修改樣本值。 ``` <xacro:arg name="laser_visual" default="false"/> # Visualization of LDS. If you want to see LDS, set to `true` ``` ``` <scan> <horizontal> <samples>360</samples> # The number of sample. Modify it to 24 <resolution>1</resolution> <min_angle>0.0</min_angle> <max_angle>6.28319</max_angle> </horizontal> </scan> ``` ![](https://i.imgur.com/LQDev4R.png) sample = 360 ![](https://i.imgur.com/wWhbFI2.png) sample = 24 ### 9.2.2. 設定 action 動作 Action 動作是 agent 在每個 state 狀態可以做的事情。在這裡,turtlebot3 的直線速度設為 0.15 m/s。而角速度(angular velocity)則由 action 決定。 | Action | Angular velocity(rad/s) | |:------:|:-----------------------:| | 0 | -1.5 | | 1 | -0.75 | | 2 | 0 | | 3 | 0.75 | | 4 | 1.5 | ### 9.2.3. 設定 reward 獎勵 當 turtlebot3 在一個 state 狀態採取某個 action 動作時,它會收到一個 reward 獎勵。 reward 獎勵設計對學習非常重要。獎勵可以是正值或負值。當 turtlebot3 到達目的地時,它會得到很大的正獎勵(positive reward)。但當 turtlebot3 與障礙物碰撞時,它會獲得很大的負獎勵(negative reward)。如果你想套用你自己的獎勵設計,請在 /turtlebot3_machine_learning/turtlebot3_dqn/src/turtlebot3_dqn/environment_stage_#.py 檔修改 setReward 函數 ### 9.2.4. 設定 hyper parameters 超參數 本教程是使用 DQN 方法來學習的。DQN 是一種強化學習方法,通過逼近 action-value function 動作值函數(Q值)來選擇深度類神經網絡。Agent 會遵照在 /turtlebot3_machine_learning/turtlebot3_dqn /nodes/turtlebot3_dqn_stage#中的 hyper parameters 超參數。 | Hyper parameter | 預設 | 說明 | |:---------------:|:-------:|:-----------------------------------------------------------------------------:| | episode_step | 6000 | The time step of one episode. | | target_update | 2000 | Update rate of target network. | | discount_factor | 0.99 | Represents how much future events lose their value according to how far away. | | learning_rate | 0.00025 | Learning speed. 如果該值太大,學習效果不好,如果太小,學習時間就會很長。 | | epsilon | 1.0 | The probability of choosing a random action. | | epsilon_decay | 0.99 | Reduction rate of epsilon. When one episode ends, the epsilon reduce. | | epsilon_min | 0.05 | The minimum of epsilon. | | batch_size | 64 | Size of a group of training samples. | | train_start | 64 | Start training if the replay memory size is greater than 64. | | memory | 1000000 | The size of replay memory. | ## 9.3. 執行機器學習套件 此機器學習範例使用 24 個 Lidar 樣本,你可以上一節 9.2 設定參數來修改。 {%youtube 5uIZU8PCHT8 %} :::info **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ::: ### 9.3.1. Stage 1 (無障礙物) Stage 1 是一個 4x4 無障礙物的地圖 ![](https://i.imgur.com/NBX9VDU.png) ``` $ roslaunch turtlebot3_gazebo turtlebot3_stage_1.launch ``` 再開新的 terminal 輸入指令 ``` $ roslaunch turtlebot3_dqn turtlebot3_dqn_stage_1.launch ``` 如果要看圖形結果,可啟動 graph 檔 ``` $ roslaunch turtlebot3_dqn result_graph.launch ``` ### 9.3.2. Stage 2 (靜止障礙物) Stage 2 是一個 4x4 地圖,具有 4 個固定的圓柱體障礙物。 ![](https://i.imgur.com/msXYCsm.png) ``` $ roslaunch turtlebot3_gazebo turtlebot3_stage_2.launch ``` 再開新的 terminal 輸入指令 ``` $ roslaunch turtlebot3_dqn turtlebot3_dqn_stage_2.launch ``` 如果要看圖形結果,可啟動 graph 檔 ``` $ roslaunch turtlebot3_dqn result_graph.launch ``` ### 9.3.3. Stage 3 (移動障礙物) Stage 3 是一個 4x4 地圖,具有 4 個在移動的圓柱體障礙物。 ![](https://i.imgur.com/D364Zqk.png) ``` $ roslaunch turtlebot3_gazebo turtlebot3_stage_3.launch ``` 再開新的 terminal 輸入指令 ``` $ roslaunch turtlebot3_dqn turtlebot3_dqn_stage_3.launch ``` 如果要看圖形結果,可啟動 graph 檔 ``` $ roslaunch turtlebot3_dqn result_graph.launch ``` ### 9.3.4. Stage 4 (障礙物組合) Stage 4 是一個 5x5 地圖,具有牆壁及 2 個在移動的圓柱體障礙物。 ![](https://i.imgur.com/egFFQJf.png) ``` $ roslaunch turtlebot3_gazebo turtlebot3_stage_4.launch ``` 再開新的 terminal 輸入指令 ``` $ roslaunch turtlebot3_dqn turtlebot3_dqn_stage_4.launch ``` 如果要看圖形結果,可啟動 graph 檔 ``` $ roslaunch turtlebot3_dqn result_graph.launch ``` # **10. [ROS 1] 實作 TB3 的不同應用程式** --- :::info **備註**: - 操作的內容已在 Ubuntu 16.04 及 ROS Kinetic Kame 版本上測試過。 - 請注意,操作內容主要是在 [Remote PC 端]上執行,但如果指令前有 [TB3 SBC 端] 的標記,則是在 TB3 的 SBC 單板電腦上執行。 - 在執行本節指令前,請先執行 Bringup 啟用 TB3 章節的指示 ::: {%youtube Xg1pKFQY5p4 %} :::info 章節內容及影片如有修改,不會預先通知 ::: ## 10.1. 使用 Interactive Markers 來移動 在 RViz 中可以使用 Interactive Markers 來移動 TB3,讓 TB3 直走或旋轉。 **[Remote PC 端]** 開新的 terminal,啟動 remote 檔 :::info TURTLEBOT3_MODEL 的參數需依平台,輸入 burger,waffle,or waffle_pi。 ::: ``` $ export TURTLEBOT3_MODEL=${TB3_MODEL} $ roslaunch turtlebot3_bringup turtlebot3_remote.launch ``` **[Remote PC 端]** 啟動 interactive markers 檔 ``` $ roslaunch turtlebot3_example interactive_markers.launch ``` **[Remote PC 端]** 在 RViz 中看 3D 模型 ``` $ rosrun rviz rviz -d `rospack find turtlebot3_example`/rviz/turtlebot3_interactive.rviz ``` ## 10.2. 偵測障礙物 TB3 可使用 LDS 光達移動或停止。當 TB3 移動時,如 LDS 光達偵測到前方有障礙物,TB3 就會停止。 **[Remote PC 端]** 啟動 obstacle 檔 ``` $ roslaunch turtlebot3_example turtlebot3_obstacle.launch ``` ## 10.3. Position Control :::info 此應用只支援 ROS2 Dashing 版 ::: ## 10.4. Point Operation 點位移 TB3 可以用 2D point (x, y) 及 z-angular 座標來移動。舉例,如果輸入 (0.5, 0.3, 60),TB3 會移動到 point(x=0.5m, y=0.3m) 的點並旋轉 60 度。 **[Remote PC 端]** 啟動 pointop 檔 ``` $ roslaunch turtlebot3_example turtlebot3_pointop_key.launch ``` ## 10.5. Patrol 巡邏 TurtleBot3 可以通過自定義路線移動。共有三種路線(長方形、三角形和圓形)。此範例使用 action topic。Action client端將巡邏數據(模式、區域、計數)轉換給 action server。然後 action server 將 cmd_vel 轉換給 TurtleBot3。 **[Remote PC 端]** 啟動 patrol server 端檔案 ``` $ rosrun turtlebot3_example turtlebot3_server ``` **[Remote PC 端]** 啟動 patrol client 端檔案 ``` $ roslaunch turtlebot3_example turtlebot3_client.launch ``` ## 10.6. TB3 follower 跟隨者 demo :::info 為了能實作這個應用,你必須安裝 [turtlebot3_application](https://github.com/ROBOTIS-GIT/turtlebot3_applications) 及 [turtlebot3_applications_msgs](https://github.com/ROBOTIS-GIT/turtlebot3_applications_msgs) 套件. **[Remote PC 端]** 到 catkin workspace 資料夾(/home/(user_name)/catkin_ws/src),複製 turtlebot3_application 及 turtlebot3_applications_msgs 儲存庫。然後執行 catkin_make 來建立新套件。指令如下: ``` $ sudo apt-get install ros-kinetic-ar-track-alvar $ sudo apt-get install ros-kinetic-ar-track-alvar-msgs $ cd ~/catkin_ws/src $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_applications.git $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_applications_msgs.git $ cd ~/catkin_ws && catkin_make ``` ::: {%youtube w9YTxZVY6yQ %} :::info **備註**: - 這個跟隨者 demo 只使用 360 度 LDS-01 光達來實現。所使用的分類演算法,是基於之前所 fitting 的人物及障礙物位置的樣本,來採取行動。它可讓機器人跟隨在前方 50cm 距離和 140 度範圍間的人移動。 - 在有障礙物的空間內執行跟隨者 demo,可能效果不好。建議在空曠無障礙的空間執行。 ::: 1. **[Remote PC 端]** 安裝 scikit-learn、NumPy 及 ScyPy 套件 ``` $ sudo apt-get install python-pip $ sudo pip install -U scikit-learn numpy scipy $ sudo pip install --upgrade pip ``` 2. **[Remote PC 端]** 當安裝完成,在 Remote PC 端執行 roscore 指令 ``` $ roscore ``` 3. **[TB3 SBC 端]** 啟動 TurtleBot3_bringup 程式 ``` $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` 4. **[Remote PC 端]** 以下指令啟動 turtlebot3_follow_filter 程式,設定 TB3 Burger 環境參數 ``` $ export TURTLEBOT3_MODEL=burger $ roslaunch turtlebot3_follow_filter turtlebot3_follow_filter.launch ``` 5. **[Remote PC 端]** 以下指令啟動執行 turtlebot3_follower 程式 ``` $ roslaunch turtlebot3_follower turtlebot3_follower.launch ``` ## 10.7. TB3 Panorama 全景照相 :::info **備註**: - turtlebot3_panorama 全景展示,使用 pano_ros 拍攝快照並將它們拼接在一起,來創建全景影像。 - 全景展示需要安裝 Raspicam_node 套件. 請參考 [Github 網頁](https://github.com/UbiquityRobotics/raspicam_node)的指示來安裝套件。 - 全景展示也需要安裝 OpenCV 及 cvbridge 套件. 請參考 [OpenCV 教程網頁](http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html)的說明來安裝 OpenCV 套件 ::: 1. **[TB3 SBC 端]** 啟動 turtlebot3_rpicamera 檔 ``` $ roslaunch turtlebot3_bringup turtlebot3_rpicamera.launch ``` 2. **[Remote PC 端]** 以下指令啟動 panorama 檔 ``` $ roslaunch turtlebot3_panorama panorama.launch ``` 3. **[Remote PC 端]** 以下指令啟動開始 panorama 全景展示 ``` $ rosservice call turtlebot3_panorama/take_pano 0 360.0 30.0 0.3 ``` 可傳到 rosservice 服務以取得全景影像的參數有下列: - mode for taking pictures 拍照的模式. - 0 : 快照及旋轉(i.e. 旋轉,停止,快照,旋轉,停止,快照,……) - 1 : 繼續(i.e. 在拍攝快照時保持旋轉) - 2 : 停止拍照並創建全景影像 - 全景影像的總角度,以度為單位 - 在 snap&rotate 快照和旋轉模式時,當創建全景影像時,是角度間隔(以度為單位),否則為時間間隔(以秒為單位) - 旋轉速度(in radians/s 單位) 4. **[Remote PC 端] 以下指令可以看到全景影像的結果** ``` $ rqt_image_view image:=/turtlebot3_panorama/panorama ``` ![](https://i.imgur.com/d0wyXd5.jpg) ## 10.8. TB3 Automatic Parking 自動停車 {%youtube IRtdxoPo8Y8 %} :::info **備註**: - turtlebot3_automatic_parking 展示使用 360 度 LDS-01 光達及反光帶。LaserScan topic 有來自 LDS 光達的強度和距離數據。TurtleBot3 使用它來定位反光帶。 - turtlebot3_automatic_parking 展示需要 Numpy 套件 ::: 1. **[Remote PC 端]** 以下列指令安裝 Numpy 套件, 如已安裝過則可以跳過 ``` $ sudo apt-get install python-pip $ sudo pip install -U numpy $ sudo pip install --upgrade pip ``` 2. **[Remote PC 端]** 執行 roscore ``` $ roscore ``` 3. **[TB3 SBC 端]** 啟動基本套件來開始 TB3 應用展示 ``` $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` 4. **[Remote PC 端]** 如果使用 TB3 Burger 漢堡款,用以下指令來設定 TB3 model :::success **提示**: 在執行指令前,你必須先指定使用的 TurtleBot3 模型。指令內的 ${TB3_MODEL} 所對應的 TB3 模型名稱,有 burger,waffle,waffle_pi 三種。如果你要永久設定 exporting setting,請參考 [Export TURTLEBOT3_MODEL 頁面](http://emanual.robotis.com/docs/en/platform/turtlebot3/export_turtlebot3_model)。 ::: ``` $ export TURTLEBOT3_MODEL=burger ``` 5. **[Remote PC 端]** 執行 RViz 可視化工具 ``` $ roslaunch turtlebot3_bringup turtlebot3_remote.launch $ rosrun rviz rviz -d `rospack find turtlebot3_automatic_parking`/rviz/turtlebot3_automatic_parking.rviz ``` 6. **[Remote PC 端]** 執行 automatic parking 自動停車擋 ``` $ roslaunch turtlebot3_automatic_parking turtlebot3_automatic_parking.launch ``` 你可在 RViz 中選擇 LaserScan topic - Topic /scan ![](https://i.imgur.com/uszR42z.png) - Topic /scan_spot ![](https://i.imgur.com/uRpFBLR.png) ## 10.9. TB3 Automatic Parking Vision 自動停車(使用 camera) :::info **備註**: - turtlebot3_automatic_parking_vision 使用 Raspberry pi 攝影機,因此此展示使用的預設平台是 TurtleBot3 Waffle Pi 鬆餅 Pi 款。由於它依一些在牆上找到的 AR marker 標記來停車,因此 AR marker 標記需要列印出來。整個過程使用從攝影機獲取的影像,因此如果停車過程不順利,請配置參數來調整,例如亮度,對比度等。 - turtlebot3_automatic_parking_vision 使用基於 image_proc 節點的矯正影像。為了獲得矯正的影像,TB3 應該取得 Raspberry pi 攝影機的光學校準數據。(每個下載的 turtlebot3 套件,已經將 Raspberry pi v2 攝影機校準數據,當作是預設的數據設置。) - turtlebot3_automatic_parking_vision 套件需要 ar_track_alvar 套件。 ::: 1. **[Remote PC 端]** 執行 roscore ``` $ roscore ``` 2. **[TB3 SBC 端]** 啟用基本套件來開始 TB3 展示 ``` $ roslaunch turtlebot3_bringup turtlebot3_robot.launch ``` 3. **[TB3 SBC 端]** 開始 Raspberry pi 攝影機節點 ``` $ roslaunch turtlebot3_bringup turtlebot3_rpicamera.launch ``` 4. **[Remote PC 端]** Raspberry pi 套件會發布壓縮的影像以加速資料傳送。然而,在 image_proc 節點中的影像校正所需要的是 raw 原始影像。因此,壓縮影像應該轉換為 raw 原始影像。 ``` $ rosrun image_transport republish compressed in:=raspicam_node/image raw out:=raspicam_node/image ``` 5. **[Remote PC 端]** 接著進行影像矯正 ``` $ ROS_NAMESPACE=raspicam_node rosrun image_proc image_proc image_raw:=image _approximate_s=true _queue_size:=20 ``` 6. **[Remote PC 端]** 現在應該開始 AR marker 標記的偵測。在執行相關的啟動文件之前,應該先導出此展示將使用的 TB3 模型。運行啟動文件後,RViz 將自動在預設環境下運行。 ``` $ export TURTLEBOT3_MODEL=waffle_pi $ roslaunch turtlebot3_automatic_parking_vision turtlebot3_automatic_parking_vision.launch ``` {%youtube dvpWdrD3bVs %} TB3 自動停車(攝影機版) :::info **備註**: 手冊中的影片內容可能隨時更新,恕不另行通知。 ::: ## 10.10. 載入多個 TB3 :::info **備註**:此應用展示需要韌體版本 v1.2.1 或以上。 ::: 1. **[Remote PC 端]** 執行 roscore ``` $ roscore ``` 2. 使用不同的 namespace 來構建多個 turtlebot3。我們建議 namespace 包含常用字詞,如 tb3_0,tb3_1 或 my_robot_0,my_robot_1。 - **[TB3 SBC 端 (tb3_0)]** 為節點提供 ROS NAMESPACE 的基本套件,為 tf 前綴提供 multi_robot_name,以及為光達框架 lidar frame id 提供 set_lidar_frame_id。 這些參數必須相同。 ``` $ ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_bringup turtlebot3_robot.launch multi_robot_name:="tb3_0" set_lidar_frame_id:="tb3_0/base_scan" ``` - **[TB3 SBC 端 (tb3_1)]** 為節點提供 ROS NAMESPACE 的基本套件,為 tf 前綴提供multi_robot_name,以及為光達框架 lidar frame id 提供 set_lidar_frame_id。 這些參數必須相同,但需跟其他機器人不同。 ``` $ ROS_NAMESPACE=tb3_1 roslaunch turtlebot3_bringup turtlebot3_robot.launch multi_robot_name:="tb3_1" set_lidar_frame_id:="tb3_1/base_scan" ``` 3. 然後你用來啟動 tb3_0 的那個 terminal 視窗,將顯示以下訊息。可以觀看前綴為 tb3_0 的 TF 變換樹訊息 ``` SUMMARY ======== PARAMETERS * /rosdistro: kinetic * /rosversion: 1.12.13 * /tb3_0/turtlebot3_core/baud: 115200 * /tb3_0/turtlebot3_core/port: /dev/ttyACM0 * /tb3_0/turtlebot3_core/tf_prefix: tb3_0 * /tb3_0/turtlebot3_lds/frame_id: tb3_0/base_scan * /tb3_0/turtlebot3_lds/port: /dev/ttyUSB0 NODES /tb3_0/ turtlebot3_core (rosserial_python/serial_node.py) turtlebot3_diagnostics (turtlebot3_bringup/turtlebot3_diagnostics) turtlebot3_lds (hls_lfcd_lds_driver/hlds_laser_publisher) ROS_MASTER_URI=http://192.168.1.2:11311 process[tb3_0/turtlebot3_core-1]: started with pid [1903] process[tb3_0/turtlebot3_lds-2]: started with pid [1904] process[tb3_0/turtlebot3_diagnostics-3]: started with pid [1905] [INFO] [1531356275.722408]: ROS Serial Python Node [INFO] [1531356275.796070]: Connecting to /dev/ttyACM0 at 115200 baud [INFO] [1531356278.300310]: Note: publish buffer size is 1024 bytes [INFO] [1531356278.303516]: Setup publisher on sensor_state [turtlebot3_msgs/SensorState] [INFO] [1531356278.323360]: Setup publisher on version_info [turtlebot3_msgs/VersionInfo] [INFO] [1531356278.392212]: Setup publisher on imu [sensor_msgs/Imu] [INFO] [1531356278.414980]: Setup publisher on cmd_vel_rc100 [geometry_msgs/Twist] [INFO] [1531356278.449703]: Setup publisher on odom [nav_msgs/Odometry] [INFO] [1531356278.466352]: Setup publisher on joint_states [sensor_msgs/JointState] [INFO] [1531356278.485605]: Setup publisher on battery_state [sensor_msgs/BatteryState] [INFO] [1531356278.500973]: Setup publisher on magnetic_field [sensor_msgs/MagneticField] [INFO] [1531356280.545840]: Setup publisher on /tf [tf/tfMessage] [INFO] [1531356280.582609]: Note: subscribe buffer size is 1024 bytes [INFO] [1531356280.584645]: Setup subscriber on cmd_vel [geometry_msgs/Twist] [INFO] [1531356280.620330]: Setup subscriber on sound [turtlebot3_msgs/Sound] [INFO] [1531356280.649508]: Setup subscriber on motor_power [std_msgs/Bool] [INFO] [1531356280.688276]: Setup subscriber on reset [std_msgs/Empty] [INFO] [1531356282.022709]: Setup TF on Odometry [tb3_0/odom] [INFO] [1531356282.026863]: Setup TF on IMU [tb3_0/imu_link] [INFO] [1531356282.030138]: Setup TF on MagneticField [tb3_0/mag_link] [INFO] [1531356282.033628]: Setup TF on JointState [tb3_0/base_link] [INFO] [1531356282.041117]: -------------------------- [INFO] [1531356282.044421]: Connected to OpenCR board! [INFO] [1531356282.047700]: This core(v1.2.1) is compatible with TB3 Burger [INFO] [1531356282.051355]: -------------------------- [INFO] [1531356282.054785]: Start Calibration of Gyro [INFO] [1531356284.585490]: Calibration End ``` 4. **[Remote PC 端]** 啟動具有相同 namespace 的 robot state publisher - [TurtleBot(tb3_0)] ``` $ ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_bringup turtlebot3_remote.launch multi_robot_name:=tb3_0 ``` - [TurtleBot(tb3_1)] ``` $ ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_bringup turtlebot3_remote.launch multi_robot_name:=tb3_1 ``` 5. 在開始另一個應用程序之前,檢查 topics 主題和 TF tree 變換樹以打開 rqt。 ``` $ rqt ``` ![](https://i.imgur.com/b9o54JO.png) 要使用此設置,每個 TB3 要使用 SLAM 製作地圖,並且這些地圖要由 [multi_map_merge](http://wiki.ros.org/multirobot_map_merge) 套件同時合併。您可以瀏覽 [Virtual SLAM by Multiple TurtleBot3s](http://emanual.robotis.com/docs/en/platform/turtlebot3/simulation/#2-excute-slam) 章節,來獲取更多有關的訊息。 # **11. Locomotion 各種 TB3 改裝運動造型** --- 跟 Melodic 相同,請參考 Melodic 內容 **TurtleBot3 Friends 改裝造型列表(locomotion list)** - TurtleBot3 Friends: Car 小車 - TurtleBot3 Friends: OpenManipulator 機器手臂 - TurtleBot3 Friends: Segway 賽格威二輪平衡 - TurtleBot3 Friends: Conveyor 輸送車 - TurtleBot3 Friends: Monster 怪獸四驅車 - TurtleBot3 Friends: Tank 履帶車 - TurtleBot3 Friends: Omni 全向輪 - TurtleBot3 Friends: Mecanum 萬象輪 - TurtleBot3 Friends: Bike 三輪車 - TurtleBot3 Friends: Road Train 聯結車 - TurtleBot3 Friends: Real TurtleBot 真烏龜 - TurtleBot3 Friends: Carrier 多層運送車 # **12. Learn 學習資源課程** --- 跟 Melodic 相同,請參考 Melodic 內容 ## 12.1. Amazon AWS RoboMaker 使用 TurtleBot3 跟 Melodic 相同,請參考 Melodic 內容 ### 12.1.1. AWS RoboMaker 範例使用 TB3 ### 12.1.2. AWS RoboMaker 強化學習範例使用 TB3 ## 12.2 透過 Matlab 蒐集數據 跟 Melodic 相同,請參考 Melodic 內容 ## 12.3. The Construct 線上教學網站 跟 Melodic 相同,請參考 Melodic 內容 ### 12.3.1. MASTER WITH ROS: TurtleBot3 (英文課程) ### 12.3.2. 使用 RDS v2.0 在 5 分鐘內進行 TurtleBot3 模擬 ### 12.3.3. TurtleBot3 光達掃描的訂閱 ## 12.4. TurtleBot3 Blockly 跟 Melodic 相同,請參考 Melodic 內容 ## 12.5. TurtleBot3 Simulation on ROS Indigo 跟 Melodic 相同,請參考 Melodic 內容 ## 12.6. Youtube 影片課程 跟 Melodic 相同,請參考 Melodic 內容 ## 12.7. 實體書 有簡中版 PDF,請跟採智科技詢問 ## 12.8. TurtleBot3 影片分享 跟 Melodic 相同,請參考 Melodic 內容 ### 12.8.1. Open Source Team 的 TB3 影片 ### 12.8.2. ROBOTIS Channel 的 TB3 影片 ### 12.8.3. TB3 的一些有趣專案項目介紹 # **13. 更多產品資訊** --- 跟 Melodic 相同,請參考 Melodic 內容 ## 13.1. 附錄 - TB3 主要零件補充說明 跟 Melodic 相同,請參考 Melodic 內容 ### 13.1.1. Dynamixel 智能馬達 ### 13.1.2. OpenCR 1.0 控制板 ### 13.1.3. LDS-01 光達 ### 13.1.4. LDS-02 光達 ### 13.1.5. Intel RealSense R200 深度攝影機 ### 13.1.6. Raspberry Pi camera v2 樹莓派攝影機 ## 13.2. 相容之第三方設備 跟 Melodic 相同,請參考 Melodic 內容 ### 13.2.1. Computer ### 13.2.2. 感測器 ## 13.3. 添加新感測器到 TB3 OpenCR 板 跟 Melodic 相同,請參考 Melodic 內容 ### 13.3.1. Bumper 碰觸感測器 ### 13.3.2. IR 感測器 ### 13.3.3. Ultrasonic 超音波 ### 13.3.4. Illumination 照明 ### 13.3.5. LED ## 13.4. 開源資源下載及授權 跟 Melodic 相同,請參考 Melodic 內容 ### 13.4.1. TB3 開源軟體下載 ### 13.4.2. 開源硬體下載 ### 13.4.3. 軟體授權 ### 13.4.4. 硬體授權 ### 13.4.5. 文件授權 # **14. 常見問題 FAQ** --- 跟 Melodic 相同,請參考 Melodic 內容 **常見問題**: 1. 如何在 Raspberry Pi 樹莓派啟動 SSH Server 2. 如何在 TB3 及 Remote PC 間同步時間 3. 設定 TB3 上的 Dynamixel 智能馬達 4. 當電池連接在 TB3 時,可以充電嗎? 5. 如何下載 TB3 的 3D 列印 STL 檔案 6. Intel Joule 深度攝影機 USB-C Port 在 Win 10 不能辨識 7. Intel Joule 深度攝影機在開機/安裝時凍結 8. 如何更新軟體 9. 如何更新韌體 # **15. 聯絡採智科技** --- ![](https://i.imgur.com/jZ7APk4.png) ![](https://i.imgur.com/mJ5jCT8.png) 採智科技是 [**TurtleBot3 台灣唯一官方授權代理商**](https://www.turtlebot.com/partners/),如有產品需求,使用,技術或維修上的問題,請聯絡我們。 **採智科技股份有限公司** 台北市11076信義區松德路12號10F Tel: +886-2-2345-7799 Fax: +886-2-2345-0867 mail: info(at)idminer.com.tw 採智科技網站: http://www.idminer.com.tw/ ** **下載 "ROS 機器人編程" 簡中版** (使用 TurtleBot3 為 ROS 1 實作平台) - [**ROS 機器人編程- 簡中 PDF**](https://www.dropbox.com/s/5cqhl5f17e2p1b5/ROS_Robot_Programming_CN.pdf?dl=0) - [**ROS Robot Programming- 英文 PDF**](https://www.dropbox.com/s/x1bj7u878p2hgtq/ROS_Robot_Programming_EN.pdf?dl=0) ![](https://i.imgur.com/R8L7KfX.png) | **簡中版章節列表** | | | |:--------------------- |:----------------------- | --------------- | | 1. 機器人軟件平台 | 6. ROS 工具 | 11. SLAM 和導航 | | 2. 機器人操作系統 ROS | 7. ROS 編程基礎 | 12. 服務機器人 | | 3. 搭建 ROS 開發環境 | 8. 機器人、傳感器和電機 | 13. 機械手臂 | | 4. ROS 的重要概念 | 9. 嵌入式系統 | | | 5. ROS 命令 | 10. 移動機器人 | | ###### tags: `TurtleBot3(ROS1)`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully