<commit_before>
<div style="counter-reset: h1 3"></div>
<div style="counter-reset: h2 1"></div>

{::options parse_block_html="true" /}

## [SBC Setup](#sbc-setup)

**WARNING**: This SBC Setup section involves with Raspberry Pi 3B+. For Intel Joule 570x SBC, please refer to the [Intel Joule 570x Setup](/docs/en/platform/turtlebot3/joule_setup/#install-linux-ubuntu) manual.
{: .notice--warning}

**NOTE**: We are offering three models of TurtleBot3. TurtleBot3 Burger and Waffle Pi use Raspberry Pi 3 B and B+, and TurtleBot3 Waffle uses Intel Joule 570x. Choose from the following pages according to the SBC used in your model.
{: .notice--info}

**NOTE**: If you would like to use Windows on your Turtlebot3, you'll need to separately acquire a Windows 10 Enterprise compatible Single Board Computer, and adapt it to the turtlebot power supply.
{: .notice--info}

### [Raspberry Pi 3](#raspberry-pi-3)

{% capture info_01 %}
**NOTE**: Use either of 3 ways to install Linux and ROS on Raspberry Pi 3

1. For Ubuntu Mate installation, read `Install Linux (Ubuntu MATE)` guide. Be sure to install ROS and dependency packages after installing the Linux images on SBC of TurtleBot. The instruction takes about 1 hour to install ROS and related packages for TurtleBot3.
2. For Linux distro image installation based on Raspbian, read `Install Linux (Raspbian)` guide. You do not have to do additional installations as the distro image contains ROS and ROS packages related to TurtleBot3.
3. For webOS Robotics Platform, read `webOS Robotics Platform` guide. You do not need to compile packages on TurtleBot3. They will be cross-compiled using OpenEmbedded on a higher performance PC, Ubuntu 18.04 based and an image file created from them.
{% endcapture %}
<div class="notice--info">{{ info_01 | markdownify }}</div>

{% capture info_02 %}
**NOTE**: Raspberry Pi 3 B+ is available in TurtleBot3 Burger and Waffle Pi. If you use Raspberry Pi 3 B+, please refer to the following.
{% endcapture %}

<div class="notice--info">{{ info_02 | markdownify }}</div>

1. [Install Linux (Ubuntu MATE)][install_linux_ubuntu_mate]

2. [Install Linux (Raspbian)][install_linux_based_on_raspbian]

3. [Install Linux (webOS Robotics Platform)](https://github.com/ros/meta-ros/wiki/OpenEmbedded-Build-Instructions)

### [Intel Joule 570x](#intel-joule-570x)

- [Install Linux (Ubuntu)][install_ubuntu]

[install_linux_ubuntu_mate]: /docs/en/platform/turtlebot3/raspberry_pi_3_setup/#install-linux-ubuntu-mate
[install_linux_based_on_raspbian]: /docs/en/platform/turtlebot3/raspberry_pi_3_setup/#install-linux-based-on-raspbian
[install_ubuntu]: /docs/en/platform/turtlebot3/joule_setup/#install-linux-ubuntu

### [[Windows] Windows 10 SBC](#windows-windows-10-sbc)

**NOTE**: ROS on Windows was brought up using [Up2](https://up-board.org/upsquared/specifications/) and an `Intel Nuc`.
{: .notice--warning}

1. You can download a trial of Windows 10 IoT Enterprise Long Term Service (LTSC) from the following link:

   - [Download Windwos 10 IoT Enterprise LTSC(Trial)][windows_download_link]

   [windows_download_link]: https://www.microsoft.com/en-us/evalcenter/evaluate-windows-10-enterprise

2. Please refer to the [ROS Wiki instructions](https://wiki.ros.org/Installation/Windows) for installing ROS on Windows.
3. Please install the [CP2102 Driver from SI Labs](https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers) in order to communicate with the Lidar.

Before starting to work with turtlebot3 with a Windows 10 Single Board Computer, you'll need to identify which COM port the lidar and OpenCR board are mounted on. To do this, visit the Windows Device Manager - which you can access by right clicking on the Start Menu icon, and selecting `Device Manager` and locate the COM port associated with the Lidar and OpenCR board.

Then modify the following files:

`turtlebot3_bringup/launch/turtlebot3_core-win.launch`

```xml
<node pkg="rosserial_python" type="serial_node.py" name="turtlebot3_core" output="screen">
    <param name="port" value="COMx"/>
```

`turtlebot3_bringup/launch/turtlebot3_lidar-win.launch`

```xml
 <node pkg="hls_lfcd_lds_driver" type="hlds_laser_publisher" name="turtlebot3_lds" output="screen">
    <param name="port" value="COMy"/>
```
<commit_msg>sbc_setup_foxy<commit_after>
<div style="counter-reset: h1 3"></div>
<div style="counter-reset: h2 1"></div>

## [SBC Setup](#sbc-setup)

{% capture warning_01 %}
**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.
{% endcapture %}
<div class="notice--danger">{{ warning_01 | markdownify }}</div>

### [Prepare microSD Card](#prepare-microsd-card)
1. Download the proper `Ubuntu 20.04.1 Preinstalled Server` image for your SBC from the links below.
  - [Ubuntu 20.04.1 Preinstalled Server ARM64 for Raspberry Pi3](http://cdimage.ubuntu.com/ubuntu-server/focal/daily-preinstalled/current/focal-preinstalled-server-arm64+raspi.img.xz)

2. Unzip the downloaded image.

3. Burn the image 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.
<details>
<summary id="summary_for_foreins" style="outline: inherit;">
![](/assets/click_here.png) Click here to expand more details about other micro SD card burning methods
{: .notice--success}
</summary>
- You can use the [etcher.io](https://etcher.io/) to burn the image.
- You can also use 'dd' command in Linux or use application 'win32 Disk Imager' in Windows. For a complete guide, refer to the instruction for [Linux](https://elinux.org/RPi_Easy_SD_Card_Setup#Using_the_Linux_command_line) or [Windows](https://elinux.org/RPi_Easy_SD_Card_Setup#Using_the_Win32DiskImager_program).
</details>


### 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.

### Configure the Raspberry Pi
1. Log in with default username(`ubuntu`) and password(`<PASSWORD>`). After logged in, system will ask you whether you change the password or not.

2. Disable Automatic update
  ```bash
$ sudo nano /etc/apt/apt.conf.d/20auto-upgrades
  ```

3. Change the update settings as below.
  ```bash
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Unattended-Upgrade "0";
  ```

4. Open the terminal with `Ctrl`+`Alt`+`T` and enter below commands to configure the WiFi network setting.
  ```bash
$ sudo touch /etc/netplan/99-netcfg.yaml
$ sudo nano /etc/netplan/99-netcfg.yaml
  ```

5. When the editor is opened, append below contents at the end of the file.  
  ![](/assets/images/platform/turtlebot3/setup/ros2_sbc_netcfg.png)

6. Apply all configuration for the renderers, and then reboot the Raspberry Pi.
  ```bash
$ 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.
```bash
$ systemctl mask systemd-networkd-wait-online.service
```

8. Disable Suspend and Hibernation
  ```bash
$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
  ```

9. Enable the SSH
  ```bash
$ 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 **<PASSWORD>**.
  ```bash
$ ssh ubuntu@{IP Address of Raspberry PI}
  ```

### [Add Swap Space](#add-swap-space)
1. Enter the command below to create 2GB swap space.  
  ```bash
$ sudo swapoff /swapfile
$ 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.
  ```bash
/swapfile swap swap defaults 0 0
  ```

3. Check if 2GB of swap space is correctly configured.
```bash
$ sudo free -h
                 total        used        free      shared  buff/cache   available
Mem:           912M         97M        263M        4.4M        550M        795M
Swap:          1.0G          0B        1.0G
```

### Install ROS Foxy Fitzroy

- [ROS 2 Installation Guide](https://index.ros.org/doc/ros2/Installation/Foxy/Linux-Install-Debians/)

1. Open a terminal on **SBC**

2. Update and upgrade your software
```bash
$ sudo apt update && sudo apt upgrade
```
3. Setup locale
```bash
$ 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
```bash
$ 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=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'
```
5. Install ROS 2 packages
```bash
$ sudo apt update
$ sudo apt install ros-foxy-ros-base
```

### Install TurtleBot3 Packages

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

### 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.
```bash
$ echo 'source ~/turtlebot3_ws/install/setup.bash' >> ~/.bashrc
$ echo 'export ROS_DOMAIN_ID=30 #TURTLEBOT3' >> ~/.bashrc
$ source ~/.bashrc
```

    **WARNING** : Do not **OVERLAP** any IDs between you and other users. It will cause a conflict of communication between users under the same network environment.
    {: .notice--warning}

{'fraction_non_alphanumeric': 0.10944965492833127, 'fraction_numerical': 0.01946558131304194, 'mean_word_length': 3.7772612003381236, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 34, 'https://': 14, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5930041', 'n_tokens_mistral': 4022, 'n_tokens_neox': 3563, 'n_words': 1269}