<style> .red {color: red;} </style> <style> .sol {color: green; font-weight: bold;} </style> ###### tags: `vsclab` `turtlebot` `ubuntu` `ros` `raspberry pi` # TurtleBot3 Setup :::spoiler 文章目錄 [toc] ::: --- :::warning * [Install TP-link TL-WN725N USB wifi driver on Ubuntu 20.04](https://askubuntu.com/a/1356730) * Ubuntu 20.04 需要額外安裝套件才有 `ifconfig` ``` $ sudo apt install net-tools ``` * 查看是否已安裝 ROS 套件 ``` $ dpkg --list | grep ROS ``` ::: - [品瑄版本](https://hackmd.io/Ah_pIkbvQ-OqW9vd1amglw) - [TurtleBot 3 Quick Guide](https://emanual.robotis.com/docs/en/platform/turtlebot3/quick-start/#pc-setup) ## 🍒Raspberry Pi: connect to the Internet :::warning 若使用<span class="red">手機熱點</span>,請將頻寬設定成 <span class="red">**2.4 GHz**</span> ::: #### 1. Open Configuration File ```linux $ sudo vim /etc/netplan/50-cloud-init.yaml ``` #### 2. Edit Configuration File ##### 2-1. For Wi-Fi * [See Example](https://linuxconfig.org/how-to-configure-static-ip-address-on-ubuntu-18-04-bionic-beaver-linux) * [Multiple SSID Example](https://askubuntu.com/questions/1245253/set-multiple-wifi-access-points-in-ubuntu-20-04) * To select the wifi, first show the wifi list ``` $ sudo wpa_cli -i wlan0 list_networks ``` * it will show you the network_id and network_ssid, then select by network_id. ``` $ sudo wpa_cli -i wlan0 select_network network_id ``` ##### 2-2. For Static IP * 請參考此格式 https://blog.toright.com/posts/6293/ubuntu-18-04-%E9%80%8F%E9%81%8E-netplan-%E8%A8%AD%E5%AE%9A%E7%B6%B2%E8%B7%AF%E5%8D%A1-ip.html * 注意**子網路遮罩**的格式需要轉換 https://www.calculator.net/ip-subnet-calculator.html ##### :page_facing_up: Netplan Example `/etc/netplan/50-cloud-init.yaml` ``` # This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no addresses: [140.116.215.151/27] gateway4: 140.116.215.157 nameservers: addresses: [8.8.8.8] wifis: wlan0: dhcp4: yes dhcp6: yes access-points: "VSCLAB": password: "VSCLAB-pwd" wlan0: dhcp4: yes dhcp6: yes access-points: "rubato_phone": password: "rubato_phone-pwd" ``` #### 3. Apply Changes ```linux $ sudo netplan --debug apply # more details # or $ sudo netplan apply # or (for ssh user) $ sudo netplan try # apply only 120 sec then restore ``` #### 4. Confirm IP Address ``` $ ip a # IP address $ ip r # default gateway IP address ``` #### 5. [Check Internet Connectivity in Linux Terminal](https://linuxhint.com/check-internet-connectivity-terminal/) ##### Method 1: PING Command ``` $ ping -c 3 google.com ``` ![](https://linuxhint.com/wp-content/uploads/2021/06/1.png) ##### Method 2: CURL Command ``` $ curl -I https://linuxhint.com/ ``` ![](https://linuxhint.com/wp-content/uploads/2021/06/2.png) ## 固定裝置的 DHCP 位址 :::info 每次裝置重新連線時,分享器會再重新分配 IP,導致 ROS IP 也要跟著重新設定 **若希望固定 IP 位址,請參考以下教學** ::: ### 1. 查詢 TurtleBot 的 MAC 位址 ### 2. 更改分享器設定 1. 使用 Wi-Fi 或是有線網路連到分享器 2. 打開瀏覽器,網址列輸入`192.168.1.1` 3. 登入分享器設定(帳密請洽網管) ![](https://i.imgur.com/ysRtooB.png) 4. **DHCP伺服器**>**保留指定IP位址**>**新增** ![](https://i.imgur.com/wlJEvbP.png) 5. **系統工具**>**重新開機** ## SSH Login Automatically * [How to automate SSH login with password?](https://serverfault.com/a/241593) # Raspberry Pi 相關 ## :battery:電源方面 #### 進行長時間操作建議不要使用電池(例如:更新軟體、重灌系統) * [OpenCR 電源規格表](https://emanual.robotis.com/docs/en/parts/controller/opencr10/#specifications) ![](https://emanual.robotis.com/assets/images/parts/controller/opencr10/opencr_pinout.png) * [論壇討論](https://answers.ros.org/question/359856/turtlebot3-wired-power-operation/) :::danger **結論:** SMPS (12V 5A) 與 Battery (11.1V) 不能同時供電!**一次僅能使用一個電源輸入** ![](https://i.imgur.com/G945Qwt.jpg) ::: <!-- * https://goodspeedlee.blogspot.com/2018/04/raspberry-pi.html --> # Day 2-3 | ROS ## Install ROS & ros_menu * [Official](http://wiki.ros.org/noetic/Installation/Ubuntu) * [Adlink/ros_menu](https://github.com/Adlink-ROS/ros_menu) :::warning <span class="red">Server 啟動 ros1 遇到 $shell 名稱錯誤問題</span> `/tmp/host_sourcefile.txt:source:3: 沒有此一檔案或目錄: /opt/ros/noetic/setup./usr/bin/zsh` <!-- shell=`cat /proc/$$/cmdline | tr -d '\0' | tr -d '-'` --> <span class="sol">Solution:</span> 重新定義`/proc/$$/cmdline` PID執行緒參數 1. For Terminal ![](https://i.imgur.com/tAwWw34.png) 2. For tmux ![](https://i.imgur.com/bCUixef.png) ::: * [連線埠查詢](https://askubuntu.com/questions/9368/how-can-i-see-what-ports-are-open-on-my-machine) ``` $ sudo netstat -ntlp ``` ## Run Example Code * [TurtleBot3 Bringup](https://emanual.robotis.com/docs/en/platform/turtlebot3/bringup/#bringup) :::warning <span class="red"> [sensor_msgs/BatteryState] 問題 </span> `[ERROR] [1642758400.659716]: Creation of publisher failed: Checksum does not match: 4ddae7f048e32fda22cac764685e3974,476f837fa6771f6e16e3bf4ef96f8770` <span class="sol"> Solution: </span> [OpenCR 的版本必須與 PC 的 ROS 相同](https://discourse.ros.org/t/turtlebot3-software-and-firmware-update-and-waffle-pi/3729/4) ::: # ==ROS 2== foxy for TB3 ## Install ros2 & ros_menu <span class="red">on SBC</span> * [Foxy > Click to expand : Manual SBC Setup Instructions](https://emanual.robotis.com/docs/en/platform/turtlebot3/sbc_setup/#sbc-setup) <!-- * [Install ROS2 Foxy on Raspberry Pi 4](https://roboticsbackend.com/install-ros2-on-raspberry-pi/) --> * [Adlink/ros_menu](https://github.com/Adlink-ROS/ros_menu) ## Communicate with Windows using PuTTY * [Download PuTTY](https://www.putty.org/) ![](https://i.imgur.com/pU8Zuht.png) :::warning <span class="red">如何在 PuTTY 對 tmux 視窗貼上</span> <span class="sol"> Solution:</span> [Press shift](https://superuser.com/questions/1410591/how-to-paste-when-using-tmux-on-a-remote-server-with-putty) ::: ## :+1: Communicate with Windows using Bitvise SSH * [Download Bitvise SSH](https://www.bitvise.com/ssh-client-download) * 有 GUI 介面可直接複製、瀏覽 Server、Client 檔案 ![](https://i.imgur.com/MOhBPdw.png) ## MATLAB ROS Toolbox ## Joysticks x Raspberry Pi ### Wiring PS3 * [Connect PS3 Joystick to Raspberry 4b with ROS](https://jepeloa.medium.com/connect-ps3-joystick-to-raspberry-4b-with-ros-6c4603f2c752) ### Wireless PS2 {%youtube gshsbqfgJmE %} * https://pinout.xyz/pinout/pin1_3v3_power #### GPIO Library Installation * [GPIO 簡介](https://medium.com/geekculture/gpio-programming-on-the-raspberry-pi-python-libraries-e12af7e0a812) * [Pin 接線圖](http://wiringpi.com/download-and-install/) * https://atceiling.blogspot.com/2014/02/raspberry-pi-wiringpi-gpio.html :::warning 由於 GPIO 原作者 Gordon 已不再維護,請使用 `git clone https://github.com/WiringPi/WiringPi` ::: ### Xbox * [Xbox搖桿選購](https://blog.xuite.net/e613011/book/588868619) * [e-Manual](https://emanual.robotis.com/docs/en/platform/turtlebot3/teleoperation/#xbox-360-joystick) * [ROS使用XBOX ONE 手柄](https://www.cnblogs.com/lizhensheng/p/11117708.html) * {%youtube 4cSRdS83PX4 %} * [樹梅派藍芽設定](https://medium.com/@r3850355/%E7%94%A8-raspberry-pi-4-%E4%BE%86%E5%81%9A-line-beacon-%E5%9B%9B-%E8%A8%AD%E5%AE%9A%E8%97%8D%E7%89%99-e06901d0602a) ### ROS Library * [teleop_twist_joy](https://index.ros.org/p/teleop_twist_joy/github-ros2-teleop_twist_joy/) * [teleop_twist_joy](http://wiki.ros.org/teleop_twist_joy) # Pi Camera Module install on TB3 burger ## Hardware Installation Tutorial {%youtube VzYGDq0D1mw %} * See [TurtleBot3 Waffle Pi 3D Model](https://emanual.robotis.com/docs/en/platform/turtlebot3/features/#open-source-hardware) ## System Settings ### Install `raspi-config` * [Follow this instruction](https://github.com/EmilGus/install_raspi-config) ```shell $ git clone https://github.com/EmilGus/install_raspi-config $ cd install_raspi-config $ sudo sh install.sh ``` ### Enable Camera Module :::warning <span class="red"> [Your firmware appears to be out of date (no start_x.elf). Please update] 問題 </span> <span class="sol"> Solution: </span> [树莓派通过raspi-config启动摄像头时,出错:Your firmwave appears to be out of date (no start_x.elf). Please update](https://blog.csdn.net/qq_34493401/article/details/107672691) ```shell $ df -h $ sudo mount /dev/mmcblk0p1 /boot $ sudo raspi-config ``` ::: ## Take a photo ### Camera Module with Raspberry Pi4 {%youtube 0hrF8Wq8SSQ %} ``` $ vcgencmd get_camera > supported=1 detected=1 # success $ ls /dev/video* # raspistill $ sudo apt install libraspberrypi-bin $ raspistill -v $ sudo modprobe bcm2835-v4l2 $ sudo raspistill -o test.jpg # fswebcam $ sudo apt-get install fswebcam $ sudo fswebcam image.jpg $ sudo fswebcam /dev/video10 image.jpg ``` ## Use ROS ### Install ROS Package `raspicam` (TurtleBot) * [Github: raspicam_node/Build Instructions](https://github.com/UbiquityRobotics/raspicam_node/tree/noetic-devel#build-instructions) ### Run `raspicam` Node * [Run raspicam Node](https://emanual.robotis.com/docs/en/platform/turtlebot3/appendix_raspi_cam/#run-raspicam-node)