Robot/TurtleBot3

[TurtleBot3][Dashing] 3. SBC(Single-Board Computer) Setup

jstar0525 2021. 8. 10. 18:35
반응형

https://emanual.robotis.com/docs/en/platform/turtlebot3/sbc_setup/#sbc-setup

 

ROBOTIS e-Manual

 

emanual.robotis.com

 

 


WARNING

  • This SBC Setup section is specifically written for Raspberry Pi 3B+ which is the current official TurtleBot3 SBC.
  • This process may take long time. Please do not use battery while following this section.
  • An HDMI monitor and input devices such as a keyboard and a mouse will be required to complete this setup.
  • In order to use the webOS Robotics Platform, please refer to webOS Robotics Platform instruction. Packages will be cross-compiled using OpenEmbedded on a higher performance PC and an image file is created.

 

1. Prepare microSD Card and Reader

You need a micro SD card reader to burn the OS image on your PC or laptop.

  1. Download the ubuntu-18.04.4-preinstalled-server-arm64+raspi3.img.xz image on your PC.
  2. Unzip the downloaded image.
  3. Burn the image file(.img) to the microSD card.
    • Use Restore Disk Image option in the Disks utility in Ubuntu.
    • Run the utility and select the restore image, then burn to the selected micro SD card.

    You can use various image burning tools.
    For example, Raspberry Pi Imager or Linux Disks utility can be used.
    Choose your preferred tool to burn the image to microSD.


    ■ Raspberry Pi Imager

    Please refer to this article to find more information about Raspberry Pi Imager.

    Download Raspberry Pi Imager from raspberrypi.org

    1. Click CHOOSE OS.
    2. Click Use custom and select the extracted .img file from local disk.
    3. Click CHOOSE STORAGE and select the microSD.
    4. Click WRITE to start burning the image.

    ■ Disks Utility

     

    Disks utility is included in recent Ubuntu Desktop. Search for “Disks” and launch the app.

    1. Select the microSD card in the left panel.
    2. Select Restore Disk Image option.
    3. Open the .img file from local disk.
    4. Click Start Restoring... > Restore button.

 

 

 

2. Boot Up the Raspberry Pi

  1. Connect the HDMI cable of the monitor to the HDMI port of Raspberry Pi.
  2. Connect input devices to the USB port of Raspberry Pi
  3. Insert the microSD card.
  4. Connect the power (either with USB or OpenCR) to turn on the Raspberry Pi.

 

 

 

3. Configure the Raspberry Pi

  1. Log in with default username(ubuntu) and password(ubuntu). After logged in, system will ask you to change the password.

  2. Open automatic update setting file.
    $ sudo nano /etc/apt/apt.conf.d/20auto-upgrades​
  3. Edit to disable automatic update settings as below.
    APT::Periodic::Update-Package-Lists "0";
    APT::Periodic::Unattended-Upgrade "0";​
    Save the file with Ctrl+S and exit with Ctrl+X.

  4. Enter below command to configure the WiFi network setting.
    $ sudo nano /etc/netplan/50-cloud-init.yaml​
  5. When the editor is opened, append below contents at the end of the file.
    Replace the WIFI_SSID and WIFI_PASSWORD with your wifi SSID and password.
    network:
        version: 2
        renderer: networkd
        ethernets:
            eth0:
              dhcp4: yes
              dhcp6: yes
              optional: true
        wifis:
            wlan0:
              dhcp4: yes
              dhcp6: yes
              access-points:
                WIFI_SSID:
                  password: WIFI_PASSWORD

    Save the file with Ctrl+S and exit with Ctrl+X.

  6. Apply all configuration for the renderers, and then reboot the Raspberry Pi.
    $ sudo netplan apply
    $ reboot​
  7. Set the systemd to prevent boot-up delay even if there is no network at startup. Run the command below to set mask the systemd process using the following command.
    $ systemctl mask systemd-networkd-wait-online.service​
  8. Disable Suspend and Hibernation
    $ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target​
  9. Install and enable the SSH
    $ sudo apt install ssh
    $ sudo systemctl enable --now ssh
    $ reboot​
  10. After rebooting the Raspberry Pi, if you wish to work from the Remote PC using SSH, use below command from the remote PC terminal. The default password is ubuntu.
    $ ssh ubuntu@{IP Address of Raspberry PI}​
    * check IP
    $ ifconfig
    
    eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
            ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 100  bytes 7784 (7.7 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 100  bytes 7784 (7.7 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.0.3  netmask 255.255.255.0  broadcast 192.168.0.255
            inet6 xxxx::xxxx:xxxx:xxxx:xxxx  prefixlen 64  scopeid 0x20<link>
            ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
            RX packets 324  bytes 315749 (315.7 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 289  bytes 40538 (40.5 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    wlan0의 inet에 해당하는 IP임을 알 수 있다.또한, DHCP로 인해 IP가 바뀌는 것을 방지하기 위해
    공유기에서 ether에 해당하는 MAC주소를 사용하여
    IP가 추후에 변경되지 않도록 하였다.

    https://jstar0525.tistory.com/130
 

[TCP/IP] DHCP

공유기(router)을 사용하다보면 DHCP라는 용어가 나온다. 이에 대해 간단하게 알아보고, 활용해봅시다. 1. DHCP 용어 The Dynamic Host Configuration Protocol (DHCP) is a network management protocol used on..

jstar0525.tistory.com

 

 

 

 

4. Add Swap Space

  1. Enter the command below to create 2GB swap space.
    $ sudo swapoff /swapfile
    You can ignore below error when entering swapoff /swapfile command.
    swapoff: /swapfile: swapoff failed: No such file or directory​
    $ sudo fallocate -l 2G /swapfile
    $ sudo chmod 600 /swapfile
    $ sudo mkswap /swapfile
    $ sudo swapon /swapfile
    $ sudo nano /etc/fstab​​


  2. When the editor opens the fstab file, append below contents at the end of the file.
    /swapfile swap swap defaults 0 0​


  3. Check if 2GB of swap space is correctly configured.
    $ sudo free -h
                  total        used        free      shared  buff/cache   available
    Mem:           912M         97M        263M        4.4M        550M        795M
    Swap:          2.0G          0B        2.0G​
Please refer to the Ubuntu Blog below for more useful information.

 

 

 

5. Install ROS Dashing Diademata

  1. Open a terminal on SBC
  2. Update and upgrade your software
    $ sudo apt update && sudo apt upgrade​
  3. Setup locale
    $ sudo locale-gen en_US en_US.UTF-8
    $ sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
    $ export LANG=en_US.UTF-8​
  4. Setup sources
    $ sudo apt update && sudo apt install curl gnupg2 lsb-release
    $ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
    $ sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'​
  5. Install ROS 2 packages
    $ sudo apt update
    $ sudo apt install ros-dashing-ros-base​

 

 

 

6. Install ROS Packages

$ sudo apt install python3-argcomplete python3-colcon-common-extensions libboost-system-dev build-essential
$ sudo apt install ros-dashing-hls-lfcd-lds-driver
$ sudo apt install ros-dashing-turtlebot3-msgs
$ sudo apt install ros-dashing-dynamixel-sdk
$ mkdir -p ~/turtlebot3_ws/src && cd ~/turtlebot3_ws/src
$ git clone -b dashing-devel https://github.com/ROBOTIS-GIT/turtlebot3.git
$ cd ~/turtlebot3_ws/src/turtlebot3
$ rm -r turtlebot3_cartographer turtlebot3_navigation2
$ cd ~/turtlebot3_ws/
$ echo 'source /opt/ros/dashing/setup.bash' >> ~/.bashrc
$ source ~/.bashrc
$ colcon build --symlink-install --parallel-workers 1
$ echo 'source ~/turtlebot3_ws/install/setup.bash' >> ~/.bashrc
$ source ~/.bashrc

 

 

 

 

7. Environment Setup (Domain ID Allocation)

In DDS communication, ROS_DOMAIN_ID must be matched between Remote PC and TurtleBot3 for wireless communication under the same network environment. Following commands shows how to assign a ROS_DOMAIN_ID to SBC in TurtleBot3.

  • A default ID of TurtleBot3 is set as 0.
  • To configure the ROS_DOMAIN_ID of Remote PC and SBC in TurtleBot3 to 30 is recommendable.
  1. Open a terminal on SBC
  2. Use the following commands.
    $ echo 'export ROS_DOMAIN_ID=30 #TURTLEBOT3' >> ~/.bashrc
    $ source ~/.bashrc​
WARNING : Do not use an identical ROS_DOMAIN_ID with others in the same network. It will cause a conflict of communication between users under the same network environment.
반응형